A Hall effect sensor works by passing a bias current through a thin semiconductor plate and measuring the transverse voltage generated when a magnetic field deflects the moving charge carriers. The output is either a continuous analog voltage proportional to the magnetic flux density (measured in Gauss or milliTesla) or a discrete digital logic signal (high/low) triggered at a specific magnetic threshold. Choosing between these two output types dictates whether you need an analog-to-digital converter (ADC) or a simple GPIO interrupt on your microcontroller.
The Physics: Lorentz Force and Sensing Principle
When a current-carrying conductor—typically an n-type or p-type semiconductor like gallium arsenide or indium antimonide—is placed in a magnetic field, the Lorentz force pushes the moving charge carriers to one side of the material. This charge accumulation creates a measurable transverse voltage difference, known as the Hall voltage, which is perpendicular to both the current flow and the magnetic field lines.
Because the raw Hall voltage generated across the silicon die is usually in the microvolt range, modern integrated Hall sensors include an on-chip differential amplifier, voltage regulator, and temperature compensation circuitry. This internal signal conditioning scales the microvolt signal up to a usable level, dictating whether the final output pin delivers a ratiometric analog voltage or drives an open-drain digital transistor.
Analog vs. Digital: Spec Sheet Comparison
A common mistake on the bench is conflating analog linear sensors with digital switches. An analog sensor (like the A1302) will output 2.5V at rest and swing up toward VCC or down toward GND as a magnet approaches. A digital switch (like the A3144) acts as a solid-state relay, pulling its output pin to ground only when the magnetic field exceeds a specific threshold. Below is a data-dense comparison of common through-hole and SMT Hall ICs used in embedded projects.
| IC Model | Type | Supply Range (VCC) | Sensitivity / Trip Point | Output Stage | Typical Use Case |
|---|---|---|---|---|---|
| Allegro A1302 | Analog Linear | 4.5V to 6.0V | 1.3 mV/G (Typical) | Push-Pull Voltage | Joystick position, current sensing |
| TI DRV5053 | Analog Linear | 2.5V to 38V | 10 mV/mT to 100 mV/mT | Push-Pull Voltage | Automotive pedal travel, wide-VCC robotics |
| Allegro A3144 | Digital Switch | 3.8V to 24V | Turn-on: 35G / Turn-off: 25G | Open-Drain (NPN) | RPM tachometers, door interlocks |
| TI DRV5013 | Digital Latch | 2.5V to 5.5V | Turn-on: 3.5mT / Turn-off: -3.5mT | Open-Drain | Brushless DC motor commutation, encoders |
If you are using a digital sensor like the A3144 or DRV5013, the output transistor only sinks current to ground; it cannot drive the pin HIGH. You must enable your microcontroller's internal pull-up resistor (e.g.,
pinMode(HALL_PIN, INPUT_PULLUP); in Arduino) or wire an external 10kΩ resistor from the OUT pin to VCC. Without this, the pin will float, causing phantom triggers from ambient EMI.
Wiring Pinouts and Magnetic Interference Sources
Most standard 3-pin Hall effect sensors follow the same physical pinout when viewed from the front (flat face with the part number facing you). However, always verify against the specific datasheet, as SOT-23 surface-mount packages sometimes mirror the TO-92 through-hole layout.
| Pin Number | Function | Connection Details & Notes |
|---|---|---|
| 1 | VCC | Connect to 5V (for A1302/A3144) or 3.3V (for DRV5013). Add a 0.1µF ceramic decoupling capacitor directly across VCC and GND pins to filter high-frequency noise. |
| 2 | GND | Connect to microcontroller ground. Ensure a star-ground topology if measuring high currents to avoid ground-loop offsets. |
| 3 | OUT | Analog: Route to ADC pin (keep trace short). Digital: Route to GPIO with pull-up enabled. |
Even with perfect wiring, Hall sensors are susceptible to specific interference sources that will corrupt your readings:
- Temperature Drift: The sensitivity of the silicon die changes with temperature. The A1302 has a typical sensitivity drift of -0.02%/°C. For precision applications, log the temperature using an onboard thermistor and apply a software compensation curve.
- Mechanical Stress (Piezoresistive Effect): Bending the leads of a TO-92 package or applying torque to the PCB can physically stress the silicon die, altering its resistance and shifting the quiescent output voltage. Never bend the leads flush against the epoxy body.
- Ambient EMI: Alternating magnetic fields from nearby AC mains wiring, transformers, or brushless motors will induce noise. Twisting the sensor lead wires and using a hardware low-pass RC filter (e.g., 100Ω series resistor + 100nF capacitor to GND) on the analog output pin is mandatory in noisy environments.
Converting Raw ADC Readings to Gauss
When using an analog sensor like the Allegro A1302 with a 5V Arduino Uno (10-bit ADC), the sensor outputs a ratiometric voltage. "Ratiometric" means the quiescent (zero-field) output voltage is exactly half of the supply voltage (VCC / 2), and the sensitivity scales proportionally with VCC. This is highly advantageous because if your 5V USB rail sags to 4.8V, both the ADC reference and the sensor output drop together, canceling out the error.
Here is the exact mathematical pipeline to convert a raw 10-bit ADC integer into a physical magnetic flux density value in Gauss. According to the Allegro Micro design documentation, the A1302 has a nominal sensitivity of 1.3 mV/G (0.0013 V/G).
Step 1: Convert ADC to Voltage
With a 10-bit ADC (1024 steps) and a 5.0V reference, each step represents 4.887 mV.
V_out = ADC_Raw * (5.0 / 1023.0)
Step 2: Calculate the Voltage Delta
Subtract the quiescent voltage (2.5V at zero magnetic field) to find the voltage shift caused by the magnet.
V_delta = V_out - 2.5
Step 3: Convert Voltage Delta to Gauss
Divide the delta by the sensor's sensitivity (0.0013 V/G).
Magnetic_Field_Gauss = V_delta / 0.0013
Complete Arduino Implementation:
const int hallPin = A0;
const float vRef = 5.0;
const float adcMax = 1023.0;
const float sensitivity = 0.0013; // 1.3 mV/G for A1302
const float vQuiescent = vRef / 2.0;
void setup() {
Serial.begin(115200);
analogReference(DEFAULT); // Ensure 5V reference on 5V boards
}
void loop() {
// Read analog pin and apply a simple 16-sample rolling average to filter noise
long adcSum = 0;
for(int i = 0; i < 16; i++) {
adcSum += analogRead(hallPin);
delayMicroseconds(200);
}
float adcAvg = adcSum / 16.0;
// Math pipeline
float vOut = adcAvg * (vRef / adcMax);
float vDelta = vOut - vQuiescent;
float gauss = vDelta / sensitivity;
// Convert Gauss to milliTesla (1 mT = 10 Gauss) for SI unit display
float mT = gauss / 10.0;
Serial.print("Raw ADC: "); Serial.print(adcAvg);
Serial.print(" | Voltage: "); Serial.print(vOut, 3);
Serial.print("V | Field: "); Serial.print(gauss, 1);
Serial.print(" G ("); Serial.print(mT, 2); Serial.println(" mT)");
delay(250);
}
Manufacturing tolerances mean your A1302 might output 2.48V or 2.53V at rest instead of exactly 2.50V. Before deploying your code, power the circuit on with no magnets nearby, read the average ADC value, and calculate the exact
vQuiescent for your specific chip. Hardcode this calibrated offset into your firmware to eliminate zero-point drift. For advanced TI Hall sensor architectures, some digital ICs allow you to program the threshold offsets via I2C, bypassing software math entirely.
Understanding the distinction between a ratiometric analog output and an open-drain digital switch prevents the most common hardware integration failures. By applying the correct pull-up resistors for digital switches and executing the precise ADC-to-Gauss math for linear sensors, you can reliably measure everything from motor RPM to 100A DC current shunts.






