If you need to measure AC or DC current without introducing a shunt resistor's voltage drop or breaking galvanic isolation, hall effect current sensors are the correct tool. For modern 3.3V microcontrollers like the ESP32, skip the legacy 5V-only ACS712 modules flooding online marketplaces; instead, use 3.3V-native ratiometric sensors like the Texas Instruments TMCS1100 or Allegro ACS724. This guide provides the exact wiring, transfer math, and interference mitigation required to get accurate, noise-free amp readings on your bench.
The Physics and Output of Hall Effect Current Sensors
Current flowing through a conductor generates a proportional magnetic field. A hall effect current sensor routes this primary current through an internal copper trace (or an external magnetic core), which concentrates the magnetic flux onto a microscopic Hall element. The Hall element generates a voltage strictly proportional to the magnetic flux density, allowing for non-contact, galvanically isolated current measurement that dissipates almost zero heat compared to shunt resistors.
The output of these sensors is typically an analog ratiometric voltage. For bidirectional (AC/DC) sensing, the output rests at exactly VCC/2 when zero current is flowing, swinging up for positive current and down for negative current. Unidirectional DC variants start at a lower offset (e.g., 0.5V) to maximize the measurement range in one direction. While some specialized industrial sensors output digital I2C/SPI data or PWM, the analog ratiometric voltage remains the standard for embedded prototyping. Because the output scales linearly with the supply voltage, a clean, heavily decoupled VCC rail is mandatory for accurate ADC readings.
Hardware Selection and Pinout Specifications
Choosing the right sensor prevents ADC clipping and minimizes noise. The legacy ACS712 is notoriously noisy and requires a 5V supply, meaning you must use a voltage divider to interface it with an ESP32's 3.3V ADC, which degrades your resolution. Modern alternatives operate natively at 3.3V and offer vastly superior bandwidth and noise floors.
| Model | VCC Range | Sensitivity (mV/A) | Isolation Rating | Bandwidth | Best Application |
|---|---|---|---|---|---|
| TI TMCS1100 | 3.0V - 5.5V | 50 to 400 (variant dependent) | 600 Vrms (Basic) | 80 kHz | High-precision ESP32 DC/AC metering |
| Allegro ACS724 | 3.0V - 5.5V | 20 to 400 (variant dependent) | 4.8 kVrms | 250 kHz | High-isolation mains AC monitoring |
| Allegro ACS712 (Legacy) | 4.5V - 5.5V | 66 to 185 | 2.1 kVrms | 80 kHz | 5V Arduino Unos (Avoid for ESP32) |
| LEM HTFS 200-P | 4.75V - 5.25V | 12.5 (Fixed gain) | 2.5 kVrms | 100 kHz | Industrial motor drives / EV battery packs |
When wiring the low-voltage side to your microcontroller, the pinout is standardized across almost all breakout boards. Below is the wiring table for a standard 3-pin analog module.
| Sensor Pin | Function | ESP32 Connection | Wiring Notes & Constraints |
|---|---|---|---|
| VCC | Power Supply | 3V3 Pin | Must be exactly the same 3.3V rail powering the ESP32 to maintain ratiometric accuracy. Add 100nF + 10µF decoupling capacitors at this pin. |
| GND | Ground Reference | GND Pin | Keep this wire short. Do not share this ground return path with high-current motor drivers or relays. |
| OUT / VIOUT | Analog Output | GPIO 34 (ADC1_CH6) | Use ADC1 pins on the ESP32. ADC2 pins conflict with WiFi operations and will drop samples when the radio transmits. |
From Raw ADC to Amps: The Transfer Math
The most common mistake makers make with hall effect current sensors is assuming the sensor outputs exactly 1.65V at zero current. Because the output is ratiometric, the zero-current offset is exactly VCC / 2. If your ESP32's 3.3V regulator is actually outputting 3.24V under load, your offset is 1.62V, not 1.65V. Failing to calibrate this offset will result in a phantom current reading of nearly 1 Amp on highly sensitive sensors.
The transfer function to convert voltage to current is:
Current (A) = (V_measured - V_offset) / Sensitivity
Let's work through a concrete numeric example using the TI TMCS1100A10B, which has a sensitivity of 50 mV/A (0.050 V/A) and is powered by a 3.3V VCC.
- Determine V_offset: 3.3V / 2 = 1.65V.
- Read the ESP32 ADC: The ESP32's 12-bit ADC returns values from 0 to 4095. However, the ESP32 ADC is notoriously non-linear near the 0V and 3.3V rails. You must keep your operating voltage between 0.2V and 3.1V.
- Convert ADC raw to Voltage:
V_measured = (ADC_Raw / 4095.0) * 3.3(Note: For production code, use the ESP-IDF ADC calibration API to map raw values to millivolts, compensating for chip-specific non-linearity). - Calculate Current: If the ADC reads a voltage of 2.15V, the math is:
(2.15V - 1.65V) / 0.050 V/A = 10.0 Amps.
The math above yields instantaneous current. If you are measuring DC, apply a low-pass filter (moving average or IIR) in software to smooth out high-frequency noise. If you are measuring AC, you must sample at least 20 times faster than your AC frequency (e.g., >1200 Hz for 60Hz mains), capture a full wave, remove the DC offset, square the samples, average them, and take the square root to calculate True RMS current. Simply reading the peak voltage and dividing by 1.414 only works for perfect sine waves and will fail on switching power supplies or dimmed loads.
Wiring Steps and Interference Mitigation
Hall effect sensors are incredibly susceptible to environmental noise. A sloppy wiring job will easily introduce 2-3 Amps of apparent noise into your readings. Follow this sequence to ensure a clean signal path.
Warning: If your primary current path involves mains voltage (>50V AC) or high-current battery banks (>48V DC), de-energize the circuit, lock out the breaker, and verify dead with a CAT III/IV multimeter before touching the high-current screw terminals. Local electrical codes may require a licensed electrician for permanent mains installations.
- Terminate the High-Current Path: Do not just wrap bare wire around the sensor's screw terminals. Use proper ferrule or ring terminal crimps. A loose connection on a 30A load will generate heat that alters the Hall element's temperature coefficient, drifting your readings by up to 5%.
- Route the Low-Voltage Signals: Use twisted pair wire for the VCC and OUT lines. Keep these signal wires at least 2 inches away from the high-current cables, relays, or switching power supplies to prevent capacitive coupling.
- Decouple the VCC Pin: Solder a 100nF ceramic capacitor and a 10µF tantalum or low-ESR electrolytic capacitor directly across the VCC and GND pins on the sensor breakout board. This creates a local energy reservoir that starves out high-frequency VCC ripple.
- Calibrate the Zero-Offset in Code: Before applying any load to the primary terminals, power up the ESP32, read the ADC 1,000 times, average the result, and store that value in non-volatile memory (NVS) as your
V_offset. This accounts for both VCC sag and the sensor's internal zero-current offset error.
Common Interference Sources and Fixes
Even with perfect wiring, external physics can corrupt your data. Here is how to identify and defeat the three most common interference sources:
- External Magnetic Fields: Hall sensors cannot distinguish between the magnetic field generated by your target wire and the field generated by a nearby transformer, relay coil, or adjacent high-current cable. Fix: Maintain physical clearance from magnetic components, or use a sensor variant with an integrated magnetic shield (like the TMCS1100) which rejects external fields by up to 40 dB.
- VCC Ripple: Because the output is ratiometric, any noise on your 3.3V power rail is directly injected into your signal. If your ESP32 is transmitting on WiFi, it pulls current spikes that cause VCC to dip, creating massive current spikes in your sensor data. Fix: Power the sensor from an independent LDO regulator (like an AP2112K-3.3) rather than sharing the ESP32's onboard regulator.
- Ground Loops: If the high-current load shares a ground return path with your microcontroller's logic ground, high-frequency switching noise from the load will modulate the sensor's GND pin. Fix: Rely on the sensor's internal galvanic isolation. Ensure the high-current ground and the ESP32 logic ground only meet at a single, dedicated star-ground point, or keep them entirely separate if using an isolated DC-DC converter for the ESP32.






