## Introduction

This is a quick how-to explaining everything you need to get started using your Flexiforce Pressure Sensor.  This example uses the 25lb version, but the concepts learned apply to all the Flex sensors.

## Requirements

Necessary hardware to follow this guide:

You'll also need the Arduino IDE for programming.

## Hardware

The Flexiforce Pressure Sensor is essentially a variable resistor. When no pressure is applied, the resistance between the two outer leads is incredibly large, probably greater than 10 Mega Ohms (more than my meter can measure). When pressure is applied, the resistance measured between the outer leads lowers until you've reached the max pressure it's intended to measure. In this case that's about 25 lbs of pressure, and the current Flexiforce Pressure sensor I'm using measures about 50K Ohms when given that max amount of pressure.

You can test the range of your sensor using a multimeter. Just attach the two outer leads to the multimeter and set the meter to measure resistance. Then squeeze the sensor and watch the resistance value change.

Now, let's read values with an Arduino. To do this, we create a voltage divider circuit with the Flexiforce sensor and an extra resistor. I picked 1M Ohm in this example because it's about in the middle of the Flexiforce sensor's dynamic range. Many other similar values could work as well.

Connect 5V to one side of the voltage divider, and GND to the other. In the middle, where the Flexiforce sensor and the resistor connect, connect one of the analog-in pins of the Arduino with a jumper wire. In this case I used pin A0. Here is a Fritzing diagram of the setup:

Fritzing Wiring Diagram

*Note*: The sensor in the image doesn't look exactly the same as the Flexiforce sensor, but very close. The actual Flexiforce sensor has a larger surface area.

## Software

Now that you have your circuit wired and ready, it's time to write some very basic Arduino code.  This code is almost exactly the same as Arduino's standard AnalogReadSerial example. Let's take a look to see what it's doing:

```
// Flexiforce quick start example
// Reads A0 every 100ms and sends voltage value over serial

void setup()
{
// Start serial at 9600 baud
Serial.begin(9600);
}

```
```    void loop()
{
// Read the input on analog pin 0:

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);

// Print out the value you read:
Serial.println(voltage);

// Wait 100 milliseconds
delay(100);
}

```

The code is simply running in a small infinite loop every 100ms, or 10 times a second. In each pass through the loop, it measures the voltage on pin A0 and returns a corresponding value between 0 and 1023. 0 represents ground in this case and 1023 indicates A0 is sitting at 5 Volts. For other numbers in between, we can figure out the voltage by multiplying the measured number by the fraction, 5.0 / 1023.0. We then spit this value back over the Serial port, we can watch the values change in real time.

Go ahead and try. Make sure you have the hardware connected correctly. Program the Arduino, open up the Arduino Serial Monitor (make sure it's using 9600 baud), and watch the voltage values change as you press and release the Flexiforce Pressure Sensor.

## Conclusion

Now you know how to use the Flexiforce Pressure Sensor. Believe it or not, there are many different analog sensors where you can use what you learned here and collect data the exact same way. Now it's all up to you to use these types of products however you imagine. If you have any other questions or comments, please drop them in the box below. Enjoy!

• very good tutorial about how to interface a force sensor. Also, I add this tutorial in my article about force sensors http://www.intorobotics.com/force-sensors-reviewed-and-programming-tutorials/

• Hello. sorry, am completely new to arduino, so I may ask ‘stupid’ questions… ;) I am searching for a solution for a musical project where I need to connect maaaany pressure sensors. so my question is, how many pressure sensor elements can I connect to an arduino board?

• With the Arduino Uno there are 6 analog input pins (A0 through A5), so you can easily connect 6 pressure sensors as shown in the tutorial. The Arduino Mega has 16 analog input ports I believe, so you could measure 16 pressure sensors with a Mega.

• C'mon SparkFun, this tutorial creates meaningless data. Here’s why the voltage divider does NOT work for a FlexiForce, and how an op amp solves the problem.

• Thiya / last year / 1

Thank you for this tutorial. I built it up like its shown above. Now i have the problem, that if i apply different weights (from around 1,6kg up to around 11kg) i only get values between 920 and 999 back. Shouldn’t i get values from 0 to 1023? What could this mistake come from? I also tried to convert it to the weight with a quiet similar line than you go for voltage. (25/1023)*Sensorvalue. But i dont get the right value back?? Its also not a linear line (but a curve). Thanks for your help!

• Thank you for the tutorial. I’m a beginner to Arduino, How do you convert Volts to pounds? I have yet to find anything out there, your guidance is appreciated.

• You have to make a calibration equation. For example, put 1 lb on the sensor then note the voltage. Put a 2 lb weight on the sensor and note the voltage. Repeat this up to 100 lb (or your sensor’s upper limit) and you can use a regression model like least-squares to fit an equation to the data points.

• so I understand the relation that represents the 0-5 voltage and the 0-1023 values, but how do I know the force or pressure value from the given information. if i want to be able to use the pressure values and compare them, is that possible?

• You have to make a calibration equation. For example, put 1 lb on the sensor then note the voltage. Put a 2 lb weight on the sensor and note the voltage. Repeat this up to 100 lb (or your sensor’s upper limit) and you can use a regression model like least-squares to fit an equation to the data points.

• Hello, I’m still fairly new to arduino builds and I’m just trying to understand how you read the actual values, do you use a separate program that acts as a GUI and shows the values? I don’t see any code for a physical screen read out like an LCD or code that would export the values to notepad or something.

Thanks for your time, I appreciate the help!

• How you output values is up to you, you can definitely use an LCD screen, 7 segment displays, LEDs, etc. The easiest way is probably to use the serial monitor in the Arduino IDE. Output your data over the serial stream and then open the serial monitor and you should see the information. Most sensor example code will do this since its easy to read and universal, if you want something more portable find a suitable display and then check for example code. Check out Arduino Reference Page as well as any introductory Arduino book or tutorial for more information.

• This is a little different then what is going on for this tutorial but I think that it may be helpful for people interested in messing around with these sensors/Arduinos, I based my code off of the above code and was planning on just doing the serial monitor that you suggested before. With this code I’m just looking to monitor 5 sensors and obtain the values, mainly looking at the hysteresis of the sensors and seeing if this is something I could use on a larger scale ~ 60 sensors. I’m not great with programming with the Arduino software, used to graphical programming. Anyway I cant get this code to load to the Arduino, do you see any glaring errors or misuse of the code in basic terms or does it need a complete re-write? Again thank you for your time and patience. I pasted the code below: I placed notes to make it easier to understand where I’m heading with it.

void setup() { //start serial at 9600 baud rate (charecters per second) Serial.begin(9600)

;void loop() { //First section Read all analog ports for the 5 flexiforce sensors //Read input on analog pin 0 int flexValue0 = analogRead(A0);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage0 = flexValue0 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage1 = flexValue1 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage2 = flexValue2 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage3 = flexValue3 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage4 = flexValue4 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Print colleceted values from the 5 flexiforce sensors for analog inputs A0-A4

// Print value from A0 Serial.println(voltage0);

// Print value from A1 Serial.println(voltage1);

// Print value from A2 Serial.println(voltage2);

// Print value from A3 Serial.println(voltage3);

// Print value from A4 Serial.println(voltage4);

// Wait 100 milliseconds or adjust delay(100); }

• Great, I’ll give it a shot and let you know if I have any issues

Greatly appreciated thank you!

• Hi, I have some questions, would this be exactly the same for the 1lb version? Also in the code where did you get the 1023 value are those bits? ohms? or what?

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0);

Thanks !

• Yep - hooking it up is exactly the same.

The 1023 comes from the 10 bit ADC used on the Arduino, which converts an analog signal into a digital value. 10 bits is 210 or 1024 different values. 0 is one of them, so the maximum is 1023 :)

• i need to shot water jet for 100 milisec and check the change of pressure over time i planned to connect this sensor directly to Oscilloscope. Q1: can i use this sensor to measure jet pressure over time? jet diameter 0.5mm Q2: is it water proof?

• Not sure if that has anything to do with this but the sensor that I am using has 3 pins and I connected the sensor directly on to the breadboard.

• I set up the circuit the exact same way as it is shown in the above diagram. And used the exact same code. But when I press on the pressure sensor, the numbers on the serial monitor change from 0.00 to 0.05 and back to 0.00 when I release the sensor.

• I purchased a sensor that had 3 pins instead of 2. How do I connect this one to an Arduino UNO board ? The part # SEN-08685

• Just to clarify for anyone else reading this, the middle pin on the sensors with 3 pins does NOT connect to anything. Only connect the outer 2 pins as indicated in the tutorial.

• Use aligator clips on the outside sensor leads to jumper wires (into the breadboard).

• if you are trying to have multiple pressure sensor to a single board, what would you do in wiring?

• You would duplicate the wiring, but run each sensor to its own analog pin on the Arduino. Each pin would then need to be defined and read in the code.

SparkFun is an online retail store that sells the bits and pieces to make your electronics projects possible. Whether it's a robot that can cook your breakfast or a GPS cat tracking device, our products and resources are designed to make the world of electronics more accessible.

In addition to products, SparkFun also offers classes and online tutorials to help educate individuals in the wonderful world of embedded electronics.