A hall-effect sensor outputs either a continuous analog voltage proportional to magnetic flux density or a digital HIGH/LOW switch state. For precision measurement, an analog linear sensor (like the Honeywell SS49E or Allegro A1302) outputs a ratiometric voltage centered at VCC/2 when no magnetic field is present. To convert this to physical units, you read the ADC, convert to voltage, subtract the zero-gauss offset, and divide by the sensor's sensitivity (mV/mT). This guide covers the exact wiring, the raw-to-millitesla math, and how to filter out the EMI that ruins these readings on the bench.

The Physics: How Hall-Effect Sensing 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 practical silicon ICs, this microvolt-level signal is amplified by an internal op-amp and temperature-compensated before reaching the output pin.

Linear analog sensors output a continuous voltage that scales with the magnetic flux density (measured in Gauss or Tesla). Digital hall sensors, conversely, use an internal Schmitt trigger to snap the output to a clean logic LOW or HIGH once a specific magnetic threshold is crossed. We focus strictly on the analog variant here for continuous field measurement, as digital switches require no ADC scaling math.

Wiring Pinouts and Supply Specifications

Most through-hole linear hall-effect sensors come in a 3-pin TO-92 package. When looking at the flat face of the sensor with the leads pointing down, the standard pinout is VCC (1), Output (2), and GND (3). However, always verify with the specific datasheet, as some surface-mount (SOT-23) variants swap the GND and Output pins.

Common Analog Hall-Effect Sensor Specifications
Part Number Manufacturer Supply Range (V) Quiescent Output Sensitivity
SS49E Honeywell 4.5V - 6.0V VCC / 2 1.4 mV/Gauss (14 mV/mT)
A1302 Allegro 4.5V - 6.0V VCC / 2 1.3 mV/Gauss (13 mV/mT)
DRV5053A1 Texas Instruments 2.5V - 5.5V VCC / 2 14 mV/mT
Bench Tip: Because these sensors are ratiometric, their quiescent output and sensitivity scale directly with VCC. If you power an SS49E with a noisy USB 5V rail that sags to 4.8V under load, your zero-gauss offset shifts, introducing measurement drift. Use a dedicated 3.3V or 5.0V LDO regulator for precision work.

Output Signal Math: Raw ADC to Millitesla (mT)

Let's wire an SS49E to an Arduino Uno (ATmega328P). The Uno features a 10-bit ADC (0-1023) with a default 5.0V reference. The SS49E requires a minimum of 4.5V, so we power it directly from the Uno's 5V pin. The output pin connects to A0.

The physical unit we want is millitesla (mT). The SS49E datasheet specifies a sensitivity of 1.4 mV/Gauss. Since 10 Gauss = 1 mT, the sensitivity is 14 mV/mT (or 0.014 V/mT). The quiescent (zero-field) output is VCC/2, which equals 2.5V.

The Math Sequence:

  1. Convert ADC to Voltage: V_out = raw_adc * (5.0 / 1024.0)
  2. Find Delta Voltage: delta_V = V_out - 2.5
  3. Convert to mT: mT = delta_V / 0.014
const int sensorPin = A0;
const float vRef = 5.0;
const float adcMax = 1024.0;
const float sensitivity = 0.014; // 14 mV/mT converted to V/mT
const float zeroOffset = 2.5;    // VCC / 2

void setup() {
  Serial.begin(115200);
  analogReference(DEFAULT); // 5V on Uno
}

void loop() {
  // Average 16 reads to reduce ADC noise
  long sum = 0;
  for(int i = 0; i < 16; i++) {
    sum += analogRead(sensorPin);
    delayMicroseconds(50);
  }
  float rawAdc = sum / 16.0;
  
  float voltage = rawAdc * (vRef / adcMax);
  float deltaV = voltage - zeroOffset;
  float magneticField_mT = deltaV / sensitivity;
  
  Serial.print("Raw: "); Serial.print(rawAdc);
  Serial.print(" | V: "); Serial.print(voltage, 3);
  Serial.print(" | mT: "); Serial.println(magneticField_mT, 2);
  
  delay(100);
}
Resolution Warning: On a 10-bit ADC at 5V, one ADC step equals 4.88 mV. With a sensitivity of 14 mV/mT, your absolute best-case resolution is roughly 0.35 mT per step. If you need finer resolution, move to a 12-bit external ADC (like the ADS1115) or a 3.3V ESP32 using analogReadMilliVolts() with a sensor like the DRV5053.

Calibration, Scaling, and Interference Sources

You cannot blindly trust the theoretical 'VCC/2' zero-gauss offset. Internal op-amp offset voltages mean your sensor might output 2.48V or 2.53V in a zero-field environment. Furthermore, the Earth's magnetic field (approx. 0.05 mT) and nearby ferrous metals will skew the baseline.

Calibration Routine:

  1. Remove all magnets and magnetic tools from the workbench.
  2. Power the circuit and let the sensor thermally stabilize for 60 seconds.
  3. Read the raw ADC value 1,000 times and average it. Store this as your zeroGaussOffset.
  4. Replace the hardcoded 2.5 in the math above with your measured offset voltage.

Common Interference Sources:

  • AC Mains Wiring: 50/60Hz AC currents in nearby walls or power strips generate alternating magnetic fields. This induces a massive low-frequency ripple in high-gain analog sensors. Keep sensor leads short and use twisted-pair wiring.
  • Ferrous Workbenches: Steel bench tops or magnetic tool holders concentrate ambient flux lines, creating localized 'hot spots' that shift your zero-offset.
  • PWM Crosstalk: Running high-current PWM signals (like motor drivers or LED strips) on adjacent breadboard rows can induce voltage spikes in the high-impedance analog output trace.

Frequently Asked Questions

How to wire a 3-pin analog hall-effect sensor to an ESP32?

The ESP32 operates at 3.3V logic, but common sensors like the SS49E require 4.5V minimum. You have two choices: Power the SS49E at 5V and use a resistor voltage divider (e.g., 10kΩ and 20kΩ) on the output pin to drop the 2.5V quiescent signal down to a safe ~1.66V for the ESP32 ADC. Alternatively, buy a 3.3V-native sensor like the TI DRV5053, which you can wire directly to the ESP32's 3V3 and GND pins without level shifting.

Why is my analog hall-effect sensor reading fluctuating wildly?

Wild fluctuations are almost always caused by electromagnetic interference (EMI) or a noisy power supply. Because the internal amplifier has high gain, it will happily amplify 60Hz noise from nearby AC cables. First, ensure your VCC rail is clean (add a 0.1µF ceramic capacitor directly across the sensor's VCC and GND pins). Second, implement software oversampling—read the ADC 16 to 64 times and average the result, as shown in the code block above.

Can a hall-effect sensor measure AC current in a wire?

Yes, but not safely with a bare sensor. Current flowing through a wire generates a concentric magnetic field. By placing a linear hall sensor in a ferrous toroidal core (a flux concentrator) clamped around the wire, you can measure the field and calculate the current. However, for mains voltage (120V/230V AC), never build a DIY open-core probe. Use an isolated, potted current sensor module like the ACS712 or a split-core current transformer (CT) to maintain galvanic isolation and prevent lethal shock hazards.

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

A reed switch is a purely mechanical device consisting of two ferromagnetic metal reeds sealed in a glass tube; a magnet pulls them together to close the circuit. It draws zero standby current but suffers from mechanical bounce, slow release times, and finite lifecycle limits. A hall-effect sensor is a solid-state semiconductor device. It has no moving parts, operates at high frequencies, and can output proportional analog data rather than just an on/off state, though it requires a continuous power supply to operate its internal amplifier.