How a Magnetic Hall Effect Sensor Actually Works

When a current-carrying semiconductor is placed in a magnetic field perpendicular to the current flow, the Lorentz force deflects the charge carriers to one side of the material. This charge accumulation creates a measurable transverse voltage difference known as the Hall voltage. In modern integrated circuits, this microvolt-level signal is amplified by an on-chip operational amplifier and temperature-compensated before reaching the output pin, giving us a robust signal to interface with microcontrollers.

The output signal diverges into two distinct architectures depending on the specific IC you select. Linear (analog) sensors (like the SS49E or A1302) output a ratiometric DC voltage that scales proportionally with magnetic flux density, typically centered at VCC/2 when no magnetic field is present. Digital (switch) sensors (like the A3144 or DRV5012) use an internal Schmitt trigger to output a clean logic HIGH or LOW (often open-drain) when the field crosses a specific threshold, completely ignoring the linear gradient. Conflating these two architectures is a common beginner mistake that will instantly result in nonsensical ADC readings or floating inputs on your GPIO pins.

Spec Sheet Comparison: Choosing the Right Hall IC

Before wiring anything to your breadboard, you must select the correct sensor for your application. A digital switch is useless if you need to measure the exact distance or strength of a magnet, and a linear sensor is overkill if you just need to detect whether a door is open or closed. Below is a data-dense comparison of the most common magnetic hall effect sensor ICs available in 2026.

IC Model Architecture Supply Range (V) Sensitivity Output Type Typical Price
Allegro A1302 Linear 4.5 - 5.5V 1.3 mV/mT Ratiometric Analog $0.85
Honeywell SS49E Linear 2.7 - 6.5V 1.4 mV/mT Ratiometric Analog $1.20
TI DRV5055 Linear 2.5 - 5.5V 20-100 mV/mT* Absolute Analog $0.45
Allegro A3144 Digital 3.8 - 24.0V N/A (Switch) Open-Drain Digital $0.30
Melexis MLX90393 3-Axis 2.2 - 3.6V Configurable I2C / SPI Digital $2.50

*DRV5055 sensitivity depends on the specific suffix variant (e.g., DRV5055A1 vs A4). Consult the TI Hall Effect Sensors overview for exact suffix mappings.

Callout Tip: Ratiometric vs. Absolute Output
A ratiometric sensor (A1302, SS49E) scales its output based on the supply voltage. If your 5V rail sags to 4.8V, your quiescent offset and sensitivity both drop proportionally, which can introduce errors if your microcontroller's ADC reference is tied to a different, more stable voltage. Absolute sensors (DRV5055) use an internal voltage reference, meaning their mV/mT output remains rock-solid even if the supply rail has ripple, making them vastly superior for precision measurement on noisy 5V breadboard rails.

Wiring, Pinouts, and Interference Mitigation

Physical wiring for a 3-pin analog magnetic hall effect sensor is straightforward, but the pinout trap is where most hobbyists destroy their components. Unlike standard regulators where pin 1 is universally VCC, Hall ICs vary wildly based on the manufacturer and whether you are looking at the flat face or the branded face.

Sensor Model Pin 1 (Branded Face) Pin 2 (Branded Face) Pin 3 (Branded Face) Required Decoupling
Allegro A1302 VCC GND OUT 0.1µF ceramic close to pins
Honeywell SS49E VCC OUT GND 0.1µF ceramic close to pins
TI DRV5055 VCC GND OUT 0.1µF + 10µF bulk recommended

Warning: Always verify the pinout against the specific manufacturer's datasheet. Applying 5V to the output pin of an SS49E will instantly fry the internal op-amp.

Common Interference Sources

Hall elements are inherently sensitive to environmental factors beyond just magnetic fields. If your readings are jittery or drifting, check these three culprits:

  • Electromagnetic Interference (EMI): If you are using the sensor near a brushless DC motor or high-frequency PWM switching (like a motor driver), the radiated EMI will induce noise in the sensor's high-impedance output trace. Mitigate this by adding a simple RC low-pass filter (e.g., 100Ω series resistor + 100nF capacitor to ground) on the output pin before it reaches the microcontroller ADC.
  • Temperature Drift: The Hall coefficient is temperature-dependent. While modern ICs include on-chip compensation, extreme thermal gradients (like mounting the sensor directly next to a power MOSFET heatsink) will still cause the quiescent voltage to drift. For high-precision applications across wide temperature ranges, use a digital I2C sensor like the MLX90393 which allows you to read the die temperature and apply software compensation.
  • Mechanical Stress: Silicon exhibits piezoresistive properties. If you bend the PCB, overtighten a mounting screw near the sensor, or apply stress to the leads during soldering, the physical strain on the silicon die will mimic a magnetic field, causing a permanent offset error. Mount the sensor on a rigid, stress-relieved section of your board.

Raw ADC to MilliTesla: The Conversion Math and Calibration

To convert the raw analog voltage into a meaningful physical unit (milliTesla, mT), we must account for the sensor's quiescent voltage (the output when no magnet is present) and its specific sensitivity. For the Honeywell SS49E powered at 3.3V, the quiescent voltage is VCC/2 (1.65V or 1650mV), and the sensitivity is 1.4 mV/mT.

The core mathematical formula is:

B (mT) = (V_out - V_quiescent) / Sensitivity

If your microcontroller reads an output voltage of 1850mV, the delta is 200mV. Dividing 200mV by 1.4 mV/mT yields a magnetic flux density of 142.8 mT. A negative delta simply indicates the magnetic field is of opposite polarity (South pole instead of North pole).

ESP32 ADC Non-Linearity Warning
Never use the raw analogRead() function on an ESP32 and multiply by 3.3/4095. The ESP32's internal SAR ADC is notoriously non-linear, particularly below 100mV and above 3.0V. Instead, always use the analogReadMilliVolts() function provided in the ESP32 Arduino Core v2.x and later. This function utilizes the factory-stored eFuse calibration data to return a highly accurate millivolt reading, completely bypassing the raw ADC curve errors. See the official Espressif ADC documentation for implementation details.

Complete Calibration and Reading Code (ESP32)

The following code automatically calibrates the quiescent offset on startup (ensuring you don't have to hardcode 1650mV, which varies slightly per IC) and outputs the field strength in mT.

// Magnetic Hall Effect Sensor (SS49E) Interfacing for ESP32
// Uses analogReadMilliVolts() for hardware-calibrated accuracy

const int HALL_PIN = 34;       // ADC1_CH6 (GPIO 34)
const float SENSITIVITY = 1.4; // mV/mT for SS49E

float quiescent_mV = 0.0;

void setup() {
  Serial.begin(115200);
  analogReadResolution(12); // Ensure 12-bit resolution (0-4095)
  
  // Calibration Phase: Average 100 readings with NO magnet present
  Serial.println("Calibrating... Keep magnets away!");
  long sum = 0;
  for (int i = 0; i < 100; i++) {
    sum += analogReadMilliVolts(HALL_PIN);
    delay(10);
  }
  quiescent_mV = sum / 100.0;
  Serial.print("Calibrated Quiescent Voltage: ");
  Serial.print(quiescent_mV);
  Serial.println(" mV");
}

void loop() {
  // Read the actual voltage in millivolts using eFuse calibration
  int raw_mV = analogReadMilliVolts(HALL_PIN);
  
  // Calculate delta from the calibrated zero-point
  float delta_mV = raw_mV - quiescent_mV;
  
  // Convert to milliTesla (mT)
  float magnetic_field_mT = delta_mV / SENSITIVITY;
  
  // Optional: Convert mT to Gauss (1 mT = 10 Gauss)
  float magnetic_field_G = magnetic_field_mT * 10.0;
  
  Serial.print("Field: ");
  Serial.print(magnetic_field_mT, 2);
  Serial.print(" mT | ");
  Serial.print(magnetic_field_G, 1);
  Serial.println(" Gauss");
  
  delay(100); // 10Hz sample rate
}

By combining the correct IC selection, strict attention to pinout orientation, and hardware-calibrated ADC math, you can achieve laboratory-grade magnetic field measurements on a standard hobbyist workbench. For deeper architectural details on linear sensor arrays, refer to the Allegro MicroSystems linear sensor application notes.