A Hall effect sensor measures magnetic field strength and polarity by outputting a proportional voltage (analog) or triggering a switch state (digital) when a magnetic field deflects electrons moving through a semiconductor. Whether you are building a BLDC motor controller, a DIY tachometer, or a non-contact current meter, understanding the exact output type and scaling math is the difference between a working prototype and a noisy, unreliable mess.
The Physics: How Hall Effect Sensors Actually Work
When a control current flows through a thin semiconductor plate (typically gallium arsenide or indium antimonide) and a magnetic field is applied perpendicular to it, the Lorentz force pushes the charge carriers to one side of the plate. This accumulation of charge creates a measurable transverse voltage, known as the Hall voltage. The strength of this voltage is directly proportional to the magnetic flux density passing through the material.
In practical hobbyist modules like the SS49E (linear) or A3144 (digital switch), this microvolt-level Hall voltage is immediately amplified by an internal operational amplifier and conditioned by a voltage regulator or Schmitt trigger. The result is a robust, temperature-compensated signal you can read directly with a microcontroller's ADC or digital GPIO without needing external amplification circuitry.
Analog vs. Digital: What the Output Actually Is
The most common mistake makers make is conflating analog (linear) Hall sensors with digital (switch) Hall sensors. They look identical on a breakout board—usually a 3-pin SIP or SOT-23 package—but their internal architecture and output signals are fundamentally different.
- Analog (Linear) Output: The sensor outputs a continuous, ratiometric voltage. At zero magnetic field, the output sits at exactly half the supply voltage (Vcc/2). As a north pole approaches, the voltage increases; as a south pole approaches, it decreases. This is used for measuring exact field strength, displacement, or current.
- Digital (Switch/Latch) Output: The sensor contains an internal comparator with hysteresis. It outputs a digital logic level (usually via an open-collector NPN transistor or push-pull CMOS). It snaps LOW when the magnetic field exceeds a specific threshold (B_OP) and snaps HIGH when it drops below a release threshold (B_RP). This is used for RPM counting, limit switches, and speed sensing.
Specification and Wiring Table
| IC / Module | Type | Supply Range (Vcc) | Output Type | Zero-Field State |
|---|---|---|---|---|
| Texas Instruments DRV5055 | Analog Linear | 2.5V - 5.5V | Ratiometric Voltage | Vcc / 2 |
| Honeywell SS49E | Analog Linear | 2.7V - 6.5V | Ratiometric Voltage | Vcc / 2 |
| Allegro A3144 | Digital Switch | 3.8V - 24V | Open-Collector (Needs Pull-up) | HIGH (via Pull-up) |
| Melexis US1881 | Digital Latch | 3.5V - 24V | Push-Pull CMOS | Latches previous state |
Interfacing with ESP32: Wiring and Raw-to-Unit Math
Let's interface the DRV5055A1 (analog) with an ESP32. The DRV5055A1 has a precise sensitivity of 10 mV/mT (millivolts per millitesla). We will power it at 3.3V to match the ESP32's ADC limits safely.
Wiring Steps
- VCC: Connect to ESP32 3V3 pin.
- GND: Connect to ESP32 GND.
- OUT: Connect to ESP32 GPIO 34 (an ADC1 channel, which remains functional when WiFi is active).
- Bypass Cap: Solder a 100nF ceramic capacitor directly across the VCC and GND pins of the sensor to filter high-frequency EMI.
Raw-to-Unit Math and Calibration
At 3.3V, the quiescent (zero-field) output is 1.65V (1650 mV). If a magnetic field of 20 mT is applied, the output shifts by 200 mV, resulting in 1850 mV. The ESP32's native 12-bit ADC (0-4095) is notoriously non-linear, especially near the 0V and 3.3V rails. Instead of mapping raw 0-4095 integers, modern ESP32 Arduino cores include the analogReadMilliVolts() function, which applies factory-stored eFuse calibration data to return a highly accurate millivolt reading.
The physical unit conversion formula is:
Magnetic_Field_mT = (Measured_mV - Quiescent_mV) / Sensitivity_mV_per_mT
// ESP32 Hall Effect Sensor Code (DRV5055A1)
const int hallPin = 34;
const float quiescent_mV = 1650.0; // Vcc/2 at 3.3V supply
const float sensitivity = 10.0; // 10 mV/mT for DRV5055A1 variant
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution
pinMode(hallPin, INPUT);
}
void loop() {
// Read calibrated millivolts directly
int raw_mv = analogReadMilliVolts(hallPin);
// Calculate magnetic field in milliTesla (mT)
float field_mT = (raw_mv - quiescent_mV) / sensitivity;
// Convert to Gauss (1 mT = 10 Gauss) if preferred
float field_gauss = field_mT * 10.0;
Serial.print("Field: ");
Serial.print(field_mT, 2);
Serial.print(" mT | ");
Serial.print(field_gauss, 1);
Serial.println(" Gauss");
delay(100);
}
1650.0 as your absolute zero-point in a production build. Component tolerances mean your actual zero-point might be 1635 mV. Add a calibration routine in setup() that takes 100 readings with no magnet present, averages them, and stores that value as your dynamic quiescent_mV.
Real-World Interference and Calibration
Hall effect sensors are incredibly useful, but they are highly susceptible to environmental interference. If your readings are drifting or noisy, check these three common culprits:
- Thermal Drift: The Hall element's sensitivity and offset voltage change with temperature. While modern ICs include internal temperature compensation, a sensor placed near a hot voltage regulator or power MOSFET will still exhibit zero-point drift. Keep your sensor physically isolated from heat-generating components.
- Piezoresistive Stress: Silicon is piezoresistive, meaning mechanical stress changes its electrical resistance. If you bend your PCB, overtighten the mounting screws, or apply too much heat during soldering, the physical stress on the IC package will shift the zero-field voltage. This is a frequent cause of "my sensor reads 5 mT when no magnet is present" complaints.
- AC Magnetic Interference: Hall sensors will happily pick up 50Hz/60Hz electromagnetic fields from nearby AC mains wiring or transformers. This manifests as a low-frequency hum in your ADC readings. To fix this, implement a software low-pass filter (like a simple moving average or exponential smoothing) or increase the hardware bypass capacitance to 1µF.
Frequently Asked Questions
What does a Hall effect sensor do in a brushless DC (BLDC) motor?
In a BLDC motor, Hall effect sensors act as rotor position encoders. Typically, three digital Hall sensors are embedded in the stator, spaced 120 electrical degrees apart. As the permanent magnets on the rotor spin past, the sensors output a sequence of HIGH/LOW digital pulses. The motor controller reads these pulses to determine the exact angular position of the rotor, allowing it to commutate (switch) the current through the stator coils at the precise microsecond needed to keep the motor spinning smoothly. Without them, the controller must rely on sensorless back-EMF zero-crossing detection, which struggles at low RPMs.
What does a Hall effect sensor do when exposed to AC magnetic fields?
If you expose an analog Hall sensor to an alternating magnetic field (like the one generated by an AC current-carrying wire), the output voltage will oscillate above and below the Vcc/2 quiescent point at the exact frequency of the AC source (e.g., 60Hz). This is the operating principle behind non-contact AC current clamps. However, if you expose a digital switch sensor to an AC field, it will rapidly chatter between HIGH and LOW states as the field crosses its operate and release thresholds, which can cause interrupt storms or erratic behavior in your microcontroller code.
How do I know if my unmarked Hall effect sensor is digital or analog?
If the part number is rubbed off, you can identify the type using a multimeter and a magnet. Power the sensor with 5V and connect your multimeter's DC voltage probe to the output pin. Wave a neodymium magnet past the sensor. If the voltage sweeps smoothly and continuously (e.g., from 2.5V up to 4.8V, then down to 0.2V), it is an analog linear sensor. If the voltage sits steady at 5V and then instantly snaps to near 0V the moment the magnet gets close enough, it is a digital switch. (Note: If it snaps to 0V and stays there until you reverse the magnet's polarity, it is a digital latch, like the US1881).






