How a Hall Effect Magnetic Sensor Actually Works

At the core of every hall effect magnetic sensor is the Lorentz force. When a constant current flows through a thin semiconductor material (like indium antimonide or gallium arsenide), the charge carriers—usually electrons—move in a straight line. If you introduce a magnetic field perpendicular to this current flow, the magnetic force deflects the moving electrons to one side of the material. This physical separation of charge creates a measurable transverse voltage across the semiconductor, known as the Hall voltage.

Because the raw Hall voltage is incredibly small (often in the microvolt range), modern integrated hall sensors include an on-chip differential amplifier and voltage regulator. The amplifier boosts the microvolt signal to a usable level, while the internal regulator ensures the output remains stable even if your bench power supply sags. Depending on the specific silicon inside the package, this amplified signal is either fed directly to an analog output pin or routed through a Schmitt trigger to create a clean digital logic signal.

Analog vs. Digital Outputs: What You Are Actually Reading

A common mistake in embedded projects is conflating analog (linear) and digital (switch/latch) hall sensors. They look identical on the outside—usually a black 3-pin TO-92 package—but their outputs behave completely differently.

Analog (Linear) Sensors

The output is a continuous voltage proportional to the magnetic flux density (measured in Gauss or milliTesla). With no magnet present, the output sits at a quiescent 'null' voltage (typically half of your supply voltage, VCC/2). As a north pole approaches, the voltage increases; as a south pole approaches, it decreases. You read this with a microcontroller's Analog-to-Digital Converter (ADC).

Digital (Switch/Latch) Sensors

The output is a binary logic level (HIGH or LOW), usually driven by an internal open-drain MOSFET. It acts as a simple proximity switch. When the magnetic field crosses a specific 'operate point' (Bop) threshold, the output pulls LOW. It stays LOW until the field drops below the 'release point' (Brp), or in the case of a latch, until an opposite magnetic pole is applied. You read this with a standard digital GPIO pin configured with an internal pull-up resistor.

Wiring, Pinouts, and Supply Ranges

Almost all through-hole hall sensors share the same standard 3-pin layout when viewed from the front (flat face with text facing you). Below is the standard wiring matrix for interfacing with 5V (Arduino Uno/Mega) and 3.3V (ESP32/Raspberry Pi Pico) microcontrollers.

Pin Function Arduino (5V) Connection ESP32 (3.3V) Connection Notes & Decoupling
1 (Left) VCC 5V Pin 3V3 Pin Requires 100nF ceramic cap to GND, placed <5mm from pins.
2 (Middle) GND GND GND Must share a common ground plane with the MCU ADC ground.
3 (Right) OUT Analog Pin (e.g., A0) ADC Pin (e.g., GPIO34) For digital sensors, add a 10kΩ pull-up to VCC if not using internal pull-ups.
ESP32 ADC Warning: The ESP32's internal ADC is notoriously non-linear below 0.15V and above 2.6V. If you power your analog hall sensor at 3.3V, the quiescent voltage is 1.65V (safe), but strong magnetic fields will push the output past 2.6V, clipping your readings. For precision ESP32 projects, use an external I2C ADC like the ADS1115, or power the sensor from the 5V VIN pin and use a voltage divider on the output.

The Math: Converting Raw ADC Readings to Gauss

To turn a raw ADC integer into a physical unit (Gauss), you must account for the sensor's quiescent voltage (offset) and its sensitivity (slope). Let's use the Allegro A1302 powered at exactly 5.0V, read by a standard 10-bit Arduino ADC (0-1023 range).

The Core Formula:
B (Gauss) = (V_out - V_quiescent) / Sensitivity

Worked Numeric Example

  1. Identify Datasheet Specs (at 5V): V_quiescent = 2.5V. Sensitivity = 1.3 mV/Gauss (0.0013 V/G).
  2. Read the ADC: Your Arduino analogRead() returns 620.
  3. Convert ADC to Voltage: V_out = (620 / 1023) * 5.0V = 3.03V.
  4. Calculate the Offset: 3.03V - 2.5V (quiescent) = 0.53V. (A positive value indicates a North pole).
  5. Calculate Gauss: 0.53V / 0.0013 V/G = 407 Gauss.

Calibration and Scaling Realities

Never trust the datasheet's 'typical' quiescent voltage blindly. Manufacturing tolerances mean your specific sensor might output 2.42V instead of 2.50V with zero magnetic field. Always calibrate at startup: read the ADC 16 times with no magnets nearby, average the result, and store that as your software V_quiescent baseline. Furthermore, because these sensors are ratiometric, if your 5V USB supply drops to 4.8V, both the quiescent voltage and the sensitivity drop proportionally. If your MCU uses a fixed internal voltage reference (like the ESP32), supply sag will introduce massive calculation errors. Powering the sensor and the MCU ADC reference from the exact same rail cancels this out.

Interference, Drift, and Troubleshooting

Hall sensors are notoriously susceptible to environmental noise. If your readings are jittery or drifting, check these three common interference sources:

  • Ferrous Chassis Interference: Mounting a hall sensor directly to a steel breadboard, an iron-core solenoid, or using steel M3 screws within 10mm of the sensor face will distort the magnetic flux lines. The sensor will read the residual magnetism of the screw. Always use brass, plastic, or non-magnetic stainless steel (316 grade) for mounting hardware.
  • EMI from PWM Motor Drivers: If you are using the sensor to measure BLDC motor commutation or stepper RPM, the high dV/dt switching of the motor driver will inject noise into the sensor's output trace. Route the sensor signal using a twisted-pair cable, keep it away from motor phase wires, and place a 10nF ceramic capacitor directly between the OUT and GND pins to form a low-pass hardware filter.
  • Temperature Drift: The sensitivity of silicon hall elements drifts with temperature (typically around -0.06%/°C to -0.11%/°C). If your sensor is mounted near a hot voltage regulator or an outdoor enclosure in direct sun, a 30°C temperature swing can introduce a 3% gain error. For high-precision industrial applications, you must log the temperature and apply a software compensation curve, or use a sensor with built-in temperature compensation like the Allegro A1324.

Decision Tree: Which Hall Sensor Should You Buy?

Stop guessing based on whatever cheap multipack arrived from the overseas marketplace. Use this decision path to select the exact silicon you need for your circuit.

  • Q1: Do you need to measure continuous magnetic field strength, distance, or liquid level?
    • Yes ➔ You need an Analog Linear sensor. Proceed to Q2.
    • No, I just need to detect if a magnet is there (RPM, limit switch, door open/close) ➔ You need a Digital sensor. Proceed to Q3.
  • Q2 (Analog Path): Do you require sub-milliGauss precision for scientific measurement?
    • Yes ➔ Buy a dedicated fluxgate magnetometer or an industrial-grade sensor like the Melexis MLX90393 (I2C/SPI, 3-axis).
    • No, standard DIY/bench precision is fineDEFAULT PICK: Buy the Allegro A1302 (or Honeywell SS49E). The A1302 is the undisputed workhorse for 90% of microcontroller linear magnetic projects, offering excellent linearity and robust internal EMI filtering for under $1.50 per unit.
  • Q3 (Digital Path): Should the output turn OFF when you pull the magnet away?
    • Yes (Switch) ➔ Buy the Allegro A3144. Ideal for tachometers and limit switches.
    • No, it should stay ON until I introduce an opposite South pole (Latch) ➔ Buy the Melexis US1881. Ideal for brushless DC (BLDC) motor commutation and rotary encoders.

For further reading on optimizing analog signal chains for these sensors, review the official Arduino analog input documentation to ensure your ADC sampling rate and reference voltages are configured correctly before writing your conversion math.