The Sensing Principle: How Linear Hall Effect Sensors Work

When a current-carrying semiconductor is placed in a magnetic field, the Lorentz force deflects the moving electrons to one side of the material. This charge accumulation creates a measurable transverse voltage perpendicular to both the current flow and the magnetic field. This phenomenon, discovered by Edwin Hall in 1879, is the foundational physics behind every hall effect sensor. In modern integrated circuits, this microvolt-level signal is amplified by on-chip op-amps and conditioned for direct microcontroller interfacing.

It is critical to distinguish between linear and digital (switch) hall effect sensors. Digital sensors (like the A3144) output a simple HIGH/LOW logic signal when a magnetic threshold is crossed, acting as a proximity switch. Linear sensors, which are the focus of this guide, output a continuous analog voltage proportional to the magnetic flux density (measured in Gauss or milliTesla). This allows you to measure not just the presence of a magnet, but its exact distance, orientation, and field strength.

Module Specifications, IC Comparison, and Wiring

Most hobbyist modules use a 3-pin breakout board containing the hall IC, a decoupling capacitor, and sometimes a pull-up resistor. Below is a data-dense comparison of the most common linear hall effect ICs you will encounter in 2026, detailing their specific electrical characteristics.

Table 1: Linear Hall Effect IC Specifications Comparison
IC Model Sensitivity (mV/G) Supply Range (V) Output Type Quiescent Current Typical Price
Honeywell SS49E 1.4 (Nominal) 2.7 to 6.5 Ratiometric Analog 6.0 mA $0.85 - $1.20
TI DRV5055A1 2.5 (Unipolar) 2.5 to 5.5 Absolute Analog 3.5 mA $0.40 - $0.65
Allegro A1324 5.0 (High Sens) 4.5 to 5.5 Ratiometric Analog 8.0 mA $1.10 - $1.50
Melexis MLX90242 Programmable 4.5 to 5.5 Ratiometric Analog 7.0 mA $1.80 - $2.50

Note: Ratiometric output means the zero-Gauss offset voltage and sensitivity scale proportionally with the supply voltage (VCC). Absolute output (like the DRV5055) maintains a fixed voltage reference regardless of minor VCC fluctuations, making it superior for battery-powered ESP32 projects where the 3.3V rail might sag.

Standard 3-Pin Module Wiring

Table 2: Wiring Pinout for ESP32 and Arduino Uno
Module Pin ESP32 DevKit Pin Arduino Uno Pin Notes & Supply Range
VCC 3.3V 5V Check IC datasheet. SS49E accepts 2.7-6.5V; A1324 requires 5V.
GND GND GND Ensure common ground with the microcontroller.
OUT (AO) GPIO 34 (ADC1_CH6) A0 Use ADC1 pins on ESP32 (GPIO 32-39) to avoid WiFi conflicts.
Callout Tip: ESP32 ADC Selection
Never use GPIO 25, 26, or 27 (ADC2) for analog sensors on the ESP32 if you plan to use WiFi. The WiFi driver takes control of ADC2, causing your hall sensor readings to drop to zero or return garbage data during network transactions. Always stick to ADC1 (GPIO 32 through 39).

Output Signal Math: Converting Raw ADC Readings to Gauss

The output of a linear magnetic sensor hall effect module is an analog voltage. To make this useful, you must convert the microcontroller's raw ADC integer (or millivolt reading) into a physical unit: Gauss (G) or milliTesla (mT). 10 Gauss = 1 milliTesla.

The fundamental transfer function for a ratiometric linear hall sensor (like the SS49E) is:

V_out = V_offset + (B * Sensitivity)

Where:

  • V_out: The measured voltage at the OUT pin.
  • V_offset: The quiescent output voltage when no magnetic field is present (typically VCC / 2).
  • B: The magnetic flux density in Gauss.
  • Sensitivity: The IC-specific slope (e.g., 1.4 mV/G for the SS49E).

Rearranging the formula to solve for the magnetic field (B):

B (Gauss) = (V_out - V_offset) / Sensitivity

Concrete Numeric Example

Assume you are powering an SS49E module with exactly 5.00V on an Arduino Uno. The zero-Gauss offset (V_offset) is nominally 2.50V. The sensitivity is 1.4 mV/G (or 0.0014 V/G).

If your multimeter measures V_out at 3.20V when a neodymium magnet is nearby:

B = (3.20V - 2.50V) / 0.0014 V/G = 0.70 / 0.0014 = 500 Gauss

Because the voltage increased above the offset, this indicates a South magnetic pole facing the branded side of the sensor. A North pole would drive the voltage below 2.50V (e.g., 1.80V would yield -500 Gauss).

Calibration and Scaling

Datasheets provide nominal values, but manufacturing tolerances mean your specific sensor's V_offset might be 2.45V instead of 2.50V. Calibration is mandatory for precision work. To calibrate, power the circuit, keep all magnets and ferrous metals away from the sensor, and read the analog pin 100 times to find the average zero-Gauss voltage. Hardcode this measured value into your software as the baseline offset.

Step-by-Step Interfacing, Code, and Interference Mitigation

Interfacing the sensor physically is straightforward, but achieving stable, noise-free readings requires managing environmental and electrical interference.

Common Interference Sources

  1. Switching Regulator EMI: The ESP32's onboard switching power supply generates high-frequency noise on the 3.3V rail. This noise couples directly into the hall sensor's analog output. Fix: Add a 100nF ceramic capacitor and a 10µF tantalum capacitor across the sensor's VCC and GND pins, as close to the IC body as possible.
  2. Temperature Drift: Hall sensors exhibit thermal drift. The SS49E, for example, has a typical sensitivity drift of -0.1%/°C and an offset drift of ±0.5 mV/°C. If your project operates in an unclimate-controlled garage, a 20°C swing can introduce a 10mV offset error (translating to ~7 Gauss of phantom reading).
  3. Ferrous Workbench Interference: Steel workbenches, screwdrivers, and even the metal shielding on some USB cables can distort the local magnetic field. Always test and calibrate your sensor on a wood or plastic surface.

ESP32 Implementation Code

The ESP32's ADC is notoriously non-linear and noisy compared to the Arduino Uno's ATmega328P. As of 2026, the modern ESP32 Arduino Core (v3.x) includes the analogReadMilliVolts() function, which uses the chip's internal eFuse calibration data to return a highly accurate millivolt reading, bypassing the raw 12-bit integer non-linearity.

The following code implements a moving average filter to smooth out residual EMI noise and calculates the field strength in Gauss.

/*
 * Linear Hall Effect Sensor (SS49E) Interfacing for ESP32
 * Uses analogReadMilliVolts() for calibrated ADC readings.
 * Board: ESP32 DevKit V1 | Core: ESP32 Arduino v3.x
 */

const int HALL_PIN = 34;       // ADC1_CH6 (GPIO 34)
const float VCC_MV = 3300.0;   // Measured VCC in millivolts (use multimeter)
const float SENSITIVITY_MV_G = 1.4; // SS49E sensitivity at 5V. 
                                    // Scale if running at 3.3V: 1.4 * (3.3/5.0) = 0.924 mV/G

// Calibration variables
float zeroGaussOffset_mV = 0.0;
const int SAMPLE_SIZE = 50;

void setup() {
  Serial.begin(115200);
  delay(1000);
  
  // Configure ADC attenuation for full 0-3.3V range
  analogSetPinAttenuation(HALL_PIN, ADC_11db);
  
  Serial.println("Calibrating Zero-Gauss Offset...");
  Serial.println("Ensure no magnets or ferrous metals are nearby!");
  delay(2000);
  
  // Auto-calibrate offset
  float sum = 0;
  for (int i = 0; i < SAMPLE_SIZE; i++) {
    sum += analogReadMilliVolts(HALL_PIN);
    delay(10);
  }
  zeroGaussOffset_mV = sum / SAMPLE_SIZE;
  
  Serial.print("Calibrated V_offset: ");
  Serial.print(zeroGaussOffset_mV);
  Serial.println(" mV");
}

void loop() {
  // Moving average filter to mitigate switching regulator EMI
  float mvSum = 0;
  for (int i = 0; i < SAMPLE_SIZE; i++) {
    mvSum += analogReadMilliVolts(HALL_PIN);
    delay(2); // Short delay for ADC settling
  }
  float vOut_mV = mvSum / SAMPLE_SIZE;
  
  // Calculate Gauss: B = (V_out - V_offset) / Sensitivity
  // Note: Adjust SENSITIVITY_MV_G based on actual VCC if ratiometric
  float gauss = (vOut_mV - zeroGaussOffset_mV) / SENSITIVITY_MV_G;
  float milliTesla = gauss / 10.0;
  
  Serial.print("V_out: ");
  Serial.print(vOut_mV, 1);
  Serial.print(" mV | Field: ");
  Serial.print(gauss, 1);
  Serial.print(" G (");
  Serial.print(milliTesla, 2);
  Serial.println(" mT)");
  
  delay(250);
}
Summary Card: Choosing the Right Sensor
Choose Ratiometric (SS49E) when your microcontroller shares a highly regulated, noise-free power supply with the sensor, as the ADC reference and sensor scale together.
Choose Absolute (DRV5055) for battery-powered IoT nodes where the supply voltage droops as the battery depletes; the internal reference ensures your Gauss calculations remain accurate even if VCC drops from 3.3V to 2.8V.

By understanding the underlying transfer function, calibrating the zero-Gauss offset in software, and mitigating high-frequency EMI with proper decoupling, a $1 linear magnetic sensor hall effect module can achieve sub-milliTesla resolution suitable for precision current sensing, joystick positioning, and non-contact linear displacement tracking.