A linear hall effect sensor outputs a continuous, ratiometric analog voltage that scales proportionally with magnetic flux density. Unlike digital Hall switches (which snap HIGH or LOW at a fixed Gauss threshold to act as simple proximity toggles), linear sensors provide the exact field strength, making them ideal for measuring continuous physical variables like joystick position, fluid level, or DC current flow.

For 3.3V microcontrollers like the ESP32, the Texas Instruments DRV5055 is the benchmark part. It operates natively at 3.3V, eliminating the need for voltage dividers required by older 5V parts like the SS49E. Below is the complete workbench guide to wiring, scaling the raw ADC data into milliTesla (mT), and filtering out the noise that ruins magnetic measurements.

The Physics: How Linear Hall Sensing Works

When a bias current flows through a semiconductor element inside the sensor IC and a magnetic field is applied perpendicular to that current, the Lorentz force deflects the charge carriers to one side of the material. This accumulation of charge creates a transverse potential difference known as the Hall voltage. Because the raw Hall voltage is typically in the microvolt range, it is entirely useless for direct microcontroller interfacing.

To solve this, a linear hall effect sensor integrates an on-chip differential amplifier and a voltage regulator. The amplifier boosts the microvolt Hall signal into a usable ratiometric analog output. "Ratiometric" means the output voltage scales relative to the supply voltage (VCC); if VCC drops by 5%, the sensitivity and quiescent output drop by exactly 5%, which allows the microcontroller to cancel out supply noise if measured correctly.

Component Selection and Hardware Wiring

Choosing the right sensor depends on your supply voltage and required sensitivity. Older hobbyist kits frequently include the Honeywell SS49E or Allegro A1302, but these are 5V devices. Feeding 5V into an ESP32 GPIO will destroy the pin. If you must use a 5V sensor, you need a precision voltage divider or an op-amp level shifter. For new builds, native 3.3V parts are mandatory.

Table 1: Linear Hall Effect Sensor Specifications (2026 Standard Hobbyist/Prosumer Parts)
Part Number Supply Range (VCC) Sensitivity Quiescent Output (0 mT) Output Type
TI DRV5055A1 2.5V to 5.5V 60 mV/mT VCC / 2 (Ratiometric) Analog (Push-pull)
TI DRV5055A3 2.5V to 5.5V 120 mV/mT VCC / 2 (Ratiometric) Analog (Push-pull)
Honeywell SS49E 4.5V to 10.5V 1.4 mV/Gauss (14 mV/mT) VCC / 2 (Ratiometric) Analog (Push-pull)
Allegro A1302 4.5V to 5.5V 1.3 mV/Gauss (13 mV/mT) VCC / 2 (Ratiometric) Analog (Push-pull)
Melexis MLX90242 4.5V to 16V Programmable Programmable Analog
⚠️ Safety Callout: Current Sensing on Mains
If you are using a linear hall effect sensor to measure AC/DC current by clamping it near a busbar or wire, ensure the sensor and its wiring are physically isolated from the high-voltage conductor. A loose wire or sensor package fracture can bridge mains voltage directly to your low-voltage microcontroller, creating a lethal shock hazard and destroying your PC via USB ground loops.

ESP32 to DRV5055 Wiring Pinout

The ESP32 has two ADC units. ADC2 is shared with the WiFi radio and becomes unusable when WiFi is active. Always route analog sensors to ADC1 (GPIOs 32-39).

Table 2: Wiring the DRV5055 to ESP32 DevKit V1
DRV5055 Pin ESP32 Pin Wire Color (Std) Notes
1 (VCC) 3V3 Red Must be clean; add 100nF decoupling cap at sensor pins.
2 (GND) GND Black Keep ground return path short to avoid EMI.
3 (OUT) GPIO 34 (ADC1_CH6) Yellow/Green Input only pin. Do not use internal pull-up/down.

The Math: Converting Raw ADC to MilliTesla

The most common mistake makers make with the ESP32 is using the standard analogRead() function and multiplying by 3.3 / 4095. The ESP32's internal ADC is notoriously non-linear, particularly at the extremes (near 0V and 3.3V), and suffers from factory offset variations. To get accurate physical units from a linear hall effect sensor, you must use the ESP32's calibrated millivolt reading API.

The Conversion Formula

For the DRV5055A1 (60 mV/mT sensitivity) powered at exactly 3.3V:

  1. Quiescent Voltage (Vq): At 0 mT (no magnetic field), the output sits at VCC / 2 = 1.65V (1650 mV).
  2. Delta Voltage: Subtract the quiescent voltage from the measured voltage.
    delta_mV = measured_mV - 1650
  3. Flux Density (mT): Divide the delta voltage by the sensor sensitivity.
    mT = delta_mV / 60.0

Because the sensor is ratiometric, if your 3.3V rail actually measures 3.25V, the quiescent voltage is 1625 mV, and the sensitivity scales down proportionally. For high-precision bench work, measure your actual VCC with a multimeter and hardcode that value into your firmware rather than assuming 3.3V.

Complete ESP32 Arduino Code

#include <driver/adc.h>
#include <esp_adc_cal.h>

// Hardware definitions
#define HALL_SENSOR_PIN 34      // ADC1_CH6
#define VCC_MILLIVOLTS 3300     // Measure with DMM and update this exact value
#define QUIESCENT_MV (VCC_MILLIVOLTS / 2)
#define SENSITIVITY_MV_PER_MT 60.0  // DRV5055A1

// ESP32 ADC Calibration handle
esp_adc_cal_characteristics_t adc_chars;

void setup() {
  Serial.begin(115200);
  
  // Configure ADC1 for 12-bit resolution (0-4095)
  analogReadResolution(12);
  
  // Characterize ADC at 11dB attenuation (full scale ~3.3V)
  esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 1100, &adc_chars);
  
  Serial.println("Linear Hall Sensor Initialized. Calibrating zero-field offset...");
  delay(500); // Let the sensor settle
}

void loop() {
  // Read raw ADC and convert to calibrated millivolts
  uint32_t raw_adc = analogRead(HALL_SENSOR_PIN);
  uint32_t voltage_mv = esp_adc_cal_raw_to_voltage(raw_adc, &adc_chars);
  
  // Calculate magnetic flux density in milliTesla (mT)
  int32_t delta_mv = (int32_t)voltage_mv - QUIESCENT_MV;
  float flux_mT = (float)delta_mv / SENSITIVITY_MV_PER_MT;
  
  // Convert mT to Gauss (1 mT = 10 Gauss) for legacy compatibility
  float flux_gauss = flux_mT * 10.0;
  
  Serial.printf("Raw: %u | mV: %u | Flux: %+.2f mT (%+.1f G)\n", 
                raw_adc, voltage_mv, flux_mT, flux_gauss);
                
  delay(100);
}

Calibration, Scaling, and Interference Mitigation

Even with calibrated ADC math, real-world magnetic environments are messy. If your serial monitor shows the flux density jittering by ±2 mT while the sensor is sitting still on your desk, you are dealing with interference. Here is how to isolate the signal.

1. Zero-Field Offset Calibration

Manufacturing tolerances mean the quiescent output is rarely exactly VCC/2. The TI DRV5055 datasheet specifies a quiescent offset error of up to ±3%. Before deploying the sensor in a mechanical assembly, power it up in a zero-field environment (away from speakers, magnets, and steel tools), average 100 readings, and store that value in non-volatile memory (EEPROM/NVS) to use as your QUIESCENT_MV baseline.

2. Mitigating EMI and Switching Noise

Linear Hall sensors have high-gain internal amplifiers that will happily demodulate high-frequency electromagnetic interference (EMI) from nearby switching buck converters or LED PWM drivers.

  • Decoupling: Place a 100nF (0.1µF) X7R ceramic capacitor physically within 2mm of the sensor's VCC and GND pins. Do not rely on the ESP32's onboard decoupling.
  • Routing: Keep the analog output trace away from digital clock lines (like I2C SCL or SPI SCK). If using jumper wires, twist the signal wire with the ground wire to reject common-mode noise.
  • Software Filtering: Implement a simple Infinite Impulse Response (IIR) low-pass filter in software to smooth out 50/60Hz mains hum picked up by the sensor leads.

3. Mechanical Stress and Thermal Drift

Hall elements are fabricated on silicon dies, which are piezoresistive. If you solder the sensor to a PCB that flexes, or if you clamp the IC package too tightly in a 3D-printed mount, the mechanical stress alters the semiconductor lattice and shifts the zero-field offset. This is known as the piezo-Hall effect. Always mount the sensor on a rigid substrate and avoid potting the IC in rigid epoxy.

Thermal drift is another factor. The sensitivity of the DRV5055 drifts by roughly -0.02% per °C. For room-temperature hobby projects, this is negligible. If you are measuring current on a hot busbar or using the sensor in an automotive under-hood environment, you must read a local thermistor and apply a temperature-compensation multiplier to your final mT calculation.

💡 Workbench Tip: Verifying Sensor Health
If you suspect a dead sensor, don't just wave a fridge magnet over it. Set your multimeter to DC millivolts, probe the OUT and GND pins, and bring a known neodymium magnet close to the marked face. You should see the voltage swing smoothly from ~1.65V up to ~3.0V (North pole) and down to ~0.3V (South pole). If it snaps instantly to the rails or stays pinned at 1.65V, the internal amplifier is blown or the Hall element is cracked.