A flex sensor (or bend sensor) is a flexible variable resistor that increases its electrical resistance as it is physically bent. It outputs a variable resistance—not a voltage or digital signal—requiring a voltage divider circuit to interface with a microcontroller's analog-to-digital converter (ADC). If you need to measure joint angles, trigger events when a surface curves, or build wearable input gloves, a flex sensor translates mechanical deformation into readable analog data.
The Sensing Principle: How Flex Sensors Work
At its core, a standard resistive flex sensor consists of a conductive carbon ink or polymer layer deposited on a flexible polyester substrate. When the sensor is perfectly flat, the conductive particles are tightly packed, maintaining a baseline resistance (typically 10kΩ). As you bend the substrate along its active axis, the physical distance between these conductive particles increases, restricting electron flow and driving the resistance higher.
This relationship is largely linear up to the sensor's rated maximum bend radius (usually 90°). At a full 90° bend, a standard 2.2-inch sensor will peak at roughly 35kΩ to 45kΩ. Because the sensor is purely passive, it has no polarity; you can wire it in either direction without damaging it, though it only measures unidirectional bending unless you specifically buy a bidirectional model.
Hardware Interfacing: Wiring and Voltage Divider Math
Because a microcontroller's ADC pins measure voltage (not resistance), you must place the flex sensor in a voltage divider circuit with a fixed pulldown resistor. The output voltage ($V_{out}$) is read by the MCU.
Wiring and Pinout Table
| Sensor Pin | Connection | Notes & Supply Range |
|---|---|---|
| Pin 1 | VCC (3.3V or 5V) | Supply range: 2.5V to 5.5V. Keep current low (<1mA) to prevent self-heating. |
| Pin 2 | MCU ADC Pin (e.g., A0) | Connects to the junction of the flex sensor and the pulldown resistor. |
| N/A (Junction) | 10kΩ Resistor to GND | Pulldown resistor completes the voltage divider to ground. |
Output Signal Math: Raw ADC to Degrees
Let's calculate the physical bend angle using a 5V Arduino Uno (10-bit ADC, 0-1023 range) and a standard 2.2" sensor (10kΩ flat, 35kΩ at 90°).
The voltage divider formula is:
V_out = V_in × (R_pulldown / (R_flex + R_pulldown))
- Flat (0°): R_flex = 10kΩ. V_out = 5V × (10 / 20) = 2.5V. ADC Reading ≈ 512.
- Bent (90°): R_flex = 35kΩ. V_out = 5V × (10 / 45) = 1.11V. ADC Reading ≈ 227.
Notice that bending the sensor decreases the voltage at the ADC pin because the sensor is on the high side of the divider. Here is the C++ code to map this raw reading to physical degrees:
// Flex Sensor Calibration Constants
const int ADC_FLAT = 512; // ADC reading at 0 degrees
const int ADC_BENT = 227; // ADC reading at 90 degrees
void setup() {
Serial.begin(115200);
}
void loop() {
int rawADC = analogRead(A0);
// Map the inversely proportional ADC value to 0-90 degrees
float angle = map(rawADC, ADC_FLAT, ADC_BENT, 0, 90);
// Clamp values to prevent negative or >90 noise readings
angle = constrain(angle, 0, 90);
Serial.print("Bend Angle: ");
Serial.print(angle);
Serial.println(" deg");
delay(50);
}
Calibration, Scaling, and Signal Conditioning
Out of the box, flex sensors suffer from manufacturing tolerances. Two sensors from the same batch might read 9.5kΩ and 11.2kΩ when perfectly flat. You must calibrate your ADC_FLAT and ADC_BENT constants in software for every individual sensor you deploy.
Furthermore, microcontroller ADCs—particularly the ESP32's 12-bit SAR ADC—exhibit non-linearity at the extreme top and bottom of their voltage rails. If you are using an ESP32, power the divider from 3.3V, use a 10kΩ pulldown, and restrict your usable ADC mapping range to roughly 100–3800 to avoid the non-linear dead zones at the rails (Espressif ADC Oneshot Documentation).
Common Interference Sources
Flex sensors are high-impedance devices. A 35kΩ sensor paired with a 10kΩ resistor creates a high-impedance node that acts like an antenna, picking up 50/60Hz mains hum and EMI from nearby motors or switching regulators.
- Hardware Fix: Solder a 0.1µF ceramic capacitor directly across the ADC input pin and GND. This creates a low-pass hardware filter that shorts high-frequency noise to ground.
- Software Fix: Implement a moving average filter or exponential smoothing in your code. Never trust a single
analogRead()from a high-impedance divider. - Mechanical Creep (Hysteresis): Carbon flex sensors exhibit "creep." If you hold a sensor at 90° for five minutes, the resistance will slowly drift upward. When released, it will not immediately return to 10kΩ. Software must include a deadband or auto-zeroing routine if absolute positional accuracy is required over long periods.
Decision Tree: Which Flex Sensor Should You Buy?
Do not waste time guessing which form factor fits your mechanical constraints. Use this decision matrix to select the exact part number for your workbench.
| Your Application Constraint | Required Sensor Type | Concrete Part Recommendation |
|---|---|---|
| Standard unidirectional bending (0° to 90°), wearable gloves, robotic finger joints. | 2.2" Unidirectional Carbon Resistive (10k-35kΩ) | SparkFun SEN-08606 (or Adafruit ID 182) |
| Measuring deflection in both directions (e.g., a cantilever beam vibrating up and down). | Bidirectional Flex Sensor | Spectra Symbol SSP-104 |
| Wrapping entirely around a cylinder or measuring >90° continuous curvature. | Conductive Rubber Stretch Cord (Not a flex sensor) | Adafruit Stretch Sensor (ID 519) |
| High-cycle medical or industrial use requiring millions of bends without drift. | Capacitive or Optical Bend Sensor | Flexpoint Custom Capacitive (Enterprise pricing) |
Handling and Failure Modes to Avoid
Flex sensors are surprisingly fragile if mishandled. The conductive carbon layer is encased in a thin polymer, but the crimped metal contacts at the base (the "tail") are the primary point of failure.
- Creasing the Tail: Never bend the sensor within 3mm of the crimped contacts. Bending at the base will snap the internal metal crimp, resulting in an open circuit (infinite resistance). Always clamp the rigid tail in a connector or hot-glue it to a rigid backer.
- Moisture Ingress: Standard carbon flex sensors are not IP-rated. The salts and moisture from human sweat will degrade the carbon traces and cause erratic resistance spikes. If building a wearable glove, coat the active area in a thin layer of liquid electrical tape or conformal silicone, leaving only the contact pads exposed.
- Over-voltage Self-Heating: Because the sensor is essentially a resistor, passing too much current through it will cause it to heat up (I²R losses), which alters the resistance and ruins your calibration. Keep the supply voltage at or below 5V and use a pulldown resistor of at least 10kΩ to limit current to <0.5mA.
By treating the flex sensor as a high-impedance analog component rather than a plug-and-play digital module, filtering the ADC node with a capacitor, and mapping the specific voltage drop to your mechanical limits, you will achieve smooth, repeatable bend measurements on your first hardware revision.






