Log #107 · Nov 16, 2026
ACS712 Current Sensor with Arduino: Measuring DC Current Safely
How the Hall-effect ACS712 current sensor module works, the difference between the 5 A, 20 A and 30 A versions, how to wire it in series with a load, and Arduino code with zero calibration and averaging for stable readings.
How much current is your motor drawing? Is the solar panel actually charging? Is the LED strip near the limit of its power supply? The ACS712 module answers these questions continuously, inside your project. It measures current with a Hall effect sensor, so the circuit being measured is electrically separated from the Arduino. This guide explains how it works, which version to buy and how to get readings you can trust.
How it works
Inside the chip, the current you're measuring flows through a thick copper conductor. Current creates a magnetic field around a conductor, and a Hall sensor right next to it measures that field (the principle is explained in Hall effect sensors explained). The chip turns the field into a voltage:
- 0 A → output = half the supply, about 2.5 V
- Current flowing IP+ → IP− → output rises above 2.5 V
- Current flowing the other way → output falls below 2.5 V
The measured path and the signal side don't share any wires, so a 12 V motor circuit never connects to the Arduino through the sensor.
The three versions
The chip's marking ends in 05B, 20A or 30A:
| Version | Range | Sensitivity | Change per Arduino step (4.9 mV) |
|---|---|---|---|
| ACS712-05B | ±5 A | 185 mV/A | ~26 mA |
| ACS712-20A | ±20 A | 100 mV/A | ~49 mA |
| ACS712-30A | ±30 A | 66 mV/A | ~74 mA |
Choose the smallest range that covers your maximum current. A 30 A module measuring a 300 mA load only moves 4 steps on the Arduino's ADC, which is barely a measurement at all. For currents below about 1 A, the 5 A version with averaging is the minimum; a dedicated low-current sensor such as the INA219 is better still.
Wiring
The module has a two-screw terminal for the current path and three pins for the Arduino.
| Module | Connects to |
|---|---|
| IP+ (screw) | Battery or supply + |
| IP− (screw) | The load's + (motor, LED strip…) |
| VCC | Arduino 5V |
| GND | Arduino GND |
| OUT | Arduino A0 |
The sensor goes in series with the load, exactly like a multimeter measuring current: the current must flow through it. Never connect IP+ and IP− directly across a supply, which is a short circuit.
Safety: the chip is isolated, but the cheap modules have exposed screw terminals and traces. Use them on low-voltage DC circuits (batteries, adapters, solar panels). Don't use them on mains wiring.
Converting the reading to amps
The Arduino measures the output with analogRead(), 0–1023 for 0–5 V (see analogRead explained). For the 5 A version:
- 185 mV/A ÷ 4.89 mV per step ≈ 37.9 steps per amp
- amps = (reading − zero reading) ÷ 37.9
There's a nice detail here: the ACS712's output is ratiometric, meaning its zero point and sensitivity scale with its 5 V supply. The Arduino's ADC also measures relative to its 5 V. If USB supplies 4.9 V instead of 5.0 V, both shift together, so working directly in ADC steps cancels most of the error.
The code
const int SENSE = A0;
const float STEPS_PER_AMP = 37.9; // 5 A version: 185 mV/A
// 20 A: 20.5 30 A: 13.5
float zero = 512.0;
float averageReading(int samples) {
long sum = 0;
for (int i = 0; i < samples; i++) {
sum += analogRead(SENSE);
delayMicroseconds(200);
}
return (float)sum / samples;
}
void setup() {
Serial.begin(9600);
delay(500); // let the sensor settle
zero = averageReading(1000); // NO current must flow now
Serial.print("Zero point: ");
Serial.println(zero, 1);
}
void loop() {
float amps = (averageReading(300) - zero) / STEPS_PER_AMP;
if (fabs(amps) < 0.05) amps = 0; // hide noise around zero
Serial.print("Current: ");
Serial.print(amps, 2);
Serial.println(" A");
delay(500);
}
Important details:
- Zero calibration: the output at 0 A is never exactly 512 on every board. The sketch measures it at startup, so make sure the load is off (or disconnected) when the Arduino starts.
- Averaging: a single reading jumps around by several steps because of electrical noise. Averaging 300 readings takes about 0.1 s and gives a stable value.
- Dead band: values within ±50 mA of zero are shown as 0 to avoid a reading that flickers between −0.03 and 0.04 A with nothing connected.
Checking the readings
Put a multimeter in series with the same load and compare. With averaging and a good zero, the 5 A version is usually within about 2–5 % plus a few tens of milliamps. If your reading is consistently off by the same percentage, adjust STEPS_PER_AMP. If the sign is negative, swap the wires on IP+ and IP− (or accept negative as "reverse direction", which is useful for measuring battery charge vs discharge).
Measuring power and energy
Measure the supply voltage too (with a voltage divider if it's above 5 V), and you can calculate power and energy:
- Power (W) = voltage × current
- Energy (Wh): add up power × time. Measure the real time between loops with
millis()(about 0.6 s here, because averaging takes time too) and addwatts * dt_s / 3600.0to a running total, wheredt_sis that time in seconds.
That turns the sketch into a simple energy meter for a solar panel or a battery-powered project. Watts and watt-hours are explained in electrical power explained.
Measuring motor current
Motors draw current in pulses when driven by PWM, and spikes when starting. The averaged reading shows the average current, which is what matters for battery life and heat. To catch the peak start-up current, read without averaging in a fast loop and keep the maximum value.
Troubleshooting
- Reading isn't zero with no load: the load was on during calibration, or the module sits near a magnet or a motor. Restart with the load off and keep the module away from magnetic fields.
- Reading noisy: add more averaging, keep the OUT wire short and away from motor wires, and add a 100 nF capacitor from OUT to GND.
- Reading barely changes: the range is too large for your current (a 30 A module on a small load). Use the 5 A version.
- Reading doubles or halves: wrong
STEPS_PER_AMPfor your version. Check the marking on the chip.
— TheSolderBench · found a mistake? tell me