A Hall effect sensor translates magnetic flux density into an electrical signal. Specifically, it outputs either a continuous analog voltage proportional to the magnetic field strength (measured in Gauss or Tesla) or a clean digital logic pulse when a specific magnetic threshold is crossed. If you are building a current monitor, a brushless DC motor commutator, or a non-contact limit switch, understanding the exact output type and the raw-to-unit math is the difference between a reliable prototype and a noisy mess.
The Physics: How a Hall Effect Sensor Actually Works
The sensing principle relies on the Lorentz force. When a constant control current flows through a thin semiconductor element (typically Indium Antimonide or Gallium Arsenide) and a magnetic field is applied perpendicular to that current, the moving electrons are deflected to one side of the material. This charge accumulation creates a measurable transverse voltage—the Hall voltage—across the sensor. The stronger the perpendicular magnetic field, the greater the deflection and the higher the resulting voltage.
Because the raw Hall voltage is only in the microvolt range and highly susceptible to temperature drift, practical integrated circuits (ICs) like the Allegro A1302 or TI DRV5053 package the semiconductor die with an internal differential amplifier, voltage regulator, and temperature compensation circuitry. This onboard signal conditioning amplifies the microvolt deflection into a robust, usable output (typically 0.5V to 4.5V for analog, or a saturated push-pull/open-drain switch for digital) that can be read directly by a microcontroller's ADC or GPIO pin without external op-amps.
Selecting the Right IC: Analog vs. Digital Outputs
The most common mistake in embedded sensor design is conflating analog (linear) and digital (switch/latch) Hall sensors. Analog sensors output a continuous voltage that scales with magnetic flux density, making them ideal for measuring current, joystick position, or fluid level. Digital sensors contain an internal Schmitt trigger; they output a hard HIGH or LOW only when the magnetic field crosses a specific operate point (BOP) and release point (BRP), making them perfect for RPM counting or limit switches.
Data-Dense Spec Sheet: Common Hall ICs
Below is a breakdown of industry-standard Hall ICs. Note the supply ranges and quiescent voltages, which dictate whether you can power them directly from a 3.3V ESP32 or if you need a 5V Arduino Uno with a voltage divider.
| Part Number | Type | Supply Range (V) | Quiescent Output (No Field) | Sensitivity | Typ. Price (USD) |
|---|---|---|---|---|---|
| Allegro A1302 | Analog (Linear) | 4.5 to 6.0 | 2.5V (at 5V Vcc) | 1.3 mV/Gauss | $1.45 |
| Honeywell SS49E | Analog (Linear) | 2.7 to 6.5 | 1.65V (at 3.3V Vcc) | 1.4 mV/Gauss | $0.85 |
| TI DRV5053A1 | Analog (Linear) | 2.5 to 5.5 | 1.65V (at 3.3V Vcc) | 70 mV/mT (7 mV/G) | $0.60 |
| Melexis US5881 | Digital (Unipolar) | 2.2 to 5.5 | Open-Drain (Pull-up req.) | N/A (Switch: 35G BOP) | $0.40 |
Sources: Manufacturer datasheets (Allegro MicroSystems, Honeywell, Texas Instruments). Pricing reflects 2026 distributor averages for single-unit quantities.
Wiring and Pinout Table
When wiring to an ESP32, always prioritize native 3.3V sensors (like the DRV5053 or SS49E) to avoid frying the 12-bit ADC pins. If you must use a 5V-only sensor like the A1302, use a simple resistor divider (e.g., 2.2kΩ and 3.3kΩ) on the output pin.
| Sensor Pin | ESP32 DevKit v1 Connection | Arduino Uno Connection | Notes & Supply Range |
|---|---|---|---|
| VCC | 3V3 Pin (for 3.3V ICs) | 5V Pin | Verify IC datasheet; DRV5053 accepts 2.5-5.5V. |
| GND | GND | GND | Keep ground paths short to minimize EMI loop area. |
| OUT (Analog) | GPIO 34, 35, 36, or 39 | A0 - A5 | ESP32 ADC2 pins (e.g., GPIO 25) conflict with WiFi. |
| OUT (Digital) | Any GPIO (e.g., GPIO 22) | Any Digital Pin (e.g., D2) | Add 10kΩ pull-up to 3.3V if IC is open-drain. |
Interfacing, Wiring, and Raw-to-Gauss Math
Reading a digital Hall sensor is as simple as using digitalRead(), but extracting physical units from an analog sensor requires precise math and an understanding of your microcontroller's ADC architecture. Let's walk through the raw-to-unit conversion using the TI DRV5053A1 powered at 3.3V, read by an ESP32's 12-bit ADC.
The Output Signal Math
The fundamental transfer function for a linear Hall sensor is:
V_out = V_q + (B × Sensitivity)
Where:
- V_out is the measured voltage at the output pin.
- V_q is the quiescent voltage (output when B = 0). For the DRV5053 at 3.3V Vcc, V_q is nominally 1.65V.
- B is the magnetic flux density in milli-Tesla (mT).
- Sensitivity is 70 mV/mT for the A1 variant.
To find the magnetic field (B), we rearrange the formula:
B (mT) = (V_out - 1.65) / 0.070
Converting ESP32 ADC Raw Values to Voltage
The ESP32 features a 12-bit ADC, meaning raw readings range from 0 to 4095. However, the ESP32 ADC is notoriously non-linear at the extreme top and bottom of its range. According to Espressif's official ADC documentation, you should use the built-in calibration functions or restrict your measurement window to the linear middle region (roughly 0.1V to 3.1V).
Assuming a calibrated reading, the voltage conversion is:
V_out = (ADC_raw / 4095.0) * 3.3
Complete C++ Snippet for ESP32 (Arduino Core):
const int hallPin = 34;
const float Vcc = 3.3;
const float V_q = 1.65; // Quiescent voltage at 0 Gauss
const float sensitivity = 0.070; // 70 mV/mT converted to V/mT
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit mode
pinMode(hallPin, INPUT);
}
void loop() {
// Multisampling to reduce ESP32 ADC noise
long sum = 0;
for(int i = 0; i < 64; i++) {
sum += analogRead(hallPin);
}
float adc_avg = sum / 64.0;
float V_out = (adc_avg / 4095.0) * Vcc;
float B_mT = (V_out - V_q) / sensitivity;
float B_Gauss = B_mT * 10.0; // 1 mT = 10 Gauss
Serial.print("Voltage: "); Serial.print(V_out, 3);
Serial.print(" V | Field: "); Serial.print(B_Gauss, 1);
Serial.println(" Gauss");
delay(250);
}
Real-World Interference and Calibration Gotchas
A Hall sensor on a clean workbench behaves perfectly; a Hall sensor inside a motor controller enclosure is a magnet for noise. If your readings are drifting or jumping, check these three common interference sources.
1. AC Mains and High-Current EMI
Because linear Hall sensors contain high-gain internal op-amps, they will readily demodulate 50/60Hz electromagnetic interference from nearby AC mains wiring or high-current PWM motor traces. This manifests as a 50/60Hz ripple on your ADC readings. The fix: Route sensor traces as twisted pairs, keep them at least 10mm away from AC lines, and place a 100nF ceramic bypass capacitor directly across the VCC and GND pins of the sensor, as close to the plastic package as physically possible.
2. Thermal Drift and Quiescent Shift
The quiescent voltage (V_q) is derived from Vcc. If your 3.3V regulator sags under load (e.g., when an ESP32 transmits a WiFi packet, pulling an extra 300mA), Vcc might drop to 3.1V. Your V_q will drop proportionally, causing the sensor to report a false change in the magnetic field. The fix: Power the sensor from a dedicated, low-noise LDO (like the AP2112) rather than sharing the microcontroller's main 3.3V rail, or measure Vcc dynamically with another ADC channel to compensate in software.
3. Ferrous Mounting Hardware
Mounting your PCB with steel screws or placing the sensor inside a steel enclosure will distort the magnetic field lines you are trying to measure. Steel has high magnetic permeability; it acts as a flux shunt, pulling magnetic field lines away from the sensor die and reducing your effective sensitivity. The fix: Use brass, nylon, or plastic standoffs and screws within a 15mm radius of the Hall IC. For deeper theory on magnetic field distortion in sensor enclosures, refer to this comprehensive guide on magnetic field interactions.
By matching the correct IC to your microcontroller's logic levels, applying the exact transfer function math, and mitigating EMI at the hardware level, Hall effect sensors become one of the most reliable, non-contact measurement tools in your embedded arsenal.






