The ACS712 outputs a ratiometric analog voltage sensor signal centered exactly at VCC/2 (typically 2.5V on a 5V supply). To extract the actual current in Amps, you must read the raw ADC value, convert it to millivolts, subtract the zero-current quiescent offset, and divide by the specific sensitivity rating of your chip variant (e.g., 66 mV/A for the 30A model). Unlike I2C or SPI digital sensors that hand you a pre-calculated register value, the ACS712 requires you to handle the analog-to-physical math and zero-offset calibration in your firmware.
The Hall Effect Sensing Principle & Signal Output
The ACS712 relies on the Hall effect to measure current without introducing significant shunt resistance into your load path. When current flows through the internal copper conduction path, it generates a proportional magnetic field. A precision Hall transducer embedded in the IC converts this magnetic flux density into a proportional analog voltage. Because the conduction path is electrically isolated from the sensor leads (up to 2.1 kV RMS isolation), the low-voltage microcontroller side remains completely safe from the high-voltage or high-current load side.
Critically, the output is a continuous analog voltage sensor signal, not a digital stream or a simple threshold trigger. It is ratiometric, meaning the zero-current baseline and the sensitivity scale linearly with the VCC supply voltage. If your 5V supply sags to 4.8V, the zero-current baseline drops from 2.50V to 2.40V, and the millivolts-per-Amp sensitivity shifts slightly. This ratiometric behavior is the most common source of calculation errors for beginners who hardcode a 2.5V offset without measuring the actual VCC rail.
ACS712 Variants & Pinout Specifications
Allegro MicroSystems manufactures the ACS712 in three primary current ranges, each with a different internal gain amplifier. Choosing the wrong variant ruins your resolution; using a 30A sensor to measure a 2A LED strip will result in a noisy, unusable signal because the voltage swing is too small for a standard 10-bit or 12-bit ADC. Below is the data-dense specification matrix to select the correct IC.
| Model Variant | Measuring Range | Sensitivity (mV/A) | Quiescent Output (at 5V) | Bandwidth (-3dB) | Primary Resistance |
|---|---|---|---|---|---|
| ACS712ELC-05B | ±5 A | 185 mV/A | 2.50 V | 80 kHz | 1.2 mΩ |
| ACS712ELC-20A | ±20 A | 100 mV/A | 2.50 V | 80 kHz | 1.2 mΩ |
| ACS712ELC-30A | ±30 A | 66 mV/A | 2.50 V | 80 kHz | 1.2 mΩ |
| ACS758LCB-050B (Alt) | ±50 A | 40 mV/A | 2.50 V | 120 kHz | 0.1 mΩ |
Source: Allegro MicroSystems ACS712 Datasheet
Wiring & Pinout Table
The breakout modules typically feature a 3-pin header for the microcontroller and heavy-duty screw terminals for the load. The supply range is strictly 4.5V to 5.5V. Do not power the VCC pin with 3.3V, as the internal op-amps will clip and the ratiometric math will fail.
| Module Pin | Function | Microcontroller Connection | Wiring Notes & Constraints |
|---|---|---|---|
| VCC | Power Supply | 5V Pin (USB or Buck Converter) | Must be a clean 5.0V ±5%. Do not use 3.3V. |
| GND | Logic Ground | GND Pin | Must share a common ground with the MCU. |
| OUT | Analog Signal | ADC Pin (e.g., ESP32 GPIO34) | Analog input only. Never connect to a digital I/O pin. |
| IP+ / IP- | Load Path | Series with Load (Screw Terminals) | Direction matters for sign (+/-). Use heavy gauge wire. |
Converting the Raw Sensor Signal to Physical Units
Translating the analog sensor signal into Amperes requires a two-step mathematical conversion. First, the raw ADC integer must be converted to a voltage. Second, that voltage is mapped to current using the sensitivity constant.
The Raw-to-Unit Math
For an Arduino Uno (10-bit ADC, 5V reference), one ADC step equals 4.88 mV (5000mV / 1024). For an ESP32 (12-bit ADC, 3.3V max input), the math is trickier because the ESP32 ADC is notoriously non-linear and caps at ~3.1V. To bypass this, modern ESP32 Arduino cores include the analogReadMilliVolts() function, which uses the chip's factory-burned eFuse calibration data to return a highly accurate millivolt reading directly.
The core formula for current is:
Current (A) = (Measured_mV - Zero_Offset_mV) / Sensitivity_mV_per_A
If you are using the ACS712-30A, the sensitivity is 66 mV/A. If your zero-current offset measures 2510 mV, and the sensor reads 2708 mV under load, the calculation is: (2708 - 2510) / 66 = 3.0 Amps.
ESP32 Firmware: Calibration and Oversampling
Because the ACS712 outputs a high-frequency PWM-like noise when measuring switching power supplies, a single analogRead() will yield erratic results. The code below implements a startup zero-offset calibration and a 64-sample moving average filter to stabilize the sensor signal.
// ACS712-30A Current Sensor Code for ESP32
// Wiring: OUT to GPIO34, VCC to 5V, GND to GND
const int SENSOR_PIN = 34;
const float SENSITIVITY_MV = 66.0; // 66mV/A for 30A model
float zeroOffsetMV = 2500.0; // Default, overwritten by calibration
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Ensure 12-bit resolution on ESP32
// 1. Zero-Offset Calibration (Ensure NO load is connected during boot)
Serial.println("Calibrating zero-offset... Keep load disconnected!");
float sum = 0;
for (int i = 0; i < 256; i++) {
sum += analogReadMilliVolts(SENSOR_PIN);
delay(2);
}
zeroOffsetMV = sum / 256.0;
Serial.print("Calibrated Zero Offset: ");
Serial.print(zeroOffsetMV);
Serial.println(" mV");
}
void loop() {
// 2. Oversampling to filter high-frequency noise
float sampleSum = 0;
const int SAMPLES = 64;
for (int i = 0; i < SAMPLES; i++) {
sampleSum += analogReadMilliVolts(SENSOR_PIN);
}
float measuredMV = sampleSum / SAMPLES;
// 3. Raw-to-Unit Math
float currentAmps = (measuredMV - zeroOffsetMV) / SENSITIVITY_MV;
// 4. Deadzone filtering to eliminate micro-amp jitter at zero load
if (abs(currentAmps) < 0.05) currentAmps = 0.0;
Serial.print("Current: ");
Serial.print(currentAmps, 2);
Serial.println(" A");
delay(200);
}
Note: ESP32 ADC pins (GPIO32-39) are input-only and lack internal pull-ups, making them ideal for analog sensor signals. For deeper ESP32 ADC non-linearity handling, consult the Espressif ADC Calibration API documentation.
Interference Sources & Signal Conditioning
The analog sensor signal from a Hall effect IC is highly susceptible to environmental and electrical interference. If your readings drift or show phantom current when the load is off, you are likely encountering one of the following issues.
Because the sensor is ratiometric, a 100mV sag on your 5V USB rail (common when an ESP32 transmits on WiFi) shifts the zero-offset baseline by 50mV. On a 30A sensor (66mV/A), this VCC sag looks exactly like a 0.75A phantom load. Fix: Power the ACS712 from a dedicated, regulated 5V LDO (like an LM7805 or AMS1117-5.0), not the raw USB VBUS pin.
Magnetic Field Coupling
The Hall element cannot distinguish between the magnetic field generated by the internal conduction path and external magnetic fields. Mounting the ACS712 module within 2 inches of a step-down transformer, a large inductor, or an AC motor will induce massive offset errors. Keep the sensor at least 5 cm away from any magnetic components, and avoid looping high-current AC wires directly over the IC package.
Switching Ripple and EMI
When measuring the current draw of switching power supplies, LED drivers, or motor controllers, the load current contains high-frequency ripple (often 20 kHz to 100 kHz). The ACS712 has an 80 kHz bandwidth, meaning it will faithfully output this high-frequency noise on the OUT pin. If your microcontroller's ADC sampling rate aliases with this ripple, your readings will scatter wildly.
Hardware Fix: Add a simple RC low-pass filter on the OUT pin before it reaches the microcontroller. A 1kΩ series resistor and a 100nF ceramic capacitor to GND creates a ~1.6 kHz cutoff filter, smoothing out switching noise while preserving the DC current envelope.
Software Fix: As demonstrated in the code block above, use software oversampling (reading 64 to 256 samples and averaging) to mathematically smooth the ripple. Ensure your sampling window covers at least one full AC cycle if measuring rectified AC loads (16.6ms for 60Hz, 20ms for 50Hz).






