When integrating current monitoring into a microcontroller project, the most critical hurdle is translating the physical measurement into usable code. The ACS723LLCTR-20AB-T is a widely used sensor electronic IC for measuring AC and DC current up to ±20A. Unlike digital sensors that hand you a pre-calculated value over I2C, this module outputs a continuous, ratiometric analog voltage. To get accurate readings on an ESP32 or Arduino, you must understand the raw-to-unit math, manage the ADC non-linearities, and filter out electromagnetic interference.
The Hall Effect Sensing Principle
The ACS723 utilizes a Hall effect sensing principle to measure current without introducing significant insertion resistance into your load path. Current flows through the internal copper conduction path (pins IP+ to IP-), generating a localized magnetic field proportional to the charge flow. An integrated Hall transducer detects this magnetic field and converts it into a proportional voltage. Because the current path is physically separated from the signal path, the IC provides 2.5 kVRMS of galvanic isolation, protecting your low-voltage microcontroller from the high-voltage load side.
Unlike shunt resistors that dissipate heat via I²R losses, this sensor electronic IC outputs an analog voltage that scales linearly with the magnetic field. For the ±20A variant, the output sits at exactly VCC/2 when zero current is flowing. As current increases in the positive direction, the voltage rises; as it reverses, the voltage drops below the midpoint. This means you are reading a continuous voltage wave, not a digital packet, requiring precise ADC timing to capture AC waveforms accurately and a solid grasp of analog math to derive physical amperage.
Wiring and Pinout for 3.3V Microcontrollers
The most common mistake when wiring this sensor electronic module is conflating 5V and 3.3V logic. The ACS723 is specifically optimized for 3.3V systems (supply range 3.0V to 3.6V). If you feed it 5V, you risk damaging the output pin or saturating the ADC of a 3.3V microcontroller like the ESP32. The output is strictly analog voltage; it does not use PWM, I2C, or SPI.
| Pin Name | Function | ESP32 Connection | Hardware Notes & Supply Range |
|---|---|---|---|
| VCC | Power Supply | 3.3V Pin | Supply range: 3.0V to 3.6V. Do not use 5V. |
| GND | Logic Ground | GND | Use a star-ground topology to avoid ground loops. |
| OUT | Analog Output | GPIO 34 (ADC1) | Must use ADC1 pins. ADC2 conflicts with WiFi. |
| IP+ | Load Current In | Series with Load | High voltage side. Keep traces short and thick. |
| IP- | Load Current Out | Series with Load | High voltage side. Connects to the load device. |
Always route the OUT pin to an ADC1 channel (e.g., GPIO 32, 33, 34, 35, 36, 39). The ESP32's ADC2 channels share hardware with the WiFi radio. If you use an ADC2 pin and then initialize WiFi, your analog readings will silently fail or return garbage data.
Output Signal Math: Raw ADC to Physical Amps
Calibration and scaling are mandatory for this sensor electronic module. The ESP32's raw analogRead() function returns a value between 0 and 4095, but the ESP32 ADC is notoriously non-linear at the extremes (near 0 and near 3.3V). To bypass this, modern ESP32 Arduino cores include analogReadMilliVolts(), which applies the factory-stored eFuse calibration data to return a linear millivolt reading.
The physical math relies on the sensor's sensitivity, which is 200 mV/A for the ±20A ACS723 variant. The zero-current baseline (offset) is exactly half of your VCC supply.
The Formula:
I_load = (V_measured_mV - V_offset_mV) / Sensitivity
Numeric Example:
Assume your ESP32 3.3V rail measures exactly 3.28V (3280 mV) on your multimeter.
1. V_offset = 3280 / 2 = 1640 mV.
2. You read a load and analogReadMilliVolts() returns 2140 mV.
3. Current = (2140 - 1640) / 200 = 500 / 200 = 2.5 Amps.
Here is the complete, copy-pasteable code for DC current measurement with baseline calibration:
// ACS723 DC Current Reader for ESP32
// Target: ACS723LLCTR-20AB-T (±20A, 200mV/A sensitivity)
const int SENSOR_PIN = 34; // ADC1 channel
const float SENSITIVITY = 200.0; // mV per Amp
float vccMilliVolts = 3280.0; // MEASURE THIS WITH A MULTIMETER
float offsetMilliVolts;
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution
analogSetAttenuation(ADC_11db); // Full scale ~3.3V
// Calibrate zero-current offset on boot (ensure load is OFF)
long sum = 0;
for(int i = 0; i < 100; i++) {
sum += analogReadMilliVolts(SENSOR_PIN);
delay(2);
}
offsetMilliVolts = sum / 100.0;
Serial.printf("Calibrated Offset: %.1f mV\n", offsetMilliVolts);
}
void loop() {
int rawMV = analogReadMilliVolts(SENSOR_PIN);
float currentAmps = (rawMV - offsetMilliVolts) / SENSITIVITY;
Serial.printf("Raw: %d mV | Current: %.2f A\n", rawMV, currentAmps);
delay(250);
}
Common Interference Sources and Hardware Filtering
Hall effect sensors are inherently susceptible to external magnetic fields and high-frequency electrical noise. If your sensor electronic readings are jittery or drifting, the issue is almost always environmental interference rather than a faulty IC.
- External Magnetic Fields: Keep the sensor at least 2 inches away from transformers, inductors, and neodymium magnets. The Earth's magnetic field is negligible, but nearby switching power supplies will induce massive spikes.
- Capacitive Coupling (Mains Hum): If measuring 120V/240V AC loads, the 50/60Hz electric field can couple into the high-impedance analog trace. Route the OUT pin trace directly to the microcontroller, keep it short, and use a ground plane beneath it.
- Power Supply Ripple: Because the output is ratiometric to VCC, any noise on your 3.3V rail directly injects into your reading. Place a 100nF (0.1µF) ceramic decoupling capacitor as close to the VCC and GND pins of the sensor as physically possible.
For software filtering on DC loads, implement a simple exponential moving average (EMA) or a median filter to discard outlier spikes caused by EMI. For AC loads, you must sample at a high frequency (at least 1 kHz) and calculate the Root Mean Square (RMS) over full waveform cycles.
Sensor Electronic Module FAQ
Why is my sensor electronic module reading current when the load is off?
This 'phantom current' is usually caused by electromagnetic interference (EMI) or a shifting ground reference. If the load wires passing through the IP+ and IP- terminals are long and unshielded, they act as an antenna, picking up 60Hz mains hum. Twist the load wires tightly together to cancel out the magnetic fields they emit. Additionally, verify that your microcontroller's ground is not experiencing voltage sag when other peripherals (like relays or WiFi) turn on, as this will shift the VCC/2 offset baseline.
How do I calculate AC RMS from a DC-biased sensor electronic output?
Because the sensor outputs a DC-biased AC wave (centered at 1.65V), you cannot just read the peak voltage. You must sample the analog pin rapidly (e.g., 1000 times per second), subtract the DC offset from every sample, square the result, calculate the mean of those squares over one full AC cycle (approx 16.6ms for 60Hz), and finally take the square root. This is the definition of RMS. Libraries like EmonLib handle this math efficiently, but ensure your ADC sampling rate is fast enough to capture the waveform peaks without aliasing.
What causes high-frequency noise in sensor electronic analog readings?
High-frequency noise (visible as rapid, random jitter in the serial monitor) typically originates from the microcontroller's own switching regulators or nearby digital logic. The ESP32's internal DC-DC converter generates switching noise that bleeds into the 3.3V rail. To fix this, power the sensor electronic module from a dedicated LDO (Low Dropout) regulator rather than the ESP32's onboard 3.3V pin, and add a 100Ω resistor in series with the OUT pin, followed by a 10nF capacitor to GND to form a hardware low-pass filter.
Can I use this sensor electronic IC directly on a 120V mains line?
Yes, the ACS723 provides 2.5 kVRMS of galvanic isolation between the IP+/IP- pins and the logic pins, which is sufficient for standard 120V/240V residential mains. However, the breakout board itself may not have adequate physical clearance (creepage and clearance distances) on the PCB to safely isolate mains voltage from low-voltage traces. For mains voltage applications, always buy a certified module with physical isolation slots routed into the PCB, and enclose the high-voltage side in a proper junction box to meet local electrical codes.






