The Sensing Principle: How Hall Effects Sensors Actually Work
When a current-carrying conductor is placed in a magnetic field, the Lorentz force pushes the charge carriers to one side of the material. This creates a measurable transverse voltage known as the Hall voltage. In practical hall effects sensors, a thin semiconductor element (typically indium antimonide or gallium arsenide) acts as this conductor, optimized for maximum charge carrier mobility.
The magnitude of this voltage is directly proportional to the strength of the magnetic field passing perpendicularly through the element. Modern ICs amplify this microvolt-level signal on-chip, giving you a robust output. The polarity of the field (North vs. South) dictates the direction of the voltage shift, which is why linear sensors can detect both attraction and repulsion, while digital switches can be configured to trigger on specific poles.
Analog vs. Digital Output: What You Are Actually Reading
The most common mistake makers make is conflating linear (analog) and switch (digital) hall sensors. They look identical—usually in the same TO-92 or SOT-23-3 package—but their internal circuitry and output signals are entirely different.
- Linear (Analog) Output: Outputs a continuous voltage proportional to the magnetic flux density. At zero magnetic field, the output sits at a quiescent baseline (usually VCC/2). As a North pole approaches, the voltage rises; as a South pole approaches, it falls. You must read this with a microcontroller's ADC (Analog-to-Digital Converter).
- Digital (Switch/Latch) Output: Outputs a binary signal. Internally, it uses a Schmitt trigger to provide hysteresis, preventing rapid toggling when the magnet is at the threshold. The output is typically an open-drain N-MOSFET, meaning it can only pull the line to GND (Logic LOW) and requires an external or internal pull-up resistor to read a Logic HIGH.
Wiring and Pinout Reference
Most through-hole hall sensors in the TO-92 package share a standard pinout when viewed from the front (flat side facing you, leads pointing down): Pin 1 is VCC, Pin 2 is GND, and Pin 3 is OUT. However, supply voltages and output types vary drastically. Below is the spec-sheet reference for the three most common hobbyist and industrial parts.
| Part Number | Type | Supply Range (VCC) | Output Type | Quiescent / Idle State | Approx. Cost (1pc) |
|---|---|---|---|---|---|
| SS49E (Honeywell) | Linear | 2.7V to 6.5V | Analog Voltage (Push-Pull) | VCC / 2 | $0.15 |
| DRV5055 (Texas Instruments) | Linear | 2.5V to 5.5V | Analog Voltage (Push-Pull) | VCC / 2 | $0.35 |
| A3144 (Allegro) | Digital Switch | 4.5V to 24V | Open-Drain (Needs Pull-up) | HIGH (via pull-up) | $0.10 |
| US1881 (Melexis) | Digital Latch | 3.5V to 24V | Open-Drain (Needs Pull-up) | Latches last state | $0.25 |
For 3.3V microcontrollers like the ESP32 or Raspberry Pi Pico, the SS49E and DRV5055 are ideal because they operate natively at 3.3V, keeping the analog output safely within the microcontroller's ADC limits without needing a voltage divider. The A3144 requires a minimum of 4.5V, meaning you must power it from the 5V pin and use a level shifter or voltage divider on the output pin if your microcontroller GPIO is not 5V-tolerant.
The Math: Converting Raw ADC Readings to Gauss
Let's interface the SS49E with an ESP32 running at 3.3V. The goal is to convert the raw 12-bit ADC reading into a physical unit (Gauss).
1. Determine the Sensor Parameters at 3.3V
Hall sensors are ratiometric. The SS49E datasheet specifies a sensitivity of 1.4 mV/Gauss at a 5.0V supply. At 3.3V, we scale this proportionally:
- Sensitivity: 1.4 * (3.3 / 5.0) = 0.924 mV/Gauss (or 0.000924 V/G)
- Quiescent Voltage (0 Gauss): 3.3V / 2 = 1.65V
2. The Conversion Formula
First, convert the raw ADC value to voltage. Then, subtract the quiescent baseline to find the delta voltage caused by the magnetic field. Finally, divide by the sensitivity.
Voltage = (ADC_Raw / 4095.0) * 3.3
Delta_V = Voltage - 1.65
Gauss = Delta_V / 0.000924
analogReadMilliVolts() instead of analogRead(). This function utilizes the factory-calibrated eFuse data on the ESP32 to return a highly accurate millivolt reading, bypassing the raw ADC math entirely.
3. Complete ESP32 Calibration and Reading Code
// SS49E Linear Hall Sensor on ESP32 (Arduino Core v2.0+)
const int HALL_PIN = 34; // ADC1_CH6 (GPIO 34)
// Sensitivity in mV/G at 3.3V supply
const float SENSITIVITY_MV_G = 0.924;
float zeroG_baseline_mV = 1650.0; // Default 1.65V in mV
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution (0-4095)
// CALIBRATION: Read baseline with NO magnets nearby
Serial.println("Calibrating zero-G baseline... keep magnets away!");
delay(1000);
long sum = 0;
for(int i = 0; i < 100; i++) {
sum += analogReadMilliVolts(HALL_PIN);
delay(10);
}
zeroG_baseline_mV = sum / 100.0;
Serial.printf("Baseline calibrated: %.1f mV\n", zeroG_baseline_mV);
}
void loop() {
int reading_mV = analogReadMilliVolts(HALL_PIN);
// Calculate delta from baseline
float delta_mV = reading_mV - zeroG_baseline_mV;
// Convert to Gauss
float gauss = delta_mV / SENSITIVITY_MV_G;
// 100 Gauss = 10 milliTesla (mT)
float milliTesla = gauss / 10.0;
Serial.printf("Field: %6.1f Gauss | %5.2f mT\n", gauss, milliTesla);
delay(100);
}
Interference, Calibration, and Real-World Gotchas
When moving from the workbench to a permanent installation, hall effects sensors are susceptible to specific environmental failures. Understanding these will save you hours of debugging.
- Ferrous Metal Distortion: Magnetic flux lines seek the path of least reluctance. If you mount your sensor on a steel breadboard plate, inside a steel project box, or near iron screws, the metal will 'pull' the flux lines away from the sensor element. This alters your baseline and reduces sensitivity. Fix: Mount hall sensors on plastic, wood, or aluminum enclosures.
- EMI from PWM and Stepper Motors: Hall sensors are essentially high-gain amplifiers. Routing the analog output wire parallel to a stepper motor cable or a high-frequency PWM line will induce noise, resulting in a jittery ADC reading. Fix: Use shielded twisted-pair cable for the analog output, and place a 100nF ceramic capacitor directly across the VCC and GND pins of the sensor.
- Temperature Drift: The sensitivity and quiescent voltage drift with temperature (typically ~0.06% per °C for the SS49E). If your sensor is mounted near a hot voltage regulator or outdoors, your zero-G baseline will shift. Fix: For high-precision applications, use a sensor with integrated temperature compensation like the TI DRV5055, or implement software temperature compensation using a co-located thermistor.
Decision Tree: Which Hall Sensor Should You Buy?
Stop guessing which part to add to your cart. Use this decision path to select the exact right component for your embedded project.
| Your Application Goal | Required Output | Recommended Part Number | Why This Part Wins |
|---|---|---|---|
| Measuring exact magnetic field strength, building a custom joystick, or liquid level sensing via float magnet. | Linear (Analog) | SS49E | Cheap, 3.3V native, ratiometric, massive community support. |
| High-precision current sensing (e.g., measuring DC amps through a busbar) or industrial throttle. | Linear (Analog) | DRV5055 | Superior temperature stability, lower noise floor, precise factory trimming. |
| RPM counting, bicycle speedometer, or detecting if a door is open/closed. | Digital Switch | A3144 | High voltage tolerance (up to 24V), sharp Schmitt trigger, dirt cheap. |
| Brushless DC (BLDC) motor commutation or counting rotations where the magnet passes and stops. | Digital Latch | US1881 | Latches state on alternating poles; prevents double-counting when a magnet halts over the sensor. |
The Default Recommendation
If you are stocking your lab for general-purpose Arduino and ESP32 prototyping, buy a bulk pack of the SS49E. It operates natively at 3.3V without level shifters, requires no pull-up resistors, and provides both proximity and polarity data. At roughly $0.15 per unit, it is the most versatile magnetic sensor in the hobbyist toolkit. Keep a few A3144s on hand strictly for 5V/12V digital limit-switch applications.






