The Sensing Principle: How Linear Sensors Convert Motion to Voltage

Linear sensors translate physical displacement along a single axis into a proportional electrical signal. In embedded microcontroller projects, this typically means choosing between a linear Hall effect sensor (like the TI DRV5055), which measures the magnetic flux density of a moving magnet, or a linear potentiometer (slide pot), which uses a physical wiper moving across a resistive carbon track to create a variable voltage divider. Unlike digital Hall switches that only snap HIGH or LOW, linear sensors provide a continuous, ratiometric analog voltage that scales infinitely within their physical travel limits.

For a 3.3V-supplied linear Hall sensor, the quiescent (zero-magnet) output sits at exactly 1.65V, swinging toward 0V or 3.3V as the magnetic pole approaches or retreats. A slide pot simply outputs 0V to 3.3V depending on the wiper's physical ratio along the track. The core difference is contact: Hall sensors are non-contact and immune to mechanical wear, while pots offer absolute position tracking without needing to manage separate magnetic fields.

Wiring and Pinout: Linear Hall vs Slide Potentiometer

When wiring linear sensors to an ESP32, you must respect the microcontroller's 3.3V logic and ADC limits. Feeding a 5V sensor directly into an ESP32 GPIO will permanently damage the silicon. Below is the specification and wiring table for the two most reliable 3.3V-native linear sensors on the market in 2026.

Parameter TI DRV5055 (Linear Hall) Bourns PTA6043 (10k Slide Pot)
Supply Range 2.5V to 5.5V (Use 3.3V) Passive (Excite with 3.3V)
Quiescent Output 1.65V (at 0 mT) 0V to 3.3V (depends on wiper)
Output Type Ratiometric Analog Voltage Ratiometric Analog Voltage
Max Physical Travel ~15mm (limited by magnet field) 60mm (standard PTA6043 track)
ESP32 Pin Mapping VCC=3V3, GND=GND, OUT=GPIO34 Pin1=3V3, Pin3=GND, Wiper=GPIO35
Callout Tip: ESP32 ADC Pin Selection
Never wire analog linear sensors to GPIOs 0, 2, 4, or 12-15 on the original ESP32. These pins are tied to the ADC1 channel or have internal pull-ups that will skew your analog readings. Always use ADC1 channels on GPIO 32, 33, 34, 35, 36, or 39 for clean linear sensor data.

Output Signal Math: Converting Raw ADC to Millimeters

The raw output of any linear sensor is an analog voltage, which the ESP32's 12-bit Successive Approximation Register (SAR) ADC converts into a digital integer between 0 and 4095. However, the ESP32's internal ADC is notoriously non-linear at the voltage rails (below 0.1V and above 3.1V). To get accurate physical units, you must restrict your sensor's physical travel to the ADC's linear sweet spot and apply the correct scaling math.

Slide Potentiometer: Raw to Millimeters

For a Bourns 60mm slide pot, the voltage is perfectly proportional to the wiper position. Assuming you keep the signal between 0.1V and 3.1V to avoid ESP32 ADC saturation, the math is a direct linear interpolation.

  • Ideal Voltage: V_out = 3.3 * (Distance_mm / 60)
  • Raw ADC to Distance: Distance_mm = (ADC_Raw / 4095.0) * 60.0
  • ESP32 Calibrated Math: Because the ESP32 ADC reads ~150 at 0.1V and ~3800 at 3.1V, use this corrected formula for the linear zone:
    Distance_mm = ((ADC_Raw - 150.0) / 3650.0) * 54.5 + 2.7

Linear Hall Effect: Raw to Magnetic Flux (and Distance)

The TI DRV5055A1 has a sensitivity of 63 mV/mT. The output voltage shifts from the 1.65V quiescent point based on the magnetic field strength (B) in milliTesla (mT).

  • Voltage Calculation: V_out = 1.65 + (0.063 * B_mT)
  • Raw ADC to mT: B_mT = (((ADC_Raw / 4095.0) * 3.3) - 1.65) / 0.063

The Distance Problem: Magnetic field strength follows an inverse-cube law relative to distance from a dipole magnet. You cannot use a simple linear multiplier to convert mT to millimeters. Instead, you must perform a 2-point empirical calibration. Mount the magnet, read the ADC at your minimum desired distance (e.g., 2mm), and read it at your maximum distance (e.g., 12mm). Use the standard line equation y = mx + c to map the raw ADC values directly to millimeters in your C++ code.

Interference, Noise, and Calibration Realities

Understanding what the output actually is—a high-impedance ratiometric analog voltage—reveals why linear sensors are susceptible to specific environmental interference. If your serial monitor is spitting out jittery numbers, it is rarely the sensor's fault; it is almost always the environment or the microcontroller's ADC.

Common Interference Sources

  • Hall Sensors (Magnetic Crosstalk & Temp Drift): Stray magnetic fields from nearby stepper motors, relays, or speakers will instantly skew a linear Hall sensor. Furthermore, Neodymium (NdFeB) magnets have a reversible temperature coefficient of roughly -0.12%/°C. If your sensor is mounted near a hot motor and the ambient temperature rises from 20°C to 60°C, the magnet loses ~4.8% of its flux density, causing the sensor to read a false "further away" position.
  • Slide Pots (Wiper Noise & Vibration): Carbon track potentiometers suffer from contact resistance variations. As the wiper moves, microscopic scratches in the carbon cause "scratchy" voltage spikes. If the assembly is subjected to high-frequency mechanical vibration, the wiper can micro-bounce off the track, causing the ADC to momentarily read floating garbage values.
  • ESP32 ADC Noise: The ESP32's internal ADC generates its own switching noise. Reading a stable 1.65V signal might yield raw values bouncing between 2010 and 2060.
Fixing the Noise: Hardware vs Software
For slide pots, wire a 0.1µF ceramic capacitor directly between the wiper pin and GND at the breadboard to filter high-frequency wiper bounce. For Hall sensors, if you need sub-millimeter precision, bypass the ESP32's internal ADC entirely and use an external 16-bit I2C ADC like the ADS1115, which offers programmable gain and built-in digital filtering.

Decision Path: Which Linear Sensor Should You Actually Buy?

Do not default to a slide pot just because it is cheaper, and do not default to a Hall sensor just because it is non-contact. Use this decision matrix to select the correct linear sensor for your specific embedded project constraints.

Project Constraint If True... Choose This Technology
Environment is wet, dusty, or oily Yes Linear Hall Effect (Sealed, non-contact)
Required travel distance is > 60mm Yes Slide Potentiometer (or String Pot)
Subjected to high mechanical vibration Yes Linear Hall Effect (No wiper bounce)
Need absolute position on boot without homing Yes Both work, but Slide Pot is easier to scale
Strict BOM budget (under $1.50 per unit) Yes Slide Potentiometer

The Final Verdict: Concrete Part Picks for 2026

If you are building a short-travel (under 15mm) suspension telemetry, brake pedal, or throttle position sensor for an ESP32 where vibration and dirt are factors, buy the TI DRV5055A1QDBZR (the 3.3V-optimized variant) paired with a 4x2x2mm N52 NdFeB magnet. It will outlast any mechanical pot and natively match the ESP32's logic levels without voltage dividers.

If you are building a motorized fader, a long-travel valve position tracker, or a DIY flight simulator throttle quadrant requiring 60mm to 100mm of travel, buy the Bourns PTA6043-2015DPB103 (60mm, 10k linear taper). Add the 0.1µF hardware filter capacitor on the wiper, restrict your software mapping to the 0.2V–3.0V ADC sweet spot, and you will achieve reliable, repeatable linear tracking.