Measuring position, proximity, or current without physical contact is a staple of embedded design. While reed switches and digital Hall latches are fine for simple limit switches, capturing continuous, proportional movement requires a linear magnetic sensor chip. This guide strips away the abstract theory and gives you the exact wiring tables, raw-to-unit conversion math, and interference mitigation tactics you need to interface a linear Hall effect sensor with an ESP32 or Arduino.
How a Linear Magnetic Sensor Chip Actually Works
At the silicon level, a Hall effect sensor relies on the Lorentz force. When a constant control current flows through a thin semiconductor element, an external magnetic field perpendicular to the current deflects the moving charge carriers (electrons) to one side of the material. This charge accumulation creates a measurable transverse voltage—the Hall voltage—which is directly proportional to the magnetic flux density passing through the die.
Because the raw Hall voltage is typically in the microvolt range, a modern linear magnetic sensor chip integrates an on-die voltage regulator, a high-gain differential amplifier, and temperature compensation circuitry. Unlike digital Hall switches that snap HIGH or LOW at a specific threshold, a linear chip outputs a continuous, ratiometric analog voltage. The output sits at a quiescent midpoint (usually half the supply voltage) in a zero-gauss environment and scales linearly upward or downward as north or south magnetic poles approach the sensing face.
Selecting the Right Chip: Specs and Pinouts
Not all linear Hall sensors are created equal. Your choice dictates the supply voltage, the sensitivity (how many millivolts the output changes per Gauss), and the physical footprint. Below is a data-dense comparison of the most common bench-friendly linear chips available in 2026.
| Part Number | Manufacturer | Supply Range (V) | Sensitivity (mV/G) | Quiescent Output | Package |
|---|---|---|---|---|---|
| DRV5053A1 | Texas Instruments | 2.5 to 5.5 | 10 (Unipolar) | 0.1V to 1.8V | SOT-23 / TO-92 |
| A1324LLH | Allegro Micro | 4.5 to 5.5 | 1.3 (Bipolar) | VCC / 2 | SOT-23W |
| SS49E | Honeywell / Generic | 2.7 to 6.5 | 1.4 (Bipolar) | VCC / 2 | TO-92 |
| TLE4998S | Infineon | 4.5 to 5.5 | Programmable | VCC / 2 | SSO-3 |
Standard Wiring and Pin Mapping
Pinouts vary strictly by package type. Miswiring a SOT-23 when you are used to a TO-92 is the fastest way to short VCC to GND and brick the chip. Always verify the datasheet for your specific suffix.
| Package | Pin 1 | Pin 2 | Pin 3 | Decoupling Requirement |
|---|---|---|---|---|
| TO-92 (SS49E) | VCC (2.7-6.5V) | GND | VOUT (Analog) | 100nF ceramic across Pin 1 & 2 |
| SOT-23 (DRV5053) | VOUT (Analog) | GND | VCC (2.5-5.5V) | 100nF ceramic across Pin 3 & 2 |
Raw ADC to Gauss: The Conversion Math
The output of a linear magnetic sensor chip is an analog voltage. To make this useful in firmware, you must convert the microcontroller's raw Analog-to-Digital Converter (ADC) reading back into a physical unit: Gauss (G) or milliTesla (mT). Note that 1 mT = 10 Gauss.
The physical relationship is defined by the sensor's sensitivity ($S$) and its quiescent voltage ($V_Q$):
V_out = V_Q + (S × B)
Where B is the magnetic flux density in Gauss. If the chip is ratiometric, $V_Q$ scales with the supply voltage (e.g., $V_{CC} / 2$). If it is non-ratiometric (like the DRV5053), $V_Q$ is fixed internally regardless of minor VCC ripples.
Worked Numeric Example
Let's use the DRV5053A1 powered at 3.3V. Its sensitivity is 10 mV/G (0.010 V/G), and its quiescent output is nominally 0.1V (for the A1 variant, which measures unipolar fields from 0 to 170G). Suppose a magnet approaches and the ESP32's 12-bit ADC (0-4095 range, 3.3V reference) returns a raw value of 2170.
- ADC to Voltage: (2170 / 4095) × 3.3V = 1.746V
- Voltage to Gauss: (1.746V - 0.1V) / 0.010 V/G = 164.6 Gauss
ESP32 Arduino Implementation
The ESP32's native ADC is notoriously non-linear near the 0V and 3.3V rails. For precision magnetic sensing, use the analogReadMilliVolts() function available in modern ESP32 Arduino cores, which applies factory-stored eFuse calibration data to correct the raw reading.
// DRV5053A1 Linear Magnetic Sensor Chip Interfacing
const int SENSOR_PIN = 34; // ADC1_CH6 (GPIO 34)
const float SENSITIVITY_V_PER_G = 0.010; // 10 mV/G
const float QUIESCENT_V = 0.1; // Fixed 0.1V for DRV5053A1
void setup() {
Serial.begin(115200);
analogSetAttenuation(ADC_11db); // Full 0-3.3V range
}
void loop() {
// Read calibrated voltage directly in millivolts
int raw_mv = analogReadMilliVolts(SENSOR_PIN);
float voltage = raw_mv / 1000.0;
// Calculate Gauss
float gauss = (voltage - QUIESCENT_V) / SENSITIVITY_V_PER_G;
// Clamp noise floor
if (gauss < 0) gauss = 0;
Serial.printf("Voltage: %.3f V | Field: %.1f Gauss\n", voltage, gauss);
delay(50);
}
Calibration, Interference, and Real-World Gotchas
Datasheets assume a perfect laboratory environment. On a real workbench, a magnetic sensor chip is highly susceptible to three specific interference sources that will ruin your readings if left unaddressed.
1. Electromagnetic Interference (EMI)
Hall sensors have high-impedance internal nodes. If you route the sensor's analog output wire parallel to a stepper motor cable or a PWM-controlled heater line, the high $dI/dt$ (change in current over time) will induce a ghost voltage in the signal trace. The fix: Keep analog traces under 2 inches, use a ground plane directly beneath the signal trace, and physically separate the sensor from inductive loads. If long runs are unavoidable, use a twisted-pair cable for the VCC and GND, and shield the signal wire.
2. The Piezoresistive Effect (Mechanical Stress)
Silicon is piezoresistive—its electrical resistance changes when subjected to mechanical strain. If your PCB flexes, or if you press-fit the sensor into a tight plastic housing that warps the leads, the silicon die experiences stress. The chip interprets this strain as a change in the magnetic field, resulting in a drifting zero-point. The fix: Never place the sensor near the edge of a PCB where board flex is highest, and avoid potting compounds with high shrinkage rates that pull on the package.
3. Thermal Drift and Two-Point Calibration
Even with on-die temperature compensation, sensitivity can drift by 0.1% to 0.2% per °C. If your enclosure heats up by 30°C during operation, your 100 Gauss reading might silently shift to 95 Gauss. To fix this in software, perform a two-point calibration at runtime:
- Zero-Field Offset: Power the system on in a magnet-free zone. Average 100 ADC reads to establish your true $V_Q$ baseline, overriding the datasheet's nominal value.
- Known-Field Scaling: Introduce a reference magnet at a fixed mechanical stop. Measure the field with a calibrated commercial Gaussmeter (e.g., a AlphaLab GM2). Adjust your software sensitivity constant until the firmware output matches the physical meter.
By selecting the correct voltage-compatible chip, applying the exact ADC-to-Gauss math, and mechanically isolating the die from PCB flex, you can achieve sub-millimeter positional resolution using nothing but a 30-cent silicon chip and a neodymium magnet.






