At its core, a Hall effect sensor is a solid-state transducer that varies its output signal in response to a magnetic field. Unlike reed switches that rely on moving mechanical contacts, Hall sensors use semiconductor physics to detect magnetic flux density, making them immune to contact bounce, dust, and mechanical wear. Depending on the specific IC you choose, the output will be either a continuous analog voltage proportional to the field strength, or a digital binary signal that triggers at a specific magnetic threshold.
The Sensing Principle: How Hall Effect Sensors Actually Work
Discovered by Edwin Hall in 1879, the Hall effect occurs when a current-carrying conductor is placed in a perpendicular magnetic field. The Lorentz force deflects the moving charge carriers (electrons) to one side of the material, creating a measurable transverse voltage difference—the Hall voltage. In modern sensors, this microvolt-level effect is generated across a thin-film semiconductor element and immediately amplified by on-chip operational amplifiers into a usable signal.
Because the raw Hall voltage is highly temperature-dependent and extremely small, manufacturers integrate the sensing element, voltage regulator, and amplifier into a single silicon die. This results in two distinct categories of sensors: linear (analog) sensors, which output a ratiometric voltage that scales continuously with the magnetic field, and digital (switch) sensors, which feature an internal Schmitt trigger to output a clean HIGH or LOW logic level once a specific Gauss threshold is crossed.
Spec Sheet & Wiring: Linear vs. Digital Hall ICs
Conflating analog and digital Hall sensors is the most common mistake in embedded prototyping. A digital sensor like the A3144 cannot be used to measure the distance to a magnet; it only tells you if the magnet is 'close enough'. Conversely, a linear sensor like the SS49E requires an Analog-to-Digital Converter (ADC) to interpret the field strength. Below is a data-dense comparison of the most common TO-92 package Hall ICs used in microcontroller projects.
| Part Number | Type | Supply Range (VCC) | Quiescent Output | Sensitivity / Threshold | Output Stage |
|---|---|---|---|---|---|
| SS49E | Linear (Analog) | 2.7V to 6.5V | VCC / 2 (Ratiometric) | 1.4 mV/Gauss (at 5V) | Push-Pull (Voltage) |
| A1302EUA-T | Linear (Analog) | 4.5V to 6.0V | 2.5V (at 5V VCC) | 1.3 mV/Gauss | Push-Pull (Voltage) |
| A3144 | Digital (Unipolar Switch) | 4.5V to 24V | HIGH (via Pull-up) | Operate: 35G / Release: 25G | Open-Drain (NPN) |
| DRV5053 | PWM / Linear | 2.5V to 38V | 10% to 90% Duty Cycle | Duty cycle scales with field | PWM Output |
Standard TO-92 Wiring Pinout
Most through-hole Hall sensors (including the SS49E, A1302, and A3144) share the same 3-pin TO-92 footprint. When viewing the flat face of the sensor with the leads pointing downward, the pinout is:
- Pin 1 (Left): VCC (Positive Supply) — Connect to 5V or 3.3V depending on the IC's spec sheet above.
- Pin 2 (Center): GND (Ground) — Connect to microcontroller ground.
- Pin 3 (Right): OUT (Signal) — Connect to an analog input (for linear) or digital input with internal pull-up enabled (for digital open-drain).
Output Signal Math: Converting Raw ADC to Gauss
When using a linear sensor like the SS49E, the microcontroller's ADC reads a raw integer. To make this useful, you must convert that raw reading into a physical unit: Gauss (G) or Tesla (T). Note that 1 Tesla = 10,000 Gauss.
The output voltage of a ratiometric linear Hall sensor is defined by the following equation:
Vout = Vquiescent + (Sensitivity × Magnetic Field in Gauss)
Let's walk through a concrete numeric example using an SS49E powered at 5.0V and read by an Arduino Uno's 10-bit ADC (which maps 0-5V to 0-1023).
- Identify Quiescent Voltage: With no magnet present, the SS49E outputs exactly half of VCC. At 5.0V, Vquiescent = 2.5V.
- Read the ADC: You bring a neodymium magnet near the sensor. The Arduino
analogRead()returns a raw value of 665. - Convert Raw to Voltage: Vout = (665 / 1023) × 5.0V = 3.25V.
- Calculate Voltage Delta: ΔV = Vout - Vquiescent = 3.25V - 2.5V = +0.75V.
- Convert to Gauss: The SS49E sensitivity is 1.4 mV/Gauss (0.0014 V/G). Field = 0.75V / 0.0014 V/G = 535.7 Gauss.
If the magnet's opposite pole faces the sensor, the voltage drops below 2.5V, resulting in a negative Gauss value, indicating a South pole (depending on the manufacturer's polarity convention).
analogRead() math above. The ESP32's internal ADC is notoriously non-linear, particularly below 0.15V and above 3.1V, and its attenuation curves vary by pin. For precision Gauss measurements on an ESP32, either use the analogReadMilliVolts() function (available in ESP32 Arduino Core v2.0+) which applies factory-calibrated eFuse lookup tables, or bypass the internal ADC entirely and use an external I2C ADC like the ADS1115.
Real-World Interfacing: Interference, Placement, and Code
Hall effect sensors are incredibly robust, but they are not immune to environmental noise. According to Texas Instruments' sensor design guidelines, the three most common interference sources in embedded systems are:
- Electromagnetic Interference (EMI): Running AC mains wires or high-current PWM motor traces near the sensor leads will induce stray magnetic fields. Keep sensor traces short and route them away from inductive loads.
- Temperature Drift: While modern ICs have internal temperature compensation, extreme thermal gradients can still shift the quiescent voltage. If your project operates outdoors, you must sample an onboard thermistor and apply a software offset.
- The Inverse Cube Law: The magnetic field strength of a dipole magnet drops off at the cube of the distance (1/r³). Moving a magnet just 5mm further away can drop the field strength by 70%. Mechanical tolerances in your 3D-printed enclosure will drastically alter your sensor readings.
Arduino Implementation Code
Below is a complete, copy-pasteable Arduino sketch for reading an SS49E, nulling the quiescent offset on boot, and outputting the calculated magnetic field in Gauss.
// SS49E Linear Hall Effect Sensor Interfacing
// Target: Arduino Uno / Nano (5V logic, 10-bit ADC)
const int HALL_PIN = A0;
const float VCC = 5.0;
const float ADC_MAX = 1023.0;
const float SENSITIVITY = 0.0014; // 1.4 mV/Gauss in Volts
float quiescentVoltage = 0.0;
void setup() {
Serial.begin(115200);
// Calibration: Average 50 reads with no magnet present to find true quiescent voltage
long sum = 0;
for(int i = 0; i < 50; i++) {
sum += analogRead(HALL_PIN);
delay(10);
}
float avgRaw = sum / 50.0;
quiescentVoltage = (avgRaw / ADC_MAX) * VCC;
Serial.print("Calibrated Quiescent Voltage: ");
Serial.print(quiescentVoltage);
Serial.println(" V");
}
void loop() {
int rawReading = analogRead(HALL_PIN);
float vOut = (rawReading / ADC_MAX) * VCC;
// Calculate Delta V
float deltaV = vOut - quiescentVoltage;
// Convert to Gauss
float gauss = deltaV / SENSITIVITY;
// Convert to Tesla (Optional)
float tesla = gauss / 10000.0;
Serial.print("Raw: "); Serial.print(rawReading);
Serial.print(" | Voltage: "); Serial.print(vOut, 3);
Serial.print("V | Field: "); Serial.print(gauss, 1);
Serial.println(" G");
delay(100);
}
For deeper theoretical background on the Lorentz force and semiconductor Hall elements, All About Circuits provides an excellent foundational tutorial on the physics governing these ICs. When designing your final PCB, always place a 0.1µF ceramic decoupling capacitor as close to the VCC and GND pins of the Hall IC as physically possible to filter out high-frequency power rail noise.






