The Physics: How a Magnetic Hall Sensor Works
When an electrical current flows through a semiconductor material and a magnetic field is applied perpendicular to that current, the Lorentz force deflects the moving charge carriers (electrons) to one side of the material. This accumulation of charge creates a measurable transverse voltage difference across the conductor, known as the Hall voltage. The magnitude of this voltage is directly proportional to the strength of the magnetic flux density passing through the sensor, allowing us to quantify invisible magnetic fields as electrical signals.
Manufacturers build on this baseline physics to create two distinct categories of sensors. A linear magnetic hall sensor amplifies this transverse voltage continuously, outputting an analog signal that scales proportionally with the magnetic field strength (measured in Gauss or milliTesla). Conversely, a digital Hall switch pairs the sensing element with an internal Schmitt trigger, snapping the output to a clean logic HIGH or LOW only when the magnetic field crosses a specific threshold, which is ideal for simple proximity or limit-switch applications.
Output Signals: What You Are Actually Measuring
A common trap for beginners is conflating analog and digital outputs when ordering parts. You must match the sensor's output type to your microcontroller's capabilities and your project's goal.
- Linear (Analog) Output: The sensor outputs a continuous DC voltage. At zero magnetic field, it sits at a quiescent offset (usually half the supply voltage, e.g., 2.5V on a 5V supply). As a north pole approaches, the voltage rises; as a south pole approaches, it falls. This requires an Analog-to-Digital Converter (ADC) pin on your microcontroller.
- Digital (Switch) Output: The sensor outputs a logic level. These are typically open-drain (requires an external pull-up resistor to VCC) or push-pull (drives both HIGH and LOW actively). You read this with a standard digital GPIO pin configured with an interrupt or simple
digitalRead().
Wiring Guide and Supply Specifications
Powering these sensors incorrectly is the leading cause of 'noisy' or flatlined readings. While the basic 3-pin interface (VCC, GND, OUT) is universal, the supply voltage dictates your output swing and logic compatibility.
| Part Number | Type | Supply Range (VCC) | Quiescent Output (0 mT) | Logic Compatibility |
|---|---|---|---|---|
| Honeywell SS49E | Linear | 2.7V to 6.5V | VCC / 2 | 5V Arduino (Analog) |
| Allegro A1324EUA-T | Linear | 4.5V to 5.5V | 2.5V | 5V Arduino (Analog) |
| TI DRV5053A1 | Linear | 2.3V to 5.5V | VCC / 2 | 3.3V ESP32 / RP2040 |
| Melexis US5881 | Digital | 2.2V to 24V | Open-Drain LOW | Any (with Pull-up) |
The 3.3V ESP32 Trap: If you wire a 5V-powered SS49E directly to an ESP32 GPIO, the sensor's maximum output swing (up to 5V) will fry the ESP32's ADC pin, which is strictly limited to ~3.1V-3.3V. You must either power the SS49E at 3.3V (which reduces its sensitivity) or use a voltage divider on the output pin. The cleaner solution is to use a native 3.3V optimized part like the DRV5053.
The Math: Converting Raw ADC to MilliTesla
Let's calculate the physical magnetic flux density using the Texas Instruments DRV5053A1 powered at 3.3V on an ESP32 DevKit V1. According to the TI DRV5053 Datasheet, the A1 variant has a sensitivity of 100 mV/mT and a quiescent offset of VCC/2 (1.65V).
Step 1: Raw ADC to Voltage
The ESP32 features a 12-bit ADC (0 to 4095). However, the ESP32 ADC is notoriously non-linear at the extremes. Instead of manual mapping, use the modern ESP32 Arduino Core v2.x+ built-in function analogReadMilliVolts(), which applies Espressif's factory calibration fuses to return a highly accurate millivolt reading. For the sake of the underlying math, the theoretical conversion is:
Voltage (V) = Raw_ADC * (3.3 / 4095)
Step 2: Voltage to MilliTesla (mT)
To find the magnetic field, subtract the zero-field offset (1.65V) from your measured voltage, then divide by the sensitivity (0.100 V/mT).
Field (mT) = (Measured_Voltage - 1.65) / 0.100
You read a raw ADC value of 2650.
1. Voltage = 2650 * (3.3 / 4095) = 2.135V (or 2135 mV).
2. Field = (2.135 - 1.65) / 0.100 = 4.85 mT.
Because the value is positive, you are measuring a North magnetic pole. A reading of 1400 (1.12V) would yield -5.3 mT, indicating a South pole.
Calibration and Magnetic Interference
Out of the box, your readings will drift. To achieve precision, you must address offset errors and environmental interference.
Software Zero-Offset Calibration
Never hardcode the 1.65V offset. Manufacturing tolerances mean your specific sensor might sit at 1.62V or 1.68V in a zero-field environment. On boot, before any magnets are near the sensor, take 100 rapid ADC samples, average them, and store that value as your zero_offset. Subtract this dynamic baseline from all subsequent readings.
Common Interference Sources
- Ferrous Metals: Steel screws, breadboard rails, and enclosures act as magnetic flux concentrators. A standard steel breadboard can distort the local magnetic field by up to 15%, causing severe non-linearity. Mount the sensor on a plastic or wooden standoff.
- AC Mains EMI: Running the sensor cable parallel to 120V/240V AC wiring will induce a 50/60Hz hum on the analog output. Keep signal wires away from mains, and implement a software moving-average filter (window of 10-20 samples) to smooth out the AC ripple.
- Temperature Drift: Hall elements exhibit temperature coefficients (typically -100 to -200 ppm/°C for the offset). If your project operates in an unheated garage or outdoors, you must either use a sensor with internal temperature compensation (like the Allegro A1324) or log temperature via a thermistor to apply a software correction curve.
Decision Tree: Pick Your Exact Part Number
Do not waste time debugging the wrong sensor architecture. Follow this decision path to select the correct component for your specific microcontroller and application.
| If your project requires... | And your MCU logic is... | Then choose this architecture... | Exact Part Number to Buy |
|---|---|---|---|
| Detecting simple presence (door open/close, RPM counting) | Any (3.3V or 5V) | Digital Switch (Omnipolar) | Melexis US5881LSE-AAA-000-SP |
| Measuring linear distance, angle, or fluid level | 5V (Arduino Uno/Mega) | Linear Analog (5V optimized) | Honeywell SS49E |
| Measuring linear distance, angle, or fluid level | 3.3V (ESP32, RP2040, STM32) | Linear Analog (3.3V native) | Texas Instruments DRV5053A1QLPG |
| High-precision 3-axis spatial mapping | 3.3V with I2C bus | 3D Digital I2C | Infineon TLV493D-A1B6 |
The Verdict
For the vast majority of modern hobbyist and prosumer embedded projects utilizing 3.3V microcontrollers like the ESP32 or Raspberry Pi Pico, the Texas Instruments DRV5053A1 is the definitive default pick. It eliminates the need for voltage dividers, provides a clean ratiometric analog output perfectly scaled to 3.3V ADC references, and costs roughly $1.20 per unit in low quantities. Pair it with analogReadMilliVolts() and a startup zero-offset calibration routine, and you will achieve reliable, repeatable magnetic flux measurements straight off the breadboard.






