The Sensing Principle: How Analog Hall Sensors Work

When a current-carrying semiconductor (typically indium antimonide or gallium arsenide) is placed in a magnetic field, the Lorentz force deflects the moving charge carriers to one side of the material. This accumulation of charge creates a transverse voltage potential known as the Hall voltage. The strength of this voltage is directly proportional to the magnetic flux density passing perpendicular to the sensor die.

Unlike digital Hall switches (such as the ubiquitous A3144) that simply snap HIGH or LOW at a fixed magnetic threshold, an analog hall effect sensor (like the Honeywell SS49E or TI DRV5055) outputs a continuous, ratiometric voltage. This voltage scales linearly with both the strength and polarity of the magnetic field, allowing your microcontroller to measure exact flux density in Gauss or milliTesla, rather than just detecting presence or absence.

Hardware Pinout and Wiring to ESP32/Arduino

Analog Hall sensors are incredibly simple to wire, but power supply selection is critical because the output is ratiometric to VCC. If your supply voltage sags or ripples, your magnetic readings will ripple with it. Below is the standard pinout for the widely available 3-pin SS49E and DRV5055 linear sensors.

Table 1: Analog Hall Sensor Pinout and Specifications
Pin Number Function ESP32 (3.3V) Connection Arduino Uno (5V) Connection Notes
1 VCC (Supply) 3V3 5V Supply range is typically 2.7V to 6.5V. Keep it clean.
2 GND (Ground) GND GND Must share a common ground with the microcontroller.
3 VOUT (Output) GPIO 34 (ADC1_CH6) A0 Analog output. Do not use ADC2 pins on ESP32 if WiFi is active.
Bench Tip: Always place a 0.1µF ceramic decoupling capacitor directly across the VCC and GND pins of the sensor, as close to the plastic package as possible. This shunts high-frequency switching noise before it modulates your Hall voltage.

Wiring Steps for ESP32 DevKit V1

  1. De-energize the board: Disconnect the ESP32 from USB or external power before making breadboard connections.
  2. Seat the sensor: Place the SS49E across the breadboard center trench. Note the flat face (where the magnetic field is measured) and the beveled edge (where the text is printed).
  3. Wire Power: Connect Pin 1 to the ESP32 3V3 rail. Connect Pin 2 to the GND rail.
  4. Add Decoupling: Insert a 0.1µF capacitor between the VCC and GND rails adjacent to the sensor.
  5. Wire Signal: Connect Pin 3 (VOUT) to ESP32 GPIO 34. (GPIO 34 is an input-only pin with a dedicated ADC1 channel, avoiding the WiFi conflicts of ADC2).
  6. Verify: Use a multimeter to check that 3.3V is present at Pin 1 and that Pin 3 reads approximately 1.65V with no magnets nearby.

From Raw ADC to Gauss: The Output Signal Math

The output of an analog hall effect sensor is a ratiometric analog voltage. At zero magnetic flux (no magnet present), the sensor outputs exactly half of its supply voltage. This is your zero-gauss offset. As a magnetic field approaches the marked face, the voltage increases; as the opposite pole approaches, it decreases.

The Calibration and Scaling Formula

To convert the ESP32's raw 12-bit ADC reading (0–4095) into physical units (Gauss), you must account for the ADC reference voltage and the sensor's sensitivity. Here is the exact math for an SS49E powered at 3.3V.

1. Calculate the actual voltage:
V_out = (ADC_raw / 4095.0) * 3.3

2. Determine the Zero-Gauss Offset:
Because the output is ratiometric, the offset is VCC / 2. At 3.3V, V_offset = 1.65V.

3. Adjust Sensitivity for Supply Voltage:
This is where most hobbyists fail. The datasheet lists the SS49E sensitivity as 1.4 mV/Gauss at 5.0V. Because the sensor is ratiometric, sensitivity scales linearly with VCC. At 3.3V, your new sensitivity is:
Sensitivity_3V3 = 1.4 * (3.3 / 5.0) = 0.924 mV/Gauss (or 0.000924 V/Gauss).

4. Final Gauss Calculation:
Gauss = (V_out - 1.65) / 0.000924

If you want to read in milliTesla (mT) instead, simply divide the Gauss value by 10 (since 1 mT = 10 Gauss). For a deeper look into how different Hall IC architectures handle this scaling, Texas Instruments' DRV5055 datasheet provides excellent graphs on ratiometric error margins across temperature.

Real-World Interference and Debugging

Analog Hall sensors are essentially high-gain magnetic antennas. If your readings are jittery or drifting, you are likely picking up environmental interference. Here are the primary culprits and how to fix them.

Warning: ESP32 ADC Non-Linearity
The ESP32's internal ADC is notoriously non-linear at the extreme ends of its range (below 0.15V and above 3.15V). Because a 3.3V-powered analog Hall sensor idles at 1.65V, you have roughly 1.45V of linear swing in either direction. If you use a stronger magnet that drives the output to 3.2V, your Gauss calculations will become highly inaccurate. Keep your expected magnetic field within ±1500 Gauss to stay in the ADC's linear sweet spot.
  • 50/60Hz Mains Hum: If your sensor is near AC wiring or a transformer, the alternating magnetic field will induce a 50Hz or 60Hz ripple on your analog output. Fix: Implement a software low-pass filter (e.g., an exponential moving average) or sample at a multiple of the AC frequency and average the results.
  • PWM Motor Noise: Brushed DC motors and stepper drivers generate massive, high-frequency magnetic spikes. Fix: Physically separate the sensor from the motor by at least 50mm, and use twisted-pair wire for the sensor leads if they must run parallel to motor cables.
  • Ferrous Metal Distortion: Steel screws, breadboard plates, and iron enclosures bend magnetic flux lines. A magnet 10mm from the sensor might read differently if you slide a steel ruler under the breadboard. Fix: Mount the sensor in a plastic or aluminum enclosure, keeping ferrous metals out of the immediate flux path.
  • Temperature Drift: Hall elements drift with temperature (typically around -0.06%/°C for silicon-based sensors). Fix: For precision applications, read an onboard thermistor (if your IC has one, like the advanced TI DRV5057) or apply a software temperature compensation curve.

Frequently Asked Questions

How Do I Wire an Analog Hall Effect Sensor to a 5V Arduino Uno?

The wiring is identical to the ESP32 setup, but you connect Pin 1 (VCC) to the Arduino's 5V pin, Pin 2 to GND, and Pin 3 (VOUT) to A0. Because the supply is 5V, the zero-gauss offset becomes 2.5V, and you use the datasheet's baseline sensitivity (e.g., 1.4 mV/Gauss for the SS49E) without needing to scale it down. The math becomes: Gauss = ( (AnalogRead / 1023.0 * 5.0) - 2.5 ) / 0.0014.

What Is the Difference Between an Analog Hall Effect Sensor and a Digital Switch?

A digital Hall switch (like the A3144 or US1881) contains an internal Schmitt trigger and an open-drain NPN transistor. It outputs a hard 0V or VCC digital signal only when the magnetic field crosses a specific "operate point" threshold, and it stays on until the field drops below a lower "release point" (hysteresis). An analog hall effect sensor lacks this internal comparator; it outputs a continuous voltage that rises and falls smoothly with the magnetic field, requiring the microcontroller's ADC to interpret the value.

Can an Analog Hall Effect Sensor Accurately Measure Magnet Distance?

Technically yes, but practically it is very difficult. Magnetic flux density follows an inverse-cube law relative to distance for a dipole magnet. This means the voltage drops off extremely fast as you move the magnet away, giving you high resolution at close range (1-5mm) but almost no resolution beyond 20mm. Furthermore, the reading is highly dependent on the exact magnet grade (N42 vs N52) and orientation. For non-contact distance measurement over ranges greater than 10mm, a time-of-flight (ToF) optical sensor or an inductive proximity sensor is a much more reliable choice.