The Sensing Principle: How a Magnetic Sensor IC Actually Works
At the core of every Hall effect magnetic sensor IC is a thin piece of semiconductor material carrying a constant current. When a magnetic field passes perpendicular to this current, the Lorentz force deflects the charge carriers to one side of the material. This accumulation of charge creates a measurable transverse voltage—the Hall voltage—which is directly proportional to the magnetic flux density (measured in Gauss or Tesla).
However, a raw Hall plate produces only microvolts, which is useless for a microcontroller. A modern magnetic sensor IC integrates this Hall plate with a differential amplifier, a voltage regulator, and sometimes an onboard ADC or Schmitt trigger. This internal integration is what allows you to power the chip directly from a 3.3V or 5V rail and read a clean, amplified signal without designing external op-amp circuits.
Analog vs. Digital Outputs: What You Are Actually Reading
The most common mistake makers make is conflating analog and digital magnetic sensors. They look identical (usually 3-pin TO-92 packages), but their outputs behave completely differently.
- Analog (Linear) Output: The sensor outputs a continuous voltage that scales with the magnetic field strength. At zero magnetic field, the output sits at exactly half of the supply voltage (VCC/2). As a north pole approaches, the voltage rises; as a south pole approaches, it falls. You must read this with an ADC pin.
- Digital (Switch/Latch) Output: The sensor acts as a transistor switch. It outputs a hard VCC (HIGH) or GND (LOW) based on internal thresholds. A unipolar switch (like the A3144) turns ON when a strong south pole is near and OFF when it is removed. A latch (like the SS41) turns ON with a south pole and stays ON until a north pole is applied. You read this with a standard digital GPIO or interrupt pin.
Rule of thumb: Never feed a digital switch into an ADC expecting a gradient, and never expect an analog linear sensor to drive a hardware interrupt cleanly without software debouncing.
Wiring and Pinout: Supply Ranges and Signal Routing
Most 3-pin magnetic sensor ICs share the same standard pinout when viewed from the front (flat face with text facing you): Pin 1 is VCC, Pin 2 is GND, and Pin 3 is OUT. Below is a spec-sheet-table comparing the two most common variants.
| Parameter | SS49E (Linear / Analog) | A3144 (Unipolar Switch / Digital) |
|---|---|---|
| Supply Range (VCC) | 2.7V to 6.5V | 3.8V to 24V |
| Output Type | Analog Voltage (VCC/2 at 0G) | Open-Collector Digital (Needs Pull-up) |
| Quiescent Current | ~6 mA | ~4 mA |
| ESP32 Compatibility | Native 3.3V operation | Requires 5V supply + level shifting or 3.3V pull-up |
Wiring the SS49E to an ESP32 (Native 3.3V)
- Power: Connect ESP32 3V3 pin to SS49E Pin 1 (VCC). Do not use 5V, or the output will exceed the ESP32's 3.3V ADC limit and risk damaging the GPIO.
- Ground: Connect ESP32 GND to SS49E Pin 2 (GND).
- Signal: Connect SS49E Pin 3 (OUT) to ESP32 GPIO 34 (an input-only ADC pin).
- Decoupling: Solder a 0.1µF ceramic capacitor directly across Pin 1 and Pin 2 to filter high-frequency noise.
Output Signal Math: Converting Raw ADC to Gauss
To turn a raw 12-bit ADC reading into a physical unit (Gauss), you must account for the supply voltage. The SS49E datasheet specifies a sensitivity of 1.4 mV/Gauss at a 5.0V supply. Because sensitivity scales linearly with VCC, running it at 3.3V changes the math:
- Scaled Sensitivity: 1.4 mV/G × (3.3V / 5.0V) = 0.924 mV/Gauss (or 0.000924 V/G).
- Null Voltage (0 Gauss): 3.3V / 2 = 1.65V.
The ESP32's internal ADC is notoriously non-linear at the voltage rails. Readings below 0.15V and above 3.1V are highly inaccurate. Because our null voltage is 1.65V, we have roughly 1.45V of clean headroom in both directions. This limits our reliable measurement range to roughly ±1500 Gauss, which is plenty for neodymium magnets at a distance but will saturate if the magnet touches the sensor.
Here is the exact C++ code to read the sensor and apply the math, including a startup calibration step:
#define SENSOR_PIN 34
#define VCC 3.3
#define ADC_MAX 4095.0
#define SENSITIVITY 0.000924 // Volts per Gauss at 3.3V
float zeroGaussVoltage = 1.65; // Default theoretical null
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution (0-4095)
// Calibration: Read baseline with NO magnets nearby
float sum = 0;
for(int i=0; i<100; i++) {
sum += analogRead(SENSOR_PIN);
delay(5);
}
float rawAvg = sum / 100.0;
zeroGaussVoltage = (rawAvg / ADC_MAX) * VCC;
Serial.print("Calibrated 0G Voltage: ");
Serial.println(zeroGaussVoltage);
}
void loop() {
int rawADC = analogRead(SENSOR_PIN);
float voltage = (rawADC / ADC_MAX) * VCC;
// Calculate delta from the calibrated zero point
float deltaV = voltage - zeroGaussVoltage;
// Convert to Gauss
float gauss = deltaV / SENSITIVITY;
Serial.print("Raw: "); Serial.print(rawADC);
Serial.print(" | Voltage: "); Serial.print(voltage, 3);
Serial.print("V | Field: "); Serial.print(gauss, 1);
Serial.println(" Gauss");
delay(100);
}
Interference, Calibration, and Edge Cases
Magnetic sensors are incredibly susceptible to environmental noise. If your serial plotter looks like a fuzzy mess, check for these common interference sources:
- AC Mains Wiring: 50/60Hz alternating current in nearby wall wires or power strips will induce a 50/60Hz ripple on your analog output. Fix: Implement a software moving-average filter or increase your hardware decoupling capacitor to 1µF.
- Steel Workbenches: Ferrous metals near the sensor will distort the magnetic field lines of your test magnet, causing non-linear readings. Keep the sensor at least 6 inches away from large steel masses.
- Temperature Drift: The null voltage (VCC/2) drifts by roughly 0.06% per °C. If your garage temperature swings from 10°C to 30°C, your zero-point will shift. Fix: Always run the calibration routine in your
setup()loop upon power-up, rather than hardcoding 1.65V.
For advanced ESP32 ADC calibration, consider using the esp_adc_cal library to apply factory-stored eFuse calibration values, which significantly flattens the non-linearity at the voltage rails.
Decision Tree: Which Magnetic Sensor IC Should You Buy?
Use this decision path to select the correct part for your specific application.
| If your project requires... | Then you need this output type... | Buy this exact part number |
|---|---|---|
| Measuring fluid level via float magnet, mapping magnetic field strength, or building a DIY Gaussmeter. | Analog (Linear) | SS49E (or DRV5055) |
| Counting RPM on a motor shaft, building an anemometer, or detecting a door open/close state. | Digital (Unipolar Switch) | A3144 (or US5881) |
| Detecting the passing of alternating north/south poles on a rotor ring (like a BLDC motor). | Digital (Bipolar Latch) | SS41 (or DRV5023) |
The Default Recommendation
If you are prototyping a new embedded system, learning about sensor scaling, or just want to visualize magnetic fields on a serial plotter, buy the SS49E. It costs roughly $0.30 in bulk, operates natively on the ESP32's 3.3V logic without requiring level shifters or pull-up resistors, and provides continuous data that is far more useful for debugging than a simple HIGH/LOW switch. Grab a pack of five, a 0.1µF capacitor kit, and a few N52 neodymium magnets, and you have everything needed to master magnetic sensing.






