A flex sensor (often called a bend sensor) is a passive variable resistor that increases its electrical resistance as it is physically bent. Commercial models like the Spectra Symbol 2.2" (FLP2.2) or 4.5" (FLP4.5) typically sit at a baseline resistance of 10kΩ to 25kΩ when completely flat, and spike to 30kΩ–125kΩ when bent to 90°. Because they are passive components, they do not output a digital signal or a direct current; instead, they must be placed in a voltage divider circuit to produce an analog voltage that a microcontroller's ADC (Analog-to-Digital Converter) can read.
The Sensing Principle: How Flex Sensors Actually Work
At their core, standard flex sensors are constructed using a thin, flexible polymer substrate coated with a proprietary carbon or conductive polymer ink. When the sensor is flat, the conductive particles within the ink layer are tightly packed, providing a relatively low-resistance path for electrons. As you bend the sensor along its active axis, the substrate stretches on the outer curve, forcing the conductive particles to separate and micro-fracture the conductive pathways. This physical separation restricts electron flow, resulting in a proportional increase in electrical resistance that correlates directly to the bend angle.
Standard commercial flex sensors are strictly unidirectional, meaning they are designed to measure bending in only one direction (usually the side with the printed markings facing outward). Bending the sensor backward compresses the conductive ink layer, which can cause the resistance to drop unpredictably or, worse, permanently delaminate the carbon trace from the polymer base. If your application requires bidirectional bending measurement, you must mount two sensors back-to-back and read them differentially, or switch to a specialized bidirectional sensor variant which costs significantly more.
Wiring, Pinout, and Voltage Requirements
Because a flex sensor is just a resistor with wires attached, it has no intrinsic polarity. However, standardizing your wiring prevents debugging headaches later. You cannot connect a flex sensor directly to a GPIO pin and expect a reading; you must build a voltage divider to convert the changing resistance into a changing voltage.
| Parameter | Value / Specification | Implementation Notes |
|---|---|---|
| Supply Voltage (Vin) | 3.3V to 5.0V DC | Match your microcontroller logic level (use 3.3V for ESP32/RPi Pico). |
| Power Dissipation | 0.50 Watts (Max) | Keep current under 10mA to prevent self-heating and resistance drift. |
| Pin 1 (Signal/VCC) | Connect to Vin (3.3V) | Forms the top half of the voltage divider. |
| Pin 2 (GND/Output) | Junction to ADC & Fixed Resistor | The junction between the flex sensor and the fixed resistor goes to the ADC pin. |
| Fixed Resistor | 10kΩ to 22kΩ (1% tolerance) | Place between the ADC junction and GND. 10kΩ is optimal for 2.2" sensors. |
| Operating Temp | -40°C to +80°C | Resistance baseline shifts slightly at temperature extremes. |
| Typical Cost (2026) | $8.00 - $15.00 USD | Prices scale with length; 4.5" models are roughly double the cost of 2.2". |
Output Signal Math: Converting Raw ADC to Bend Angle
To get usable data, you must convert the microcontroller's raw ADC reading into a physical bend angle. This requires a two-step mathematical conversion: first from ADC voltage to resistance, and second from resistance to degrees. For this example, we assume a 3.3V supply, a 10kΩ fixed pulldown resistor, and an ESP32 microcontroller.
Step 1: The Voltage Divider Math
With the flex sensor ($R_{flex}$) on top and the fixed resistor ($R_{fixed}$) on the bottom, the voltage at the ADC junction ($V_{out}$) is:
V_out = V_in * (R_fixed / (R_flex + R_fixed))
When the sensor is flat ($R_{flex}$ ≈ 10kΩ), $V_{out}$ is roughly 1.65V. When bent to 90° ($R_{flex}$ ≈ 30kΩ), $V_{out}$ drops to roughly 0.825V. Notice that voltage decreases as the bend angle increases.
Step 2: Calculating Resistance from Measured Voltage
Rearranging the formula to solve for $R_{flex}$ using your measured voltage ($V_{meas}$):
R_flex = R_fixed * ((V_in / V_meas) - 1)
Step 3: Scaling to Degrees
Assuming a linear response between 0° (10kΩ) and 90° (30kΩ), the angle is:
Angle = ((R_flex - 10000) / (30000 - 10000)) * 90
analogRead() 12-bit value (0-4095) on older ESP32 chips, as the ADC is notoriously non-linear at the extremes. Always use analogReadMilliVolts() in the Arduino framework, which applies Espressif's factory eFuse calibration data to return a highly accurate millivolt reading. See the Espressif ADC Oneshot Documentation for hardware-level details.
Here is the exact C++ implementation for the Arduino IDE:
const int FLEX_PIN = 36; // Use ADC1 pins (36, 39, 34, 35) on ESP32
const float V_IN = 3300.0; // 3.3V in millivolts
const float R_FIXED = 10000.0; // 10k pulldown resistor
const float R_FLAT = 10000.0; // Resistance at 0 degrees
const float R_BENT = 30000.0; // Resistance at 90 degrees
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution
}
void loop() {
// Read accurate millivolts using factory calibration
float v_meas = analogReadMilliVolts(FLEX_PIN);
// Prevent division by zero if pin is floating or shorted
if (v_meas < 50) v_meas = 50;
// Calculate Flex Resistance
float r_flex = R_FIXED * ((V_IN / v_meas) - 1.0);
// Map to Angle (clamped between 0 and 90)
float angle = ((r_flex - R_FLAT) / (R_BENT - R_FLAT)) * 90.0;
angle = constrain(angle, 0.0, 90.0);
Serial.print("Voltage: "); Serial.print(v_meas); Serial.print("mV | ");
Serial.print("Resistance: "); Serial.print(r_flex); Serial.print(" ohms | ");
Serial.print("Angle: "); Serial.println(angle);
delay(100);
}
Interference, Failure Modes, and Calibration
Flex sensors are high-impedance analog components, making them highly susceptible to environmental noise. The junction between the flex sensor and the fixed resistor acts like an antenna for 50/60Hz mains hum and electromagnetic interference (EMI) from nearby motors or switching power supplies. To fix this: keep the wires between the sensor and the microcontroller under 5cm, and solder a 0.1µF ceramic capacitor directly across the ADC pin and GND to form a low-pass filter. For further noise reduction, read the ADC 16 times in a loop and average the results in software.
The most common failure mode in flex sensors is hysteresis and creep. When you bend a sensor to 90° and hold it there for five minutes, the resistance will slowly drift upward. When you release it, it will not immediately snap back to its exact 10kΩ baseline; it may linger at 12kΩ for several seconds. Because of this, flex sensors are poor choices for applications requiring absolute positional accuracy (like a robotic arm joint encoder). They are best used for relative gesture recognition (e.g., detecting a "closed fist" vs. "open hand" in an animatronic glove).
Finally, calibration is mandatory. Manufacturing tolerances for carbon-ink flex sensors are notoriously wide, often ±30%. One 2.2" sensor might read 9kΩ flat, while another from the same batch reads 13kΩ. You must measure the specific flat resistance ($R_{flat}$) and bent resistance ($R_{bent}$) of your exact sensor with a multimeter and update the constants in your code before deployment. For a deeper dive into the physics of these voltage dividers, consult the All About Circuits Voltage Divider chapter.
Frequently Asked Questions
What are flex sensors used for in robotics and wearables?
Flex sensors are primarily used for relative gesture tracking rather than precise metrology. In wearables, they are sewn into smart gloves to detect finger curl for sign-language translation or VR hand tracking. In robotics, they serve as cheap bump sensors or compliance detectors on soft-robotic grippers, allowing the robot to detect when a flexible finger has wrapped around an object by measuring the change in resistance. They are also used in medical rehabilitation devices to measure the range of motion in human joints.
Are flex sensors digital or analog components?
Flex sensors are strictly analog, passive components. They contain no microchips, no I2C/SPI interfaces, and no internal ADCs. They are simply variable resistors. To interface them with a digital microcontroller, you must build an external analog voltage divider circuit and route the resulting analog voltage to the microcontroller's ADC pin. Any "digital flex sensor" module you find online is just a standard analog flex sensor pre-mounted on a PCB with a comparator chip (like an LM393) that outputs a basic HIGH/LOW trigger at a fixed threshold.
Why is my ESP32 flex sensor reading jumping around?
Jumping readings are almost always caused by EMI (electromagnetic interference) or a high-impedance floating node. Because the voltage divider outputs a high-impedance analog signal, nearby WiFi antennas, switching regulators, or even your hand waving near the wires can induce noise. First, ensure you are using an ADC1 pin (like GPIO36 or GPIO39) rather than an ADC2 pin, as ADC2 conflicts with the ESP32's WiFi radio. Second, add a 0.1µF ceramic capacitor between the ADC pin and GND. Third, implement a software moving-average filter to smooth out high-frequency spikes.
Can I use a flex sensor to measure bidirectional bending?
Standard commercial flex sensors (like the Spectra Symbol FLP series) are unidirectional. Bending them backward (against the printed side) will yield erratic resistance drops and will eventually crack the carbon substrate, destroying the sensor. If you need to measure bending in both directions (e.g., a joystick or a knee joint that bends both ways), you must glue two identical flex sensors back-to-back with a thin piece of flexible plastic in between. You then read both voltage dividers and calculate the difference between their two resistances to determine both the magnitude and the direction of the bend.






