If you are building a brushless motor controller, an e-bike throttle, or a simple RPM counter, you need to measure magnetic fields without physical contact. The Hall effect sensor is the undisputed workhorse for these tasks, but picking the wrong variant or misunderstanding the output signal will leave you staring at nonsensical ADC readings. This guide breaks down the physics, the exact wiring, and the raw-to-unit math you need to interface these sensors with an ESP32 or Arduino.

The Physics: How Does a Hall Sensor Work?

At the silicon level, a Hall sensor 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 difference across the semiconductor, known as the Hall voltage. The strength of this voltage is directly proportional to the magnetic flux density passing through the chip.

Because the raw Hall voltage is only in the microvolt range, modern integrated Hall sensors include an on-chip differential amplifier and voltage regulator. In linear sensors, this amplified voltage scales continuously with the magnetic field strength, outputting a specific voltage per Gauss. In digital switch sensors, the amplified signal is fed into a Schmitt trigger, which snaps a digital output transistor on or off only when the magnetic field crosses a predefined threshold, providing hysteresis to prevent chatter.

Analog vs. Digital Outputs: What You Are Actually Reading

The most common bench mistake is conflating analog and digital Hall modules. They output fundamentally different signals and require entirely different microcontroller peripherals.

  • Analog (Linear) Output: This is a ratiometric voltage. For a 5V-supplied SS49E sensor, the quiescent (zero-magnetic-field) output is exactly half the supply voltage (2.5V). A south magnetic pole drives the voltage up toward 4.5V; a north pole drives it down toward 0.5V. You must read this with an Analog-to-Digital Converter (ADC).
  • Digital (Switch/Latch) Output: This is a logic-level signal. The output pin is typically an open-collector NPN transistor. It requires a pull-up resistor (often 10kΩ to VCC) and pulls the line to GND when a magnet is near. You read this with a standard digital GPIO pin using digitalRead() or hardware interrupts.
Callout Tip: Never try to measure distance or field strength with a digital sensor like the A3144. It only tells you if a magnet is present or absent. If your project requires measuring throttle position or joystick deflection, you must use a linear analog sensor.

Wiring and Pinout Reference

Below is the standard pinout and supply range for the three most common Hall sensors found in DIY electronics. Always verify the VCC range; feeding 5V into a 3.3V-rated TI DRV5053 will destroy the internal op-amp.

Sensor Type Example Part VCC Range Output Signal ESP32 Connection
Linear Analog Honeywell SS49E 2.7V - 6.5V Ratiometric Voltage GPIO 34 (ADC1)
Linear Analog TI DRV5053 2.5V - 5.5V Absolute Voltage GPIO 35 (ADC1)
Digital Switch Allegro A3144 3.8V - 24V Open-Collector (Low) GPIO 25 + 10k Pull-up

The Math: Converting Raw ADC Readings to Gauss

Let's look at the raw-to-unit math for the ubiquitous Honeywell SS49E linear sensor. To get physical units (Gauss or milliTesla), you cannot rely on raw 12-bit ADC integers (0-4095) because microcontroller ADCs—especially the ESP32's internal SAR ADC—are notoriously non-linear at the extremes. You must convert the raw reading to actual voltage first.

The SS49E has a typical sensitivity of 1.4 mV/Gauss (or 14 mV/mT) when powered at 5.0V. The zero-field quiescent voltage ($V_q$) is exactly half the supply voltage (2.5V).

The formula to find the magnetic flux density ($B$) in Gauss is:

B (Gauss) = (V_measured - V_quiescent) / Sensitivity

Worked Bench Example:
You power the SS49E with a clean 5.00V LDO. You bring a neodymium magnet near the sensor. Using the ESP32's analogReadMilliVolts() function (which applies Espressif's factory eFuse calibration), you read 2850 mV (2.85V).

  1. Convert to Volts: $V_{measured} = 2.85V$
  2. Identify Quiescent: $V_q = 2.50V$
  3. Identify Sensitivity: $S = 0.0014 V/Gauss$
  4. Calculate: $B = (2.85 - 2.50) / 0.0014 = 0.35 / 0.0014 = 250 Gauss$

If you were using a 3.3V supply instead of 5V, the sensitivity drops proportionally to ~0.924 mV/Gauss, and the quiescent voltage becomes 1.65V. Always scale your sensitivity constant to match your exact VCC.

Interference, Calibration, and Edge Cases

Hall sensors are highly susceptible to environmental noise. If your readings are jumping by ±20 Gauss while the magnet is stationary, check these three interference sources:

  1. Switching Power Supply EMI: Brushless motor ESCs and buck converters generate high-frequency magnetic noise. Keep your Hall sensor wiring at least 2 inches away from inductor coils and use twisted-pair wire for the signal and ground lines.
  2. Thermal Drift: The quiescent output voltage shifts with temperature. The SS49E drifts by roughly -1.5 mV/°C. If your sensor is mounted near a hot motor stator, your zero-point will shift. Fix: Implement a software calibration routine that reads the baseline voltage at startup before the motor spins.
  3. The Earth's Magnetic Field: The Earth generates about 0.25 to 0.65 Gauss. While negligible for a door switch, if you are building a high-resolution compass or measuring very weak fields, you must subtract the local geomagnetic baseline during calibration.
Calibration Protocol: Never hardcode 2.5V as your zero-point in software. On boot, take 50 analog readings with no magnets present, average them, and store that value as your dynamic V_quiescent variable. This accounts for minor resistor tolerances in the sensor's internal voltage divider.

Decision Tree: Which Hall Sensor Should You Buy?

Stop guessing based on whatever module came in your starter kit. Use this decision path to select the exact part number for your project.

  • IF you need to count RPM, act as a limit switch, or detect a gear tooth AND you only care about presence/absence...
    THEN you need a Digital Switch.
  • IF you need to measure throttle position, joystick deflection, or current sensing via a magnetic core AND you need proportional distance/strength...
    THEN you need a Linear Analog sensor.
  • IF you are measuring high-current DC (e.g., 50A+ battery monitor) AND require high precision without thermal drift...
    THEN skip basic analog and use an I2C/SPI isolated Hall IC (like the Melexis MLX90393).

The Final Verdict and Default Picks

For 95% of DIY microcontroller projects, here is exactly what you should buy:

For digital switching (RPM counters, bike speedometers, 3D printer endstops), buy the A3144. It costs about $0.15 per unit, operates up to 24V (making it immune to 12V/24V vehicle voltage sags), and has a sharp, chatter-free Schmitt trigger. Wire it with a 10kΩ pull-up to 3.3V and attach it to a hardware interrupt pin.

For analog linear measurement (throttles, proximity gauges, fluid level sensors), buy the SS49E. At roughly $0.80 per unit, it provides a clean, low-noise ratiometric output. Power it from a dedicated 5V LDO (like an HT7550) rather than the ESP32's noisy USB VBUS line, and use the math outlined above to extract precise Gauss readings.