A Hall effect sensor is a solid-state transducer that outputs a voltage or digital logic signal proportional to the magnetic flux density passing through its semiconductor die. If you need to measure proximity, position, speed, or current without physical contact, this is the component you reach for. But hooking one up to a microcontroller like an ESP32 or Arduino requires understanding whether you are dealing with a continuous analog voltage or a binary digital switch, as the wiring and code differ drastically.

The Physics: How Hall Effect Sensing Actually Works

When an electrical current flows through a semiconductor material and a magnetic field is applied perpendicular to that current, the Lorentz force deflects the charge carriers (electrons or holes) to one side of the material. This accumulation of charge creates a measurable transverse voltage difference across the conductor, known as the Hall voltage. The strength of this voltage is directly proportional to the strength of the magnetic field intersecting the sensor.

Because the raw Hall voltage is typically in the microvolt range, modern integrated circuits like the Allegro A1302 or TI DRV5055 embed the Hall element alongside internal operational amplifiers, voltage regulators, and temperature compensation circuitry. This on-chip signal conditioning boosts the microvolt signal into a clean, usable 0.5V to 4.5V analog output or a crisp digital logic pulse, making it practical for bench and industrial use.

Analog vs. Digital: Choosing the Right Output Type

The most common beginner mistake is conflating analog (linear) and digital (switch/latch) Hall sensors. They look identical—often housed in the same black 3-pin TO-92 plastic package—but their outputs behave completely differently.

Analog (Linear) Sensors

What the output is: A continuous DC voltage.
Common Parts: SS49E, A1302, DRV5055.
Use Case: Measuring distance to a magnet, current sensing, or replacing a mechanical potentiometer in a joystick. The output voltage rises or falls smoothly as the magnetic field strength changes. At zero magnetic field, the output sits at a "quiescent" midpoint (usually half the supply voltage).

Digital (Switch/Latch) Sensors

What the output is: A binary HIGH/LOW signal, usually implemented as an open-drain transistor.
Common Parts: A3144 (switch), US5881 (latch).
Use Case: RPM counting, limit switches, or door-open detection. The output snaps LOW when a magnetic pole of sufficient strength (the operate point) is detected, and releases HIGH when the field drops below the release point.

⚠️ Bench Warning: Most digital Hall sensors (like the ubiquitous A3144) feature an open-drain output. This means they can sink current to ground, but they cannot source voltage. You must use a pull-up resistor on the output pin. If you are wiring an A3144 to a 3.3V ESP32 GPIO, pull it up to 3.3V, not 5V, or you will back-feed 5V into the ESP32 pin and destroy the microcontroller.

Wiring and Pinout Reference

Almost all through-hole Hall effect sensors use the standard TO-92 package. When looking at the flat face of the sensor with the pins pointing down, the pinout is universally 1: VCC, 2: GND, 3: OUT. Below is a spec-sheet reference for the most common hobbyist and prototyping parts available in 2026.

Part Number Type Supply Range (V) Quiescent / Idle Output Typical Price (USD)
SS49E Analog Linear 2.7V – 6.5V VCC / 2 $0.35
A1302 Analog Linear 4.5V – 6.0V 2.5V (at 5V VCC) $1.40
A3144 Digital Switch 4.5V – 24.0V High-Z (Needs Pull-up) $0.20
US5881 Digital Latch 2.5V – 3.5V High-Z (Needs Pull-up) $0.60

From Raw ADC to Gauss: The Output Signal Math

Let’s interface the incredibly popular SS49E analog sensor directly to an ESP32. Because the ESP32’s ADC maxes out at 3.3V, we will power the SS49E from the ESP32’s 3.3V pin (the SS49E datasheet confirms it operates down to 2.7V).

The Calibration Variables:
At a 3.3V supply, the quiescent (zero-field) output is 3.3V / 2 = 1.65V.
The sensitivity at 5V is typically 1.4 mV/Gauss. However, sensitivity scales linearly with supply voltage. At 3.3V, the sensitivity drops to approximately 0.95 mV/Gauss (or 0.00095 V/G).

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

Here is the exact C++ implementation for the Arduino IDE, utilizing the modern analogReadMilliVolts() function to bypass the ESP32's notorious raw ADC non-linearity issues.

// Pin Definitions
const int HALL_PIN = 34; // ADC1_CH6 (GPIO 34)

// Calibration Constants for SS49E at 3.3V
const float V_QUISCENT_MV = 1650.0; // 1.65V in millivolts
const float SENSITIVITY_MV_PER_GAUSS = 0.95; 

void setup() {
  Serial.begin(115200);
  analogReadResolution(12); // Ensure 12-bit resolution (0-4095)
}

void loop() {
  // Read voltage directly in millivolts (handles ESP32 ADC calibration)
  int v_out_mv = analogReadMilliVolts(HALL_PIN); 
  
  // Calculate magnetic flux density in Gauss
  float gauss = (v_out_mv - V_QUISCENT_MV) / SENSITIVITY_MV_PER_GAUSS;
  
  // Convert Gauss to milliTesla (1 mT = 10 Gauss)
  float mT = gauss / 10.0;
  
  Serial.print("Field: ");
  Serial.print(gauss, 1);
  Serial.print(" G  |  ");
  Serial.print(mT, 2);
  Serial.println(" mT");
  
  delay(250);
}
💡 Pro Tip: Never use raw analogRead() on an ESP32 for precision analog Hall sensing. The ESP32 ADC is highly non-linear below 0.15V and above 3.1V, and varies chip-to-chip. Always use analogReadMilliVolts() with the factory-burned eFuse calibration data, or use an external I2C ADC like the ADS1115 for true 16-bit precision.

Interference, Drift, and Bench Gotchas

Hall sensors are robust, but they are not immune to environmental physics. When your readings look noisy on the serial plotter, check these common interference sources:

  • Ferrous Metal Distortion: Magnetic field lines bend toward iron and steel. If your sensor is mounted near a steel breadboard plate, iron screws, or a metal enclosure, the ambient field will be distorted, shifting your quiescent zero-point.
  • Temperature Drift: While internal compensation handles the bulk of it, sensitivity still drifts by roughly 0.1% per °C. If your sensor is mounted near a hot voltage regulator or a power MOSFET, expect a slow baseline creep as the board heats up.
  • EMI from Switching Loads: Brushless DC (BLDC) motors and buck converters generate massive high-frequency magnetic noise. Keep your Hall sensor signal wires away from motor phase wires, and use twisted-pair wiring for the sensor leads in high-EMI environments.
  • Magnet Grade and Geometry: A standard ceramic ferrite magnet will barely register on a high-sensitivity sensor at 1cm, while an N52 neodymium magnet will saturate the sensor's internal op-amp (clipping the output at 0.2V or 3.1V) from inches away. Match your magnet strength to your air-gap distance.

Frequently Asked Questions

What is a Hall effect sensor used for in brushless motors?

In BLDC motors, Hall effect sensors (usually three digital latches spaced 120° apart) are embedded in the stator to detect the physical position of the rotor's permanent magnets. The motor controller reads these digital pulses to determine exactly when to commutate (switch) the current through the stator coils, keeping the motor spinning smoothly. Without them, the controller must rely on "sensorless" back-EMF zero-crossing detection, which struggles at low RPMs.

What is the difference between a Hall effect sensor and a reed switch?

A reed switch is a mechanical device containing two ferrous metal contacts sealed in a glass tube that physically snap together when a magnet approaches. A Hall effect sensor is entirely solid-state with no moving parts. While reed switches are great for simple, low-cost, high-voltage isolation (like a door alarm), they suffer from contact bounce, mechanical fatigue, and slow release times. Hall sensors offer zero bounce, infinite lifecycle, and can output proportional analog data, making them vastly superior for precision timing and RPM counting.

How do I test if a Hall effect sensor is working with a multimeter?

Set your multimeter to DC Volts. Power the sensor (e.g., 5V to Pin 1, GND to Pin 2). For an analog sensor, probe Pin 3; you should read exactly half your supply voltage (2.5V). Bring a strong magnet close to the flat face—the voltage should smoothly rise or fall depending on the magnetic pole. For a digital open-drain sensor, you must connect a 10kΩ pull-up resistor between Pin 3 and VCC first. Probe Pin 3; it should read 5V, then drop to near 0V when the correct magnetic pole is applied.

Can a Hall effect sensor measure AC current?

Yes, but not bare. To measure AC or DC current, the current-carrying wire is passed through a ferrite toroid core. The core concentrates the magnetic field generated by the current into a small air gap where a linear Hall effect sensor is mounted. This is the exact operating principle behind popular current-sensing ICs like the Allegro ACS712 and isolated hall-effect current transducers used in solar inverters. For more on the underlying physics of these sensor topologies, refer to the Allegro Micro Hall Effect Sensor portfolio or the Espressif ADC Calibration documentation for handling the microcontroller side of the signal chain.