A digital hall sensor outputs a discrete logic HIGH or LOW—never a proportional analog voltage—when the applied magnetic flux density crosses a specific factory-set threshold. For most modern embedded projects in 2026, the Texas Instruments DRV5032 (ultra-low power, omnipolar) or the classic Allegro A3144 (high-voltage unipolar) are the standard choices, costing between $0.10 and $0.40 per unit in low volumes. Because the output is strictly digital, your microcontroller's ADC is bypassed entirely; you will read this sensor using a hardware interrupt or a polled digital GPIO pin.
How a Digital Hall Sensor Works
When a bias current flows through a semiconductor plate inside the sensor package, an external magnetic field exerts a Lorentz force on the charge carriers, deflecting them to one side of the material. This charge accumulation creates a transverse voltage differential known as the Hall voltage, which is directly proportional to the magnetic field strength.
In a digital Hall sensor, this microscopic analog Hall voltage is immediately routed into an internal Schmitt-trigger comparator. Instead of exposing the raw voltage to an output pin, the comparator snaps the output to a rigid logic state once the field crosses the operate point ($B_{OP}$), and resets only when it drops below the release point ($B_{RP}$). This built-in magnetic hysteresis is what prevents output chatter and oscillation when the magnet hovers near the threshold boundary.
Wiring, Pinouts, and Output Stages
Digital Hall sensors typically come in 3-pin TO-92 through-hole packages or ultra-small SOT-23 surface-mount footprints. The pinout is almost universally standardized across manufacturers, but the electrical behavior of the output pin varies critically between open-drain and push-pull architectures.
| Pin | Function | Typical Range (DRV5032) | Typical Range (A3144) |
|---|---|---|---|
| 1 (VCC) | Power Supply | 1.65V to 5.5V | 4.5V to 24V |
| 2 (GND) | Ground Reference | 0V | 0V |
| 3 (OUT) | Digital Output | Push-Pull / Open-Drain | Open-Drain (Requires Pull-up) |
If you are using an open-drain sensor like the A3144, the output pin can only pull the line to GND (Logic LOW); it cannot drive it HIGH. You must connect a pull-up resistor (typically 4.7kΩ to 10kΩ) between the OUT pin and your microcontroller's logic voltage (e.g., 3.3V for ESP32). Without it, the pin will float, causing random ghost triggers.
From Pulses to Physical Units: The Math
Because a digital Hall sensor does not output a continuous voltage, there is no ADC scaling or Gauss calibration required. The "raw reading" from your microcontroller is a pulse train (a series of timestamps or edge counts). To convert this raw digital data into a useful physical unit like Revolutions Per Minute (RPM) or linear speed, you must measure the frequency of the pulses.
For rotational speed (e.g., measuring a BLDC motor or a bicycle wheel), the math relies on the number of magnetic poles ($P$) passing the sensor. The formula to convert pulse frequency ($f$ in Hz) to RPM is:
RPM = (f × 60) / P
Where $f$ = pulses per second, and $P$ = number of distinct magnetic poles passing the sensor per revolution.
Worked Example: You are monitoring a scooter wheel with a ring magnet containing 4 north and 4 south poles ($P = 8$). Your ESP32 hardware interrupt counts 120 pulses in exactly 1.0 second ($f = 120$ Hz).
RPM = (120 × 60) / 8 = 900 RPM.
Here is a robust, non-blocking ESP32 implementation using hardware interrupts to capture this data without stalling your main loop:
// ESP32 Digital Hall Sensor RPM Calculation
const int hallPin = 14; // GPIO 14
volatile unsigned long pulseCount = 0;
volatile unsigned long lastMicros = 0;
const int magneticPoles = 8;
void IRAM_ATTR hallInterrupt() {
pulseCount++;
}
void setup() {
Serial.begin(115200);
// Internal pull-up used here; ensure your sensor is open-drain compatible
pinMode(hallPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(hallPin), hallInterrupt, FALLING);
}
void loop() {
// Calculate every 500ms for faster UI updates
if (millis() - lastMicros >= 500) {
unsigned long count = pulseCount;
pulseCount = 0;
lastMicros = millis();
// count is for 0.5s, so multiply by 2 to get Hz
float frequencyHz = count * 2.0;
float rpm = (frequencyHz * 60.0) / magneticPoles;
Serial.printf("Freq: %.1f Hz | RPM: %.1f\n", frequencyHz, rpm);
}
}
Calibration, Interference, and Hardware Gotchas
While the magnetic threshold ($B_{OP}$) is factory-trimmed and requires no software calibration, the mechanical system absolutely does. The physical air gap between the magnet and the sensor face dictates the field strength at the silicon. A 5mm x 5mm neodymium magnet might trigger a DRV5032 at 4mm away, but only at 1.5mm if you swap to a weaker ceramic ferrite magnet. Always prototype your exact magnet-sensor distance before finalizing your 3D printed enclosure.
Common Interference Sources:
- High dI/dt Traces: Routing sensor wires parallel to high-current motor phases or switching power supply traces will induce electromagnetic interference (EMI). This can create false voltage spikes that the sensor's internal comparator mistakes for a magnetic threshold crossing. Keep sensor traces orthogonal to power traces.
- Mechanical Vibration: If the magnet is mounted on a vibrating shaft, the physical air gap fluctuates rapidly. If the nominal gap is too close to the sensor's hysteresis boundary, vibration will cause the output to chatter. Increase the air gap slightly or add a 10nF capacitor in parallel with your pull-up resistor to form a low-pass hardware filter.
- Temperature Drift: While modern ICs include internal temperature compensation, extreme heat (above 85°C) can shift the operate point. If mounting near a motor stator, use a high-temperature rated variant like the Melexis US5881.
Frequently Asked Questions
Can a digital hall sensor measure magnetic field strength in Gauss?
No. A digital Hall sensor only tells you if the field is above or below a specific threshold (e.g., "is the field stronger than 30 Gauss?"). It cannot tell you if the field is 35 Gauss or 100 Gauss. If your application requires measuring continuous magnetic field strength, proximity distance via flux density, or joystick deflection, you must use an analog or linear Hall sensor (like the SS49E or DRV5053) and read it with your microcontroller's ADC.
Why is my digital hall sensor output floating or giving random triggers?
Random triggers almost always point to a missing or incorrectly sized pull-up resistor on an open-drain output. If your microcontroller pin is set to INPUT instead of INPUT_PULLUP, the line is high-impedance when the sensor is off, acting as an antenna for ambient electrical noise. Enable the internal pull-up in your code, or add an external 4.7kΩ physical resistor to the logic rail. If the issue persists, check for EMI from nearby switching regulators.
What is the difference between unipolar, bipolar, and omnipolar digital hall sensors?
This defines which magnetic pole triggers the sensor. A unipolar sensor (like the A3144) only triggers when it sees a South pole and ignores North poles entirely. A bipolar (or latch) sensor triggers on a South pole but will not reset until it sees a North pole, making it ideal for precise motor commutation. An omnipolar sensor (like the DRV5032) triggers and resets on either a North or South pole, which is best for simple proximity switches or counting gear teeth where magnet orientation is hard to guarantee.






