If you are asking what is a Hall sensor, the direct answer is that it is a magnetic transducer that outputs a voltage or digital signal proportional to the strength, polarity, and proximity of a magnetic field. Unlike reed switches that physically bounce and wear out, Hall sensors are solid-state, meaning they operate without moving parts, making them ideal for RPM counting, current sensing, and precise position tracking in embedded projects.

The Hall Effect Principle and Sensor Output Types

When an electrical current flows through a semiconductor material and a magnetic field is applied perpendicular to that current, the Lorentz force pushes the charge carriers (electrons or holes) to one side of the material. This accumulation of charge creates a measurable transverse voltage known as the Hall voltage. In raw semiconductor physics, this voltage is in the microvolt range and highly susceptible to temperature drift.

Modern Hall effect ICs solve this by integrating the sensing element with on-chip differential amplifiers, voltage regulators, and temperature compensation circuitry. This integration yields two distinct output architectures that you must never conflate in your code: digital (switch) and linear (analog). Digital sensors output a clean HIGH or LOW logic signal when the magnetic flux crosses a specific threshold, utilizing built-in hysteresis to prevent chatter. Linear sensors output a continuous, ratiometric voltage that scales proportionally with the magnetic flux density, measured in milliTesla (mT) or Gauss.

Hardware Specifications and Wiring Pinouts

Choosing the right IC depends entirely on whether you need a simple presence trigger (like a limit switch) or a continuous measurement (like a joystick or current clamp). Below is a data-dense breakdown of the most common Hall ICs used in microcontroller projects as of 2026.

Table 1: Common Hall Sensor IC Specifications
Part Number Output Type Supply Range (Vcc) Sensitivity / Threshold Typical Price (USD)
A3144 Digital (Unipolar, Open-Collector) 4.5V to 24.0V Operate: 300G / Release: 250G $0.12
SS49E Linear (Analog, Push-Pull) 2.7V to 6.5V 1.4 mV/Gauss (14 mV/mT) $0.45
DRV5053 Linear (Analog, Bidirectional) 2.5V to 5.5V Configurable (e.g., 100 mV/mT) $0.65
MLX90393 3-Axis Digital (I2C/SPI) 2.2V to 3.6V 16-bit ADC, 0.16 µT resolution $2.80

When wiring these to a 3.3V microcontroller like the ESP32, power supply matching is critical. The A3144 requires a minimum of 4.5V, meaning you must power it from the ESP32's 5V (VIN) pin, but you must use a voltage divider or logic level shifter on the output pin to avoid frying the 3.3V GPIO. The SS49E, however, can run directly from the 3.3V pin.

Table 2: ESP32 Wiring Pinout for SS49E and A3144
Sensor Pin SS49E (Linear) Connection A3144 (Digital) Connection
VCC ESP32 3V3 Pin ESP32 5V (VIN) Pin
GND ESP32 GND ESP32 GND
OUT ESP32 GPIO 34 (ADC Input) ESP32 GPIO 25 via 10kΩ Pull-Up to 3V3
⚠️ Critical Hardware Note: The A3144 features an open-collector output. It can only pull the signal line to ground; it cannot drive it high. You must wire a 10kΩ pull-up resistor between the OUT pin and the ESP32's 3.3V rail, or enable the ESP32's internal pull-up in code. Without this, the pin will float, causing erratic interrupt triggers.

Raw-to-Unit Math: Scaling Analog Signals

Reading a digital Hall sensor is trivial: it is a simple digitalRead(). But extracting physical units (mT or Gauss) from a linear sensor like the SS49E requires understanding ratiometric scaling and ADC limitations.

The SS49E is ratiometric. At zero magnetic field (quiescent state), it outputs exactly Vcc / 2. If you power it with 3.3V, the baseline is 1.65V. When a South pole approaches, the voltage increases toward Vcc; when a North pole approaches, it decreases toward 0V. The sensitivity is typically 1.4 mV/Gauss (or 14 mV/mT) per volt of supply.

The formula to convert the measured voltage to milliTesla is:

B (mT) = (V_out - V_quiescent) / (Sensitivity_mV_per_mT * Vcc)

However, the ESP32's built-in 12-bit ADC is notoriously non-linear, particularly below 0.1V and above 3.1V. Furthermore, the raw analogRead() function returns a value from 0 to 4095, which maps to an idealized 0-3.3V range that rarely matches reality due to internal voltage reference tolerances. To get accurate physical units, you must use the analogReadMilliVolts() function introduced in the ESP32 Arduino Core v2.0.0+, which applies factory-stored eFuse calibration data to return a highly accurate millivolt reading.

// ESP32 Arduino Core v2.0+ Linear Hall Sensor Math
const int HALL_PIN = 34;
const float VCC = 3.3; // Powering SS49E from 3V3 pin
const float QUIESCENT_MV = (VCC / 2.0) * 1000.0; // 1650 mV
// SS49E sensitivity is 1.4mV/Gauss at 5V. At 3.3V, it scales ratiometrically:
// (1.4 / 5.0) * 3.3 = 0.924 mV/Gauss = 9.24 mV/mT
const float SENSITIVITY_MV_PER_MT = 9.24; 

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

void loop() {
  // Read calibrated millivolts directly from ESP32 ADC
  int raw_mv = analogReadMilliVolts(HALL_PIN); 
  
  // Calculate magnetic flux density in milliTesla
  float magnetic_field_mT = (raw_mv - QUIESCENT_MV) / SENSITIVITY_MV_PER_MT;
  
  // Convert to Gauss (1 mT = 10 Gauss)
  float magnetic_field_Gauss = magnetic_field_mT * 10.0;
  
  Serial.printf("Raw: %d mV | Field: %.2f mT (%.2f Gauss)\n", 
                raw_mv, magnetic_field_mT, magnetic_field_Gauss);
  delay(100);
}

Interference, Calibration, and Bench Troubleshooting

Hall sensors are incredibly robust, but they are not immune to environmental noise. Understanding common interference sources will save you hours of debugging erratic readings on the bench.

Common Interference Sources

  • Vcc Ripple and Noise: Because linear sensors are ratiometric, any noise on your power supply directly injects noise into your signal. If you power an SS49E from a cheap buck converter with 50mV of ripple, your magnetic reading will fluctuate wildly. Fix: Place a 0.1µF ceramic capacitor as close to the sensor's VCC and GND pins as physically possible.
  • AC Mains Fields: 50/60Hz electromagnetic fields from nearby AC wiring or transformers will induce a sinusoidal wave in high-sensitivity linear sensors. Fix: Implement a software low-pass filter or average 16-32 consecutive ADC samples in your code.
  • Ferromagnetic Distortion: Mounting a Hall sensor directly to a steel chassis or using steel-core screws near the sensing face will bend and concentrate the magnetic flux lines, altering the baseline and sensitivity. Fix: Use brass, nylon, or aluminum hardware within 5mm of the sensor face.

Calibration and Edge Cases

For high-precision applications, relying on the datasheet's nominal Vcc/2 quiescent voltage is insufficient. Manufacturing tolerances mean the actual zero-point might be 1.62V or 1.68V. To calibrate, power the circuit, ensure no magnets are within a 20cm radius, and read the ADC value 100 times to establish a precise QUIESCENT_MV baseline in your code's setup routine.

Finally, be aware of the ESP32's ADC saturation limits. Even with analogReadMilliVolts(), the ESP32 ADC physically saturates around 3.1V. If you power a linear sensor at 5V, a strong South magnetic field will push the output to 4.2V, which the ESP32 will read as a flatlined ~3.1V, destroying your measurement data. Always match the sensor's Vcc to the microcontroller's native ADC reference voltage (3.3V for ESP32, 5V for Arduino Uno) or use an external I2C ADC like the ADS1115 for 5V sensor circuits.

For deeper dives into 3-axis magnetic mapping or high-resolution I2C implementations, refer to the Melexis MLX90393 datasheet or Texas Instruments' application notes on the DRV5053 linear Hall family. By respecting the electrical boundaries and applying the correct ratiometric math, Hall sensors become one of the most reliable transducers in your embedded toolkit.