Getting reliable magnetic field readings on a workbench comes down to matching the right hall sensor magnet with the correct semiconductor topology. Whether you are building a DIY tachometer, a linear position slider, or a brushless motor commutation circuit, treating digital switch sensors and linear analog sensors as interchangeable will ruin your data. This guide breaks down the exact physics, wiring, and raw-to-unit math you need to interface Hall effect sensors with 5V Arduino and 3.3V ESP32 microcontrollers.
The Physics: How a Hall Sensor Magnet Triggers the Effect
When a magnetic field from your hall sensor magnet passes perpendicular to a current-carrying semiconductor plate inside the IC, the Lorentz force deflects the charge carriers (electrons or holes) to one side of the plate. This physical separation of charge creates a measurable transverse voltage across the material, known as the Hall voltage. The strength of this voltage is directly proportional to the magnetic flux density—measured in Gauss or Tesla—passing through the active silicon area.
In practical terms, moving a neodymium magnet closer to a linear sensor increases the output voltage proportionally, allowing you to measure distance or field strength. Conversely, in a digital switch sensor, an internal Schmitt trigger monitors this Hall voltage and snaps the output pin to a logic LOW only when the magnetic field crosses a specific physical threshold (the operate point), ignoring everything below it.
Hardware Specs: Wiring, Pinouts, and Supply Ranges
The most common bench mistake is feeding a 5V analog sensor into a 3.3V ESP32 ADC, or expecting a digital switch to give you proportional distance readings. Here is the spec-sheet-table for the three most common ICs in maker kits:
| IC Model | Output Type | Supply Range (VCC) | Logic Compatibility | Pinout (Flat face towards you) |
|---|---|---|---|---|
| Honeywell SS49E | Analog (Ratiometric Voltage) | 2.7V to 6.5V | 5V Arduino (Uno/Mega) | 1: VCC, 2: GND, 3: VOUT |
| TI DRV5055 | Analog (Ratiometric Voltage) | 2.5V to 5.5V | 3.3V ESP32 / Raspberry Pi Pico | 1: VCC, 2: GND, 3: VOUT |
| Allegro A3144 | Digital (Open-Drain Switch) | 4.5V to 24V | 5V Arduino (Needs pull-up) | 1: VCC, 2: GND, 3: OUT |
The Math: Converting Raw ADC Readings to Gauss
Let us look at the raw-to-unit math for the classic SS49E paired with a 5V Arduino Uno (10-bit ADC). According to the Honeywell SS49E datasheet, the typical sensitivity is 1.4 mV per Gauss when powered at 5V.
Step 1: Determine ADC Resolution
The Arduino Uno's 10-bit ADC maps 0-5V to 0-1023.
Voltage per step = 5.0V / 1024 = 4.88 mV/step.
Step 2: Establish the Zero-Field Baseline
At zero magnetic field, the output is VCC / 2 = 2.5V.
Baseline ADC reading = 2.5V / 4.88 mV = 512.
Step 3: The Conversion Formula
To find the magnetic field in Gauss, subtract the baseline from your raw reading, convert that delta back to millivolts, and divide by the sensor sensitivity.
// C++ Math for SS49E on 5V Arduino
int rawADC = analogRead(A0);
float voltageDelta = (rawADC - 512) * 4.88; // in millivolts
float gauss = voltageDelta / 1.4; // 1.4 mV/G sensitivity
// For ESP32 users with a DRV5055 (3.3V, 12-bit ADC, 10mV/mT sensitivity):
// float voltageDelta = (rawADC - 2048) * 0.805; // 3.3V/4096 = 0.805mV/step
// float milliTesla = voltageDelta / 10.0; // DRV5055A1 is 10mV/mT
If your Arduino reads 600, the delta is 88 steps. 88 * 4.88 mV = 429.4 mV. Divided by 1.4 mV/G, you are measuring exactly 306 Gauss (or 30.6 mT) with the North pole facing the branded side of the sensor.
Real-World Interference and Calibration Fixes
Hall elements are notoriously susceptible to environmental noise. If your readings are jumping by ±20 Gauss while the magnet is perfectly still, you are hitting one of three common interference sources:
- High-Frequency EMI: Brushless DC motors, switching power supplies, and PWM lines emit electromagnetic noise that the high-impedance Hall plate picks up. Fix: Solder a 100nF (0.1µF) ceramic bypass capacitor directly across the VCC and GND pins of the sensor, as close to the plastic body as physically possible.
- Ferrous Metal Distortion: Mounting your sensor on a steel chassis or using steel screws near the active area will bend the magnetic flux lines away from the silicon. Fix: Use brass, nylon, or aluminum hardware within a 15mm radius of the sensor die.
- Temperature Drift: Silicon Hall elements drift by roughly 0.1% per °C. A sensor calibrated at 20°C will read slightly differently at 40°C inside an enclosure. Fix: For non-critical applications, implement a software moving average. For precision work, use a sensor with integrated temperature compensation like the TI DRV5055.
512 as your zero-field baseline in your sketch. At startup, take 100 analog readings with the magnet removed, average them, and store that value as your dynamic baseline. This accounts for minor VCC sag and resistor tolerances on your specific board.
Frequently Asked Questions
What type of hall sensor magnet works best for linear position tracking?
For linear tracking (like a throttle or suspension travel sensor), use a cylindrical or disc-shaped Neodymium magnet (grade N42 or N52) magnetized through its thickness (axial). Mount it so the pole face points directly at the branded flat side of the sensor. Avoid cheap ceramic ferrite magnets; their flux density is too weak to drive the sensor past its noise floor at useful air gaps.
Why is my hall sensor magnet reading fluctuating wildly on the ESP32?
The ESP32’s internal ADC is notoriously non-linear and noisy compared to the hardware ADC on an Arduino Uno. If your raw values are jumping ±30 steps, you are seeing ESP32 ADC noise, not magnetic fluctuation. Fix this by using the ESP32's analogReadMilliVolts() function (which applies factory Vref calibration) and oversampling in software (reading the pin 16 times and bit-shifting the result down by 2).
How far away can the hall sensor magnet be and still trigger?
Magnetic field strength from a dipole drops off at an inverse-cube law ($1/r^3$). If you double the distance between the magnet and the sensor, the field strength drops to 1/8th. A standard 10mm N52 disc magnet will reliably trigger an A3144 digital switch at about 25mm, but will only yield a few dozen Gauss of readable linear data on an SS49E at that same distance. For gaps larger than 30mm, you must use a larger magnet or add a soft-iron flux concentrator.
Can I use a linear hall sensor to measure AC or DC current?
Yes, but not by just taping it to a wire. A straight wire generates a circular magnetic field that is incredibly weak (often less than 5 Gauss at 10mm for a 10A load). To measure current with a raw Hall IC, you must pass the conductor through a toroidal ferrite core with a small air gap, and mount the sensor inside that gap to concentrate the flux. For most DIY current sensing, it is vastly easier and safer to buy an integrated Hall current sensor like the ACS712 or ACS724, which already have the core and amplifier built into the package.






