If you need non-contact linear position sensing for an actuator, valve, or suspension setup, use the Texas Instruments DRV5055A1 analog Hall effect position sensor. It outputs a ratiometric analog voltage, survives over 100 million mechanical cycles without contact wear, and costs roughly $1.20 in single quantities. Unlike physical potentiometers that suffer from wiper noise and dead spots, this sensor translates magnetic flux density directly into physical displacement.
The Sensing Principle: How Hall Effect Position Sensors Work
When a magnetic field passes perpendicular to a biased semiconductor die, the Lorentz force deflects moving charge carriers to one side of the material. This accumulation of charge creates a measurable transverse voltage—the Hall effect. In linear Hall sensors like the DRV5055, internal chopper-stabilized amplifiers boost this microvolt-level signal into a clean, usable analog voltage that scales proportionally with the magnetic field strength.
Because the sensor relies entirely on magnetic flux rather than physical contact, it offers infinite mechanical life and sub-millimeter resolution. By mounting a small neodymium magnet to a moving shaft and fixing the sensor to the stationary housing, the changing distance between the magnet and the die alters the flux density, allowing you to track linear or rotary displacement with zero friction and zero contact bounce.
Wiring the DRV5055 to an ESP32 (Pinout & Supply)
The DRV5055 is a 3-pin analog device. It is strictly an analog output sensor; do not confuse it with digital Hall switches (like the A3144) which only output a binary HIGH/LOW. Below is the exact wiring specification for interfacing it with an ESP32 DevKit v1.
| Sensor Pin | Function | Supply Range | ESP32 Connection | Notes |
|---|---|---|---|---|
| 1 (VCC) | Power Supply | 2.5V to 5.5V | 3V3 Pin | Must be clean; use a 100nF decoupling cap to GND. |
| 2 (GND) | Ground | N/A | GND Pin | Shared ground with ESP32 and magnet actuator. |
| 3 (OUT) | Analog Output | 0.1V to VCC | GPIO 34 (ADC1_CH6) | Use ADC1 pins only; ADC2 conflicts with WiFi. |
Output Signal Math: Converting Raw ADC to Millimeters
The output of the DRV5055A1 is a ratiometric analog voltage. At 0mT (no magnetic field), the output sits at exactly 50% of VCC. As a north-pole magnetic field increases, the voltage rises toward VCC; as a south-pole field increases, it drops toward 0V. The Texas Instruments DRV5055 Datasheet specifies the A1 variant has a sensitivity of 31.25 mV/mT.
To convert the ESP32's raw 12-bit ADC reading (0-4095) into physical millimeters, you must pass through three mathematical stages: Voltage conversion, Magnetic Field (mT) extraction, and Flux Gradient scaling.
Step 1: Raw ADC to Voltage
Assuming a 3.3V reference and a 12-bit resolution:
Voltage = (ADC_Raw / 4095.0) * 3.3
Step 2: Voltage to Magnetic Field (mT)
Subtract the quiescent offset (50% of VCC, which is 1.65V) and divide by the sensitivity (0.03125 V/mT):
Delta_V = Voltage - 1.65
Magnetic_Field_mT = Delta_V / 0.03125
Step 3: Magnetic Field to Physical Position (mm)
This is where the physical geometry of your magnet matters. A standard 6mm x 2.5mm N52 cylinder magnet moving axially away from the sensor face produces a flux gradient of roughly 10 mT per millimeter of travel in the 2mm to 10mm range. You must divide the magnetic field by your specific magnet's gradient:
Position_mm = Magnetic_Field_mT / 10.0
Interference, Drift, and Calibration Realities
Position sensors do not operate in a vacuum. When integrating the DRV5055 into a motorized actuator or robotic joint, you will encounter three primary interference sources that degrade your physical unit math:
- Stray Magnetic Fields: Stepper motors, brushless DC motors, and high-current DC traces generate localized magnetic fields. If your sensor wiring runs parallel to a 5A motor phase wire, the induced field will shift your zero-offset. Fix: Use twisted-pair wiring for the sensor output and maintain a 15mm minimum clearance from stator housings.
- ESP32 ADC Non-Linearity: The ESP32's internal ADC is notoriously non-linear at the extremes (below 0.15V and above 3.1V) and suffers from a 0.2V deadzone on some pins. Fix: Never rely on the raw
analogRead()for precision. Use the Espressif ESP32 ADC Oneshot Driver with theesp_adc_callibrary to apply factory-stored eFuse calibration values, or read the sensor output via an external ADS1115 16-bit I2C ADC. - Temperature Coefficient: The neodymium magnet's flux density drops by roughly -0.12% per °C as it heats up, and the sensor's internal sensitivity drifts slightly. Fix: If your actuator operates in an environment with >20°C temperature swings, mount a digital temperature sensor (like a TMP36 or BME280) next to the Hall sensor and apply a software temperature-compensation multiplier to your position reading.
Decision Tree: Which Position Sensor Should You Actually Buy?
Makers and engineers often default to whatever sensor is cheapest on Amazon, leading to premature mechanical failure or noisy data. Use this decision matrix to select the correct position sensor for your specific mechanical constraint.
| Mechanical Requirement | Environment / Lifecycle | Recommended Sensor Type | Exact Part Number |
|---|---|---|---|
| Rotary Absolute (0-360°) | Indoor, < 50 RPM, I2C bus available | Magnetic Rotary Encoder | AMS AS5600 |
| Linear (0-50mm travel) | Clean indoor, low budget, < 10k cycles | Linear Slide Potentiometer | Bourns 3852A Series |
| Linear (0-20mm travel) | Dirty/Wet, high vibration, > 1M cycles | Analog Hall Effect (Linear) | TI DRV5055A1 (Default Pick) |
| Linear (>100mm travel) | Industrial, high precision (< 0.05mm) | Magnetostrictive / LVDT | Temposonics R-Series (Out of hobbyist budget) |
The Final Verdict
If you are building a linear actuator, a motorized ball valve, or an active suspension linkage that requires continuous, high-cycle feedback without physical contact wear, buy the TI DRV5055A1. Pair it with a 6x2.5mm N52 neodymium magnet, decouple the VCC pin with a 100nF capacitor, route the analog output to an ESP32 ADC1 pin, and use the esp_adc_cal library to linearize the raw readings. For rotary applications under 360 degrees, pivot to the AS5600 I2C encoder, but for all robust linear tracking tasks, the DRV5055 remains the undisputed bench standard.






