Hall sensors output either a digital logic level (HIGH/LOW) when a specific magnetic threshold is crossed, or a continuous analog voltage proportional to the magnetic flux density passing through the device. Choosing between the two depends entirely on whether you need simple proximity detection (like a limit switch) or continuous position measurement (like a throttle pedal).

The Hall Effect Sensing Principle

When an electrical current flows through a semiconductor and a magnetic field is applied perpendicular to that current, the Lorentz force deflects the moving charge carriers (electrons) to one side of the material. This accumulation of charge creates a measurable transverse voltage difference across the semiconductor, known as the Hall voltage. The magnitude of this voltage is directly proportional to the strength of the perpendicular magnetic field component.

Because the raw Hall voltage is typically in the microvolt range, modern integrated hall sensors package the semiconductor element alongside signal conditioning circuitry. Digital sensors (like the A3144) amplify this signal and feed it into a Schmitt trigger to produce a clean, debounced open-drain output. Analog sensors (like the SS49E) use linear operational amplifiers to scale the microvolt signal into a ratiometric voltage output centered around half the supply rail, allowing microcontrollers to measure exact field strengths.

Output Types: Digital Switches vs. Analog Linear

Conflating digital and analog hall sensors is the most common mistake in embedded projects. They require entirely different microcontroller pin configurations and code logic.

Callout: Digital vs. Analog Outputs
Digital (e.g., A3144, OHN3020): Outputs a discrete logic level. The output pin is typically an open-drain NPN transistor. It pulls the line LOW when the magnetic field exceeds the operate point (Bop), and floats (high-impedance) when the field drops below the release point (Brp). You must use a pull-up resistor.

Analog (e.g., SS49E, DRV5055): Outputs a continuous voltage. The output is a push-pull stage that actively drives the voltage up or down relative to a null point (usually VCC/2). No pull-up resistor is needed; connect directly to an ADC pin.

Wiring Pinouts and Supply Ranges

Most hobbyist hall sensors come in a 3-pin TO-92 package. When looking at the flat face of the sensor with the leads pointing down, the pins are universally 1-VCC, 2-GND, 3-OUT. However, their electrical tolerances differ significantly.

Sensor Model Pin 1 (VCC) Pin 2 (GND) Pin 3 (OUT) Supply Range Output Type
A3144 4.5V to 24V Ground Open-Drain 4.5V - 24V Digital (Needs 10k Pull-up)
SS49E 2.7V to 6.5V Ground Push-Pull 2.7V - 6.5V Analog (Ratiometric)
DRV5055 2.5V to 5.5V Ground Push-Pull 2.5V - 5.5V Analog (High Precision)

Wiring Note for 3.3V Microcontrollers (ESP32/Teensy): The classic A3144 requires a minimum of 4.5V to operate reliably. If you are using an ESP32, power the A3144 from the 5V (VIN) pin, but place the 10kΩ pull-up resistor between the OUT pin and the ESP32's 3.3V logic rail to prevent frying the GPIO. The SS49E and DRV5055 operate natively at 3.3V, making them much safer and easier for modern 3.3V logic boards.

Output Signal Math: Raw ADC to Magnetic Flux Density

To convert the raw ADC reading from an analog hall sensor into a physical unit (Gauss or milliTesla), you must account for the microcontroller's ADC resolution, the supply voltage, the sensor's null offset, and its sensitivity.

Let's calculate the magnetic field for an SS49E connected to an ESP32 powered at 3.3V. The ESP32's `analogRead()` returns a 12-bit value (0 to 4095).

  1. Convert Raw ADC to Voltage: V_out = Raw_ADC * (3.3 / 4095)
  2. Determine Null Voltage: With zero magnetic field, the SS49E outputs VCC / 2. At 3.3V, V_null = 1.65V.
  3. Apply Sensitivity: The SS49E datasheet specifies a typical sensitivity of 1.4 mV/Gauss (or 0.0014 V/G).
  4. Calculate Flux Density (B): B (Gauss) = (V_out - V_null) / 0.0014

Here is the complete, copy-pasteable C++ implementation for the ESP32:

// ESP32 Analog Hall Sensor (SS49E) Reader
const int hallPin = 34; // ADC1_CH6 (GPIO 34)
const float VCC = 3.3;
const int ADC_MAX = 4095;
const float SENSITIVITY = 0.0014; // 1.4 mV/Gauss in Volts

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

void loop() {
  int rawADC = analogRead(hallPin);
  
  // Convert raw ADC to voltage
  float vOut = rawADC * (VCC / ADC_MAX);
  
  // Calculate null voltage (ideally VCC/2)
  float vNull = VCC / 2.0;
  
  // Calculate Magnetic Field in Gauss
  float magneticField = (vOut - vNull) / SENSITIVITY;
  
  Serial.print("Raw: "); Serial.print(rawADC);
  Serial.print(" | Voltage: "); Serial.print(vOut, 3);
  Serial.print("V | Field: "); Serial.print(magneticField, 1);
  Serial.println(" Gauss");
  
  delay(100);
}

Calibration, Scaling, and Interference

The math above assumes a perfect world. In reality, the ESP32's ADC is notoriously non-linear near the 0V and 3.3V rails, and the SS49E's internal voltage divider is rarely exactly 50%. You must calibrate the null offset.

Calibration Step: Power on the circuit with no magnets nearby. Read the raw ADC value 100 times, average it, and convert that to your actual vNull. Hardcode this calibrated vNull into your sketch. For a deeper dive into Hall effect linearization, refer to the Texas Instruments DRV5055 datasheet and application notes, which detail advanced temperature compensation techniques.

Warning: Common Interference Sources
Analog hall sensors are highly susceptible to environmental noise. Watch out for:
  • Ferrous Hardware: Steel mounting screws or breadboard plates will distort the local magnetic field, shifting your null point and reducing magnet range.
  • Switching Power Supplies: A cheap 5V buck converter on your breadboard generates high-frequency EMI that couples directly into the high-impedance analog output trace. Keep the sensor at least 2 inches away from switching regulators.
  • Temperature Drift: The SS49E sensitivity drifts by roughly -0.1% per °C. If your project sits in a hot car or near a power resistor, expect a 2-5% measurement shift. Use a digital sensor if you only need a threshold trigger, as their Schmitt triggers reject thermal drift.

For comprehensive circuit design strategies regarding magnetic field sensing and EMI mitigation, the SparkFun Hall Effect Sensor Tutorial provides excellent bench-level guidance on shielding and trace routing.

Frequently Asked Questions

Why is my digital hall sensor always reading LOW on the ESP32?

This is almost always caused by a missing pull-up resistor. Digital hall sensors like the A3144 feature an open-collector (open-drain) output. They can pull the signal line to ground (LOW), but they cannot actively drive it HIGH. If you do not wire a 10kΩ resistor between the sensor's OUT pin and the ESP32's 3.3V VCC pin, the GPIO pin is left floating when no magnet is present, and the internal weak pull-up may not be strong enough to overcome leakage current, resulting in a permanent LOW or erratic reading.

Can I use an analog hall sensor to measure AC current?

Yes, but not by just taping it to a wire. To measure AC current, the hall sensor must be placed in the air gap of a ferromagnetic core (like a split-core ferrite ring) that encircles the current-carrying conductor. The core concentrates the magnetic field generated by the AC current. However, standard linear sensors like the SS49E have a bandwidth of roughly 20kHz, which is fine for 50/60Hz mains, but they lack the built-in amplification and isolation of dedicated current sensor ICs like the ACS712. If you attempt this, ensure you implement software low-pass filtering to remove high-frequency noise, as detailed in advanced magnetic sensing guides from All About Circuits.

What is the practical difference between a hall sensor and a reed switch for Arduino projects?

A reed switch is a mechanical device consisting of two ferromagnetic metal contacts sealed in a glass tube that physically touch when a magnet approaches. A hall sensor is a solid-state semiconductor. Hall sensors win in high-speed applications (like RPM counting on a motor) because they do not suffer from contact bounce and can switch thousands of times per second. Reed switches, however, have near-zero power consumption when idle and offer a much sharper, hysteresis-free physical snap-action, making them better for battery-powered door/window alarms where microamp current draw is critical.