The Sensing Principle and Output Signal
A resistive displacement sensor (often called a linear potentiometer, slide pot, or potentiometric transducer) operates on a straightforward voltage divider principle. Inside the sensor housing, a conductive wiper slides along a uniform resistive track—typically made of carbon composition, cermet, or conductive plastic. As the mechanical shaft or slider moves, the wiper changes the ratio of resistance between the output pin and the supply/ground pins, translating physical linear travel into a proportional electrical resistance.
The output signal is strictly an analog voltage, not a digital bus protocol (like I2C or SPI) or a 4-20mA current loop. By exciting the sensor with a stable DC reference voltage (VCC) across the outer track terminals, the wiper pin outputs a ratiometric DC voltage between 0V and VCC. Because the output is ratiometric, any fluctuation in your excitation voltage directly skews your position reading, making a clean, regulated power supply mandatory for precision work.
Wiring, Pinout, and Hardware Specs
Whether you are using a hobbyist Bourns PTA6043 slide pot ($3-$5) or an industrial Novotechnik TLM series transducer ($150+), the 3-wire interface remains identical. Below is the standard wiring matrix for interfacing with a 3.3V microcontroller like the ESP32-WROOM-32 or Arduino Nano 33 IoT.
| Sensor Pin | Function | ESP32 / 3.3V MCU Connection | Notes & Supply Range |
|---|---|---|---|
| 1 (or CCW) | Ground / Low Reference | GND | Shared ground with MCU is critical to prevent ground loops. |
| 2 (or Wiper) | Analog Output | GPIO 34 (ADC1_CH6) | Use ADC1 pins on ESP32; ADC2 conflicts with WiFi. |
| 3 (or CW) | VCC / High Reference | 3.3V (or 5V via divider) | Max supply varies (5V for carbon, up to 30V for industrial cermet). Always match or step down to MCU ADC max voltage. |
Raw ADC to Millimeter Math (The Conversion)
To convert the microcontroller's raw integer reading into a meaningful physical unit (millimeters or inches), you must map the ADC resolution to the sensor's physical stroke length. For a 12-bit ADC (like the ESP32), the raw reading ranges from 0 to 4095.
The theoretical formula is:
Displacement = (Raw_ADC / 4095) * Total_Stroke_Length
However, real-world sensors suffer from mechanical deadbands at the ends of the track and minor resistance tolerances (typically ±0.5% to ±1% linearity). Therefore, a two-point calibration is required to find the actual slope (m) and y-intercept (b) of your specific hardware.
- Zero Point: Push the sensor to its minimum physical position. Record the raw ADC average (e.g., 120).
- Max Point: Push the sensor to its maximum physical position. Record the raw ADC average (e.g., 3980).
- Calculate Scale: If the physical travel between these two points is exactly 100mm, your scale factor is
100 / (3980 - 120) = 0.0259 mm per ADC step.
Here is the complete, copy-pasteable C++ implementation for Arduino/ESP32 environments, including the calibration math:
const int SENSOR_PIN = 34;
const int MIN_ADC = 120; // Calibrated zero-point ADC value
const int MAX_ADC = 3980; // Calibrated max-point ADC value
const float STROKE_MM = 100.0; // Physical travel distance in mm
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Set ESP32 to 12-bit (0-4095)
}
void loop() {
int raw = analogRead(SENSOR_PIN);
// Constrain to calibrated bounds to prevent negative/over-travel math errors
raw = constrain(raw, MIN_ADC, MAX_ADC);
// Map raw ADC to millimeters using float math
float displacement_mm = ((float)(raw - MIN_ADC) / (MAX_ADC - MIN_ADC)) * STROKE_MM;
Serial.print("Raw: ");
Serial.print(raw);
Serial.print(" | Displacement: ");
Serial.print(displacement_mm, 2);
Serial.println(" mm");
delay(50);
}
Noise, Interference, and Signal Conditioning
Resistive sensors are high-impedance analog devices, making them highly susceptible to environmental interference. If your serial monitor shows the displacement value jumping by 2-5mm while the shaft is stationary, you are experiencing noise. According to SparkFun's voltage divider guidelines, high-impedance outputs must be conditioned before hitting a microcontroller's sample-and-hold capacitor.
- Wiper Contact Noise (Jitter): As the wiper moves across the carbon or plastic track, microscopic variations cause momentary resistance spikes. Fix: Implement a software Exponential Moving Average (EMA) filter, or apply a physical 100nF ceramic capacitor between the Wiper pin and GND to form a low-pass filter.
- Electromagnetic Interference (EMI): Long, unshielded cables act as antennas, picking up 50/60Hz hum from nearby mains wiring or switching noise from stepper motors. Fix: Use shielded twisted-pair (STP) cable for runs over 1 meter, and tie the shield to GND at the microcontroller end only.
- Supply Voltage Ripple: Because the output is ratiometric, a 50mV ripple on your 3.3V VCC line will inject a proportional ripple directly into your position reading. Fix: Power the sensor from a dedicated low-dropout (LDO) regulator rather than the microcontroller's noisy internal 3.3V bus.
Frequently Asked Questions
How do I calibrate a resistive displacement sensor for accurate millimeter readings?
Calibration requires a two-point physical measurement. Mount the sensor securely and use a digital caliper or dial indicator to measure the exact physical distance between the minimum and maximum travel stops. Read the raw ADC values at both stops using your microcontroller. Plug these two ADC values and the physical distance into the linear equation y = mx + b (or use the constrain() and map() logic shown in the code block above). Never rely on the manufacturer's stated electrical travel, as it often includes a 5-10% mechanical deadband at each end that is non-linear.
Why is my resistive displacement sensor output jittering or noisy?
Jitter is usually caused by one of three things: a dirty/worn internal resistive track, high-impedance ADC sampling errors, or EMI on the signal wire. First, add a 0.1µF (100nF) ceramic capacitor directly across the Wiper and GND pins at the sensor housing to filter high-frequency contact noise. Second, ensure you are reading from an ADC1 pin on the ESP32, as ADC2 pins share hardware with the WiFi radio and will show massive spikes during network transmissions. For industrial environments, consult Espressif's official ADC calibration documentation to apply the manufacturer's eFuse calibration offsets in firmware.
Resistive displacement sensor vs inductive linear transducer: which should I choose?
Choose a resistive displacement sensor when your budget is under $20, you need absolute position on startup (no homing sequence required), and your environment is relatively clean and dry. Choose an inductive or magnetostrictive transducer (like an MTS Temposonics) when you need sub-micron resolution, the sensor will be exposed to heavy vibration, dirt, or moisture (IP67+), and you have a budget of $300+. Inductive sensors are non-contact and immune to wiper wear, making them mandatory for high-cycle industrial machinery, whereas resistive pots will eventually wear out after 100,000 to 1,000,000 cycles.
Can I wire multiple resistive displacement sensors to a single microcontroller?
Yes, but you must manage current draw and ADC crosstalk. Each sensor acts as a resistor across VCC and GND. A 10kΩ sensor draws 0.33mA at 3.3V, so wiring ten of them only adds 3.3mA to your power budget—well within limits. However, when reading multiple analog pins in rapid succession, the microcontroller's internal sample-and-hold capacitor may not fully charge/discharge between reads, causing "crosstalk" (where reading Pin A slightly alters the value of Pin B). To fix this, read each pin twice in your code and discard the first reading, or insert a 50-microsecond delayMicroseconds(50) between different pin reads to allow the ADC multiplexer to settle.






