The Hall sensor effect generates a measurable transverse voltage across a semiconductor when it is exposed to a perpendicular magnetic field. For microcontroller builders, this physical phenomenon translates into two distinct electronic outputs: a digital switch that toggles between 0V and VCC, or an analog voltage that scales linearly with magnetic flux density (measured in Gauss or milliTesla). Choosing the right output type and understanding the raw-to-unit math is the difference between a reliable RPM counter and a noisy, unusable prototype.
The Physics: How the Hall Sensor Effect Works
When an electrical current flows through a thin semiconductor layer (typically Indium Arsenide or Gallium Arsenide), the charge carriers move in a straight line. If you apply a magnetic field perpendicular to this current, the Lorentz force deflects the moving electrons toward one edge of the material. This physical deflection is the core of the Hall sensor effect.
As electrons accumulate on one edge, they create a transverse electric field—a measurable voltage difference across the material known as the Hall voltage. Because this voltage is directly proportional to the magnetic flux density passing through the sensor, modern Hall ICs use internal differential amplifiers to boost this microvolt-level signal into a clean, temperature-compensated output that an Arduino or ESP32 can easily read.
Analog vs. Digital Output: Don't Conflate Them
Critical Distinction: Never wire a digital Hall switch to an analog pin expecting a proportional reading, and never wire an analog linear sensor to a digital interrupt expecting a clean square wave. They operate on fundamentally different internal architectures.
Digital Hall Sensors (Switches/Latches): Devices like the A3144 or DRV5012 contain an internal Schmitt trigger. They output a hard digital LOW (0V) when the magnetic field exceeds a specific threshold (B_OP), and release to a HIGH (VCC) when the field drops below a release point (B_RP). The output transistor is typically open-drain, meaning you must use a pull-up resistor on the microcontroller side. These are strictly for proximity detection, RPM counting, or limit switches.
Analog Hall Sensors (Linear): Devices like the Honeywell SS49E or Texas Instruments DRV5053 output a continuous voltage. At zero magnetic field, the output sits at a quiescent voltage (usually VCC/2). As a magnetic pole approaches, the voltage swings toward VCC or GND depending on polarity. These are required for measuring exact field strength, current sensing, or linear position tracking.
Wiring and Pinout Specifications
Below is the reference table for the most common hobbyist and prototyping Hall ICs. Always verify the supply range; pushing 5V into a 3.3V-rated sensor will permanently destroy the internal op-amp.
| IC Model | Type | Supply Range | Output Style | Pinout (Flat face up) |
|---|---|---|---|---|
| A3144 | Digital Switch | 4.5V - 24V | Open-Drain (Needs Pull-up) | 1: VCC, 2: GND, 3: OUT |
| DRV5012 | Digital Latch | 1.6V - 5.5V | Push-Pull (No Pull-up needed) | 1: VCC, 2: OUT, 3: GND |
| SS49E | Analog Linear | 2.7V - 6.5V | Ratiometric Analog | 1: VCC, 2: GND, 3: OUT |
| DRV5053A1 | Analog Linear | 2.5V - 5.5V | Absolute Analog | 1: VCC, 2: OUT, 3: GND |
Bench Tip: If you are using an ESP32, stick to the DRV5053 or DRV5012. The A3144 requires a minimum of 4.5V, and while the ESP32 is 5V tolerant on some pins, running the sensor at 3.3V keeps your logic levels safely within the ESP32's native 12-bit ADC range without needing a voltage divider.
The Math: Converting Raw ADC to Gauss
Let's interface the Texas Instruments DRV5053A1 with an ESP32. This sensor has a sensitivity of 100 mV/mT (which equals 10 mV/Gauss) and a quiescent voltage ($V_Q$) of $V_{CC} / 2$. If we power it with exactly 3.3V, $V_Q$ is 1.65V.
The physical formula for the output voltage is:
V_out = V_Q + (B × Sensitivity)
Where B is the magnetic flux density in milliTesla (mT). To find B, we rearrange the formula:
B (mT) = (V_measured - V_Q) / Sensitivity
Here is the exact C++ implementation for the Arduino IDE (ESP32 core 2.0+). We use analogReadMilliVolts() instead of raw analogRead() to bypass the ESP32's notorious ADC non-linearity and internal attenuation mapping.
const int HALL_PIN = 34; // ADC1 channel, safe for WiFi use
const float VCC = 3300.0; // Supply voltage in mV
const float VQ = VCC / 2.0; // Quiescent voltage in mV
const float SENSITIVITY = 100.0; // mV per mT for DRV5053A1
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit (0-4095)
}
void loop() {
// Read calibrated voltage directly in millivolts
float v_measured = analogReadMilliVolts(HALL_PIN);
// Calculate magnetic field in milliTesla
float b_mT = (v_measured - VQ) / SENSITIVITY;
// Convert mT to Gauss (1 mT = 10 Gauss)
float b_gauss = b_mT * 10.0;
Serial.print("Field: ");
Serial.print(b_gauss, 1);
Serial.println(" Gauss");
delay(100);
}
According to the Texas Instruments Hall Effect sensor guidelines, always sample the analog output at least 10 times and average the result in software to eliminate high-frequency thermal noise before applying the math.
Calibration and Interference Mitigation
A raw mathematical conversion assumes a perfect world. In practice, three interference sources will corrupt your Hall sensor effect readings if left unaddressed:
- Piezoresistive Mechanical Stress: The silicon die inside a Hall IC is sensitive to physical bending. If you solder the sensor with excessive heat, or if you mount it on a flexing PCB, the mechanical stress shifts the zero-Gauss offset voltage ($V_Q$). Fix: Always power up the sensor in a zero-magnetic environment and record the actual baseline ADC reading in your code's
setup()routine rather than hardcoding VCC/2. - Electromagnetic Interference (EMI): Hall sensors are essentially high-gain magnetic antennas. Routing sensor traces parallel to stepper motor wires or switching buck converters will induce massive voltage spikes. Fix: Keep analog Hall traces under 2 inches, route them over a solid ground plane, and place a 100nF ceramic bypass capacitor directly across the VCC and GND pins of the sensor.
- Temperature Drift: While modern ICs have internal temperature compensation for the sensitivity, the quiescent offset voltage still drifts slightly with ambient heat. If your sensor is mounted near a hot motor driver, expect a 1-2% zero-point shift per 10°C rise.
Hall Sensor Effect FAQ
How does temperature affect the hall sensor effect readings?
Temperature impacts both the semiconductor's charge carrier mobility and the internal amplifier's offset voltage. In cheap, uncompensated sensors, sensitivity can drop by up to 0.2% per degree Celsius. Premium ICs like the DRV5053 use integrated chopper-stabilized amplifiers that actively cancel thermal offset drift, keeping sensitivity variance under ±3% across a -40°C to 125°C range. If you are measuring fields in a high-heat environment (like inside a motor housing), you must use a chopper-stabilized part or read an onboard thermistor to apply a software correction factor.
Can the hall sensor effect be used to measure AC current?
Yes, but not with a standard linear sensor alone. To measure AC current, you must pass the current-carrying wire through a high-permeability ferrite toroid with an air gap, and mount the Hall sensor inside that gap. The ferrite concentrates the alternating magnetic field generated by the AC current. However, standard Hall ICs have bandwidth limits (typically 20kHz to 50kHz). For 50/60Hz mains AC current sensing, dedicated isolated Hall current sensors like the ACS712 or the newer Allegro ACS724 are vastly superior because they integrate the ferrite core, the sensor, and the isolation barrier into a single safe package.
Why is my analog hall sensor effect output noisy on an ESP32?
The ESP32's native SAR ADC is highly susceptible to noise from the chip's own WiFi/Bluetooth radio and internal switching regulators. If your readings are jumping by ±20 Gauss at zero field, you are seeing RF rectification and ADC non-linearity. First, ensure you are using an ADC1 pin (GPIO 32-39), as ADC2 shares hardware with the WiFi antenna and becomes unstable when WiFi is active. Second, add a 10µF tantalum and a 100nF ceramic capacitor in parallel at the sensor's power pins. Finally, implement a software low-pass filter (exponential moving average) in your code.
What is the difference between a hall sensor effect switch and a latch?
A digital Hall switch (like the A3144) turns ON when a South pole reaches the operate threshold, and turns OFF when the South pole is removed and the field drops below the release threshold. It ignores North poles entirely. A digital Hall latch (like the DRV5012) turns ON when exposed to a strong South pole, but it stays ON even when the magnet is removed. It will only turn OFF when exposed to a strong North pole. Latches are mandatory for brushless DC (BLDC) motor commutation and bidirectional RPM encoding, while switches are used for simple proximity limits.






