A standard analog hall sensor diagram requires exactly three connections: VCC, GND, and an analog output pin. Unlike simple digital Hall switches that snap high or low when a magnet passes, linear Hall sensors output a continuous, ratiometric DC voltage that scales proportionally with magnetic flux density. This makes them ideal for measuring proximity, current sensing, and joystick positioning, but it also means you must handle raw ADC math and power supply noise to get usable data.
The Physics: How a Hall Effect Sensor Actually Works
When a constant current flows through a thin semiconductor plate and a magnetic field passes perpendicular to it, the Lorentz force deflects the moving charge carriers to one side of the material. This charge accumulation creates a measurable transverse voltage—the Hall voltage—which is strictly proportional to the magnetic flux density (measured in Gauss or Tesla). The stronger the magnetic field, the higher the transverse voltage.
In practical silicon devices like the Allegro A1302 or TI DRV5055, internal chopper-stabilized amplifiers boost this microvolt-level Hall voltage into a usable 0.5V to 4.5V analog signal. Because the internal amplifier references the supply rail, the output is ratiometric to VCC. This means your zero-field baseline and your sensitivity scale directly with your power supply voltage, a critical detail that dictates how you wire and filter your circuit.
Hall Sensor Diagram and Component Selection
Before wiring, you must select the right sensor for your magnetic range. Digital Hall sensors (like the A3144) are useless for measuring field strength; you need a linear analog device. Below is the standard 3-pin wiring diagram mapping, followed by a spec-sheet comparison of the most common linear Hall ICs on the market.
- Pin 1 (Left): VCC (Supply Voltage)
- Pin 2 (Center): GND (Ground)
- Pin 3 (Right): OUT (Analog Signal)
| Part Number | Output Type | Supply Range (VCC) | Sensitivity | Magnetic Range | Best Use Case |
|---|---|---|---|---|---|
| Allegro A1302 | Analog (Ratiometric) | 4.5V to 6.0V | 1.3 mV/G | ±1300 Gauss | General proximity, basic current sensing |
| Honeywell SS49E | Analog (Ratiometric) | 2.7V to 6.5V | 1.4 mV/G | ±1500 Gauss | 3.3V MCU direct interfacing, joysticks |
| TI DRV5055 | Analog (Ratiometric) | 2.5V to 5.5V | 25 mV/mT (2.5 mV/G) | ±160 mT (±1600 G) | High-resolution position tracking |
| Melexis MLX90393 | Digital (I2C/SPI) | 2.2V to 3.6V | Programmable | ±50 mT (±500 G) | Precision 3-axis field mapping, low drift |
For 5V Arduino systems, the Allegro A1302 is the legacy standard. For 3.3V ESP32 or Raspberry Pi Pico systems, the Honeywell SS49E or TI DRV5055 are vastly superior because they operate natively at 3.3V, allowing you to wire VCC directly to the microcontroller's 3V3 pin and maximizing your ADC resolution without needing a logic level shifter or voltage divider.
Output Signal Math: Converting Raw ADC to Gauss
The output of a linear analog Hall sensor is a continuous DC voltage. When no magnetic field is present, the sensor outputs a quiescent voltage ($V_{Q}$), which is exactly half of your supply voltage ($V_{CC} / 2$). When a south magnetic pole approaches, the voltage increases; when a north pole approaches, it decreases.
To convert a raw microcontroller ADC reading into a physical unit (Gauss), you must apply the sensor's sensitivity rating from the datasheet. The formula is:
$B (Gauss) = \frac{V_{out} - V_{Q}}{Sensitivity}$
Worked Numeric Example (Honeywell SS49E on an ESP32):
- VCC: 3.3V
- Quiescent Voltage ($V_{Q}$): 1.65V
- Sensitivity: 1.4 mV/G (or 0.0014 V/G)
- ESP32 12-bit ADC Reading: 2450 (out of 4095)
First, convert the raw ADC reading to voltage. Assuming a perfect 3.3V reference:
$V_{out} = (2450 / 4095) \times 3.3V = 1.974V$
Next, apply the Gauss formula:
$B = (1.974V - 1.65V) / 0.0014 V/G = 231.4 Gauss$
This positive value indicates a south magnetic pole is present. If the ADC reading had been below 2047 (the midpoint), the resulting voltage would be less than 1.65V, yielding a negative Gauss value indicating a north pole.
Real-World Interference and Calibration
If you wire up a Hall sensor and read the serial monitor, you will immediately notice the values jumping erratically. This is rarely a faulty sensor; it is almost always environmental interference or ADC non-linearity.
- VCC Ripple: Because the output is ratiometric, a 50mV ripple on your 3.3V rail from a cheap switching buck converter will look exactly like a 35 Gauss magnetic field fluctuation to your code. Always power analog Hall sensors from a clean LDO regulator, not the raw output of a switching power supply.
- AC Mains EMI: 50/60Hz alternating current in nearby wall wiring or stepper motor cables induces electromagnetic interference. Keep sensor leads short and use twisted-pair wiring for the output signal.
- Ferromagnetic Shielding: Mounting the sensor on a steel chassis or using steel breadboard plates will distort the local magnetic field lines, causing severe zero-point offsets.
- ESP32 ADC Non-Linearity: The ESP32's internal ADC is notoriously noisy and non-linear above 2.8V. If your $V_{Q}$ is 1.65V, you are in the safe zone, but for high-precision work, use an external I2C ADC like the ADS1115.
Calibration Protocol: Never hardcode $V_{Q}$ as exactly $V_{CC}/2$ in your firmware. Manufacturing tolerances mean the zero-field output can vary by ±50mV. Always write a calibration routine that powers on the system, waits 500ms, takes 1000 samples with no magnet present, and averages them to establish your true $V_{Q}$ baseline in software.
ESP32 Wiring Steps and C++ Calibration Code
Follow these physical wiring steps before uploading the code to ensure a clean signal path.
- De-energize the board: Unplug the ESP32 USB cable.
- Connect Power: Wire SS49E Pin 1 to the ESP32
3V3pin. Do not useVINor5Vunless you are using a 5V-tolerant sensor like the A1302 and an external ADC. - Connect Ground: Wire SS49E Pin 2 to the ESP32
GNDpin. - Connect Signal: Wire SS49E Pin 3 to ESP32 GPIO
34(an input-only ADC1 pin, which is more stable than ADC2 pins that conflict with WiFi). - Add Filtering: Solder a 100nF ceramic capacitor directly across the VCC and GND pins of the sensor on the breadboard to suppress high-frequency EMI.
Below is the complete, copy-pasteable ESP32 C++ code. It includes a multi-sample averaging filter to smooth out ADC noise and an automatic zero-field calibration routine on boot.
// ESP32 Linear Hall Sensor (SS49E) Interfacing Code
// Target: ESP32 DevKit V1 | Board Package: esp32 v2.0.x+
const int HALL_PIN = 34; // ADC1_CH6 (GPIO 34)
const float VCC = 3.3; // Supply voltage
const float ADC_MAX = 4095.0; // 12-bit resolution
const float SENSITIVITY = 0.0014; // 1.4 mV/G converted to V/G
float vQuiescent = 0.0; // Calibrated zero-field voltage
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit ADC mode
// Calibration Routine: Average 1000 samples with NO magnet present
Serial.println("Calibrating zero-field baseline... Keep magnets away!");
delay(500); // Let power rail stabilize
long sum = 0;
for(int i = 0; i < 1000; i++) {
sum += analogRead(HALL_PIN);
delay(2);
}
float avgRaw = sum / 1000.0;
vQuiescent = (avgRaw / ADC_MAX) * VCC;
Serial.print("Calibrated V_Quiescent: ");
Serial.print(vQuiescent, 3);
Serial.println(" V");
}
void loop() {
// Oversample to reduce ESP32 ADC noise
long rawSum = 0;
int samples = 64;
for(int i = 0; i < samples; i++) {
rawSum += analogRead(HALL_PIN);
}
float rawAvg = rawSum / (float)samples;
// Convert raw ADC to Voltage
float vOut = (rawAvg / ADC_MAX) * VCC;
// Convert Voltage to Gauss using the physics formula
float gauss = (vOut - vQuiescent) / SENSITIVITY;
// Convert Gauss to Tesla (1 Tesla = 10,000 Gauss)
float tesla = gauss / 10000.0;
Serial.print("Raw ADC: "); Serial.print(rawAvg, 1);
Serial.print(" | Vout: "); Serial.print(vOut, 3);
Serial.print(" V | Field: "); Serial.print(gauss, 1);
Serial.print(" G ("); Serial.print(tesla, 4); Serial.println(" T)");
delay(100); // 10Hz update rate
}
For deeper architectural details on chopper-stabilized amplifiers and thermal drift curves, refer to the Texas Instruments DRV5055 Datasheet and the comprehensive All About Circuits Hall Effect Guide. If your application requires sub-milliTesla precision over varying temperatures, abandon analog ratiometric sensors entirely and switch to a digital I2C sensor like the MLX90393, which handles temperature compensation internally.






