When makers and engineers search for the flex sensor meaning, they are looking for the functional definition of a passive, variable resistor whose electrical resistance increases proportionally as the sensor substrate is bent or deflected. Unlike active digital modules that output pre-calculated angles over I2C, a raw flex sensor (like the industry-standard Spectra Symbol 2.2" FS-A105 or 4.5" FS-A201) is purely analog. It outputs a changing resistance, which your microcontroller must convert to a voltage, digitize via an Analog-to-Digital Converter (ADC), and scale into a physical angle using mathematical calibration.
The Sensing Principle: How Flex Sensors Actually Work
A flex sensor is constructed by printing a proprietary conductive polymer ink onto a flexible, durable polyester substrate. When the sensor is laid flat, the carbon and polymer particles within the ink matrix are tightly packed, creating a low-resistance path for electrical current. As you bend the sensor, the outer radius of the substrate stretches. This physical stretching forces the conductive particles further apart, microscopically fracturing some of the conductive pathways and forcing the current to take longer, more resistive routes through the remaining matrix.
Electrically, this translates to a predictable resistance curve. A standard 2.2-inch sensor sits at a baseline resistance of roughly 25kΩ (±30%) when completely flat (0°). When bent to a 90° angle, the resistance climbs to approximately 125kΩ. Because it is a strictly passive, two-terminal component, it has no internal microcontroller, no digital output, and no polarity—you can wire it in either direction. It relies entirely on your external circuit to translate this resistance shift into a readable signal.
Wiring, Pinout, and Voltage Divider Math
Because microcontrollers like the Arduino Uno or ESP32 cannot read resistance directly, you must convert the resistance change into a voltage change. We do this using a voltage divider circuit. You place the flex sensor in series with a fixed pull-down resistor. The output voltage is measured at the junction between the two components.
For a 3.3V system like the ESP32, a 22kΩ or 47kΩ pull-down resistor is ideal. This keeps the midpoint voltage within the ESP32's most linear ADC range (0.1V to 2.5V) across the sensor's entire bending spectrum. Using a 10kΩ resistor will push the bent voltage too close to the 3.3V rail, where ESP32 ADCs suffer from severe non-linearity.
Wiring and Pinout Table
| Sensor / Component | Pin / Terminal | Connects To | Supply Range / Notes |
|---|---|---|---|
| Flex Sensor | Terminal 1 | VCC (3.3V or 5V) | Max 5V. No polarity. |
| Flex Sensor | Terminal 2 | ADC Pin & Pull-down Resistor | Analog output junction. |
| Pull-down Resistor | Lead 1 | ADC Pin & Flex Sensor Terminal 2 | 22kΩ to 47kΩ (1% metal film). |
| Pull-down Resistor | Lead 2 | GND | System ground. |
| Bypass Capacitor | Across ADC & GND | ADC Pin to GND | 100nF ceramic (filters noise). |
Output Signal Math: Raw ADC to Physical Angle
The output of this circuit is an analog voltage. To get from a raw ADC reading to a physical bend angle, you must chain three mathematical steps. Here is the exact math for a 12-bit ADC (like on an ESP32) reading a 3.3V system with a $R_{pull}$ of 22,000Ω:
- Raw to Voltage: $V_{out} = \text{ADC\_raw} \times \left(\frac{3.3}{4095}\right)$
(Note: UseanalogReadMilliVolts()on ESP32 to bypass raw ADC non-linearity). - Voltage to Resistance: $R_{flex} = R_{pull} \times \left(\frac{V_{cc}}{V_{out}} - 1\right)$
- Resistance to Angle: Assuming a linear mapping between 0° (25kΩ) and 90° (125kΩ), the angle is:
$\text{Angle} = \left( \frac{R_{flex} - 25000}{125000 - 25000} \right) \times 90$
Here is how that math looks in practical, compilable ESP32 C++ code:
const int FLEX_PIN = 34; // ADC1 pin on ESP32
const float VCC = 3.3;
const float R_PULL = 22000.0; // 22k pull-down resistor
const float R_FLAT = 25000.0; // Resistance at 0 degrees
const float R_BENT = 125000.0; // Resistance at 90 degrees
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution
}
void loop() {
// Read voltage directly in millivolts to avoid ESP32 raw ADC non-linearity
int mV = analogReadMilliVolts(FLEX_PIN);
float vOut = mV / 1000.0;
// Prevent division by zero if sensor is disconnected
if (vOut <= 0.05) {
Serial.println("Error: Check wiring, voltage near 0.");
delay(1000);
return;
}
// Calculate Flex Resistance
float rFlex = R_PULL * ((VCC / vOut) - 1.0);
// Map to Angle (constrain to prevent negative angles)
float angle = ((rFlex - R_FLAT) / (R_BENT - R_FLAT)) * 90.0;
angle = constrain(angle, 0.0, 90.0);
Serial.printf("V: %.2fV | R: %.0f ohms | Angle: %.1f deg\n", vOut, rFlex, angle);
delay(100);
}
Calibration, Scaling, and Interference
If you build the circuit above and test it, you will quickly notice the numbers drift. Calibration and scaling are strictly required for flex sensors because manufacturing tolerances are wide. A datasheet might state a flat resistance of 25kΩ, but your specific unit might measure 18kΩ flat and 90kΩ at 90°. To fix this, write a calibration routine that records the ADC value when the sensor is physically clamped at 0°, and again when clamped at 90°. Use the map() function or a linear interpolation formula between those two exact empirical data points rather than relying on datasheet nominal values.
Common interference sources will also ruin your readings if ignored. Because the voltage divider outputs a high-impedance analog signal, it acts like an antenna for 50/60Hz electromagnetic interference from nearby AC mains wiring. Furthermore, mechanical "creep" (hysteresis) means the sensor's resistance won't immediately return to baseline when you release the bend; it takes 100-300ms to relax. To combat electrical noise, keep the wires between the sensor and the microcontroller under 12 inches, use twisted-pair wire, and solder a 100nF ceramic bypass capacitor directly across the ADC pin and GND at the microcontroller header.
Frequently Asked Questions
What is the practical meaning of flex sensor hysteresis in a circuit?
In the context of flex sensors, hysteresis means the electrical resistance on the return stroke (unbending) does not perfectly match the resistance on the forward stroke (bending). When you bend the sensor to 45° and hold it, it might read 60kΩ. When you bend it to 90° and release it back to 45°, it might temporarily read 65kΩ before slowly relaxing back to 60kΩ over a few hundred milliseconds. Practically, this means you cannot use raw flex sensors for high-speed, high-precision closed-loop feedback (like balancing a robot). You must implement software low-pass filtering or physical return springs in your mechanical design to force the sensor back to a known baseline.
Does the flex sensor meaning change when using bidirectional (2-way) bending?
Yes, the physical and electrical meaning shifts significantly. Standard flex sensors are designed for unidirectional (1-way) bending. The conductive polymer ink is printed on one side of the substrate. If you bend it backward, the substrate compresses rather than stretches, which can cause the conductive layer to buckle, delaminate, or permanently crack. While some specialized bidirectional sensors exist, using a standard 1-way sensor in a 2-way hinge will result in erratic resistance drops, permanent mechanical damage, and a drastically shortened lifespan. Always design your mechanical housing with a physical hard-stop to prevent reverse bending.
What does flex sensor tolerance mean for production Arduino builds?
Tolerance refers to the batch-to-batch variance in baseline resistance. Manufacturer datasheets often specify a flat resistance tolerance of ±30%. If you are building a single DIY Arduino project, you simply calibrate it once in your code. However, if you are manufacturing 500 units of a wearable device, you cannot hardcode the 25kΩ flat resistance into your firmware. You must either design a hardware trimmer potentiometer into the voltage divider, or include a "calibration mode" in your firmware that prompts the end-user to press a button while the device is laid flat, allowing the microcontroller to measure and store the exact baseline resistance in EEPROM for that specific unit.






