ACS712 current sensor

A Hall-effect current sensor board: the load's current runs through its copper, and OUT moves 185, 100 or 66 mV an amp from half the supply.

A small red breakout with a two-way screw terminal for the current and three pins for the board. The same part is the ACS758 (50 and 100 A) and the ACS724 boards, by model. Aliases: ACS712-05B, ACS712-20A, ACS712-30A, ACS758, ACS724, current sensor module, Hall current sensor.

The current runs through a strip of copper inside the chip; a Hall element beside it measures the magnetic field the current makes, and an amplifier turns that into a voltage on OUT. The copper never touches the electronics, so the same board can sit in a 12 V motor lead or a mains cable.

Pins

Pin What it does
VCC Supply, 4.5 to 5.5 V (the ACS758: 3 to 5.5 V). The ACS712 is not a 3.3 V part.
OUT The analog output: half the supply at no current (a tenth or so of it on a unidirectional U part).
GND Ground.
IP+ One end of the copper, a screw terminal. Current in here raises OUT.
IP- The other end.

Properties

model is the chip, as printed on it:

Model Range mV an amp at 5 V Zero at 5 V Copper
ACS712-05B ±5 A 185 2.5 V 1.2 mΩ
ACS712-20A ±20 A 100 2.5 V 1.2 mΩ
ACS712-30A ±30 A 66 2.5 V 1.2 mΩ
ACS758LCB-050B ±50 A 40 2.5 V 100 µΩ
ACS758LCB-050U 0 to 50 A 60 0.6 V 100 µΩ
ACS758LCB-100B ±100 A 20 2.5 V 100 µΩ
ACS758LCB-100U 0 to 100 A 40 0.6 V 100 µΩ
ACS724LLCTR-05AB ±5 A 400 2.5 V 1.2 mΩ
ACS724LLCTR-10AB ±10 A 200 2.5 V 1.2 mΩ
ACS724LLCTR-20AB ±20 A 100 2.5 V 1.2 mΩ
ACS724LLCTR-30AB ±30 A 66 2.5 V 1.2 mΩ
ACS724LLCTR-50AB ±50 A 40 2.5 V 1.2 mΩ

noise turns the sensor's noise on (the default) or off.

A real conductor in the circuit

IP+ and IP- are the two ends of the chip's copper, 1.2 milliohms on the ACS712, and the part is that conductor: the load's current really flows through it. So the reading is whatever the circuit is doing, not a number on a slider, and the readout on the board shows the same current the simulation computes. Turn the board round and the current reads the other way, as it does on a bench.

What the model gets right

From the Allegro ACS712, ACS758xCB and ACS724 datasheets:

The output. OUT = zero + sensitivity x current: 2.5 V at no current on 5 V, and the model's millivolts more for each amp from IP+ to IP-, less for each amp the other way. A 2 A load on the ACS712 5 A board reads 2.87 V. A unidirectional part (U) starts at 0.6 V on 5 V and reads current one way only.

Ratiometric. Both the zero and the sensitivity are in proportion to the supply. On a USB port's 4.8 V the zero is 2.4 V and the 5 A board gives 177.6 mV an amp. (The ACS724's sensitivity moves 1.3 times as much as the supply, as its datasheet gives.) A sketch that reads the converter against the same supply cancels most of that; one that assumes 2.5 V reads a current that is not there.

The noise. 21, 11 and 7 mV peak to peak for the three ACS712 models, a new value 4000 times a second, which is the figure and the 2 kHz bandwidth the datasheet quotes it at. The ACS758's are its datasheet's 10, 15, 6 and 12 mV (three sigma either way), and the ACS724's its 150 µA per root hertz over the same 2 kHz, about 8 mA. On an Uno one converter step is 4.9 mV, so the ACS712 5 A board's reading jumps by a few steps and the 30 A board's by about one. Average a hundred readings and it settles.

The resolution. One step on a 5 V, 10-bit converter is 26 mA on the ACS712 5 A board, 49 mA on the 20 A and 74 mA on the 30 A, and 122 mA on the ACS758 50 A. Small currents need the 5 A board, the ACS724 5 A (12 mA a step), or an INA219.

What it does not model

The common ACS712 board's filter capacitor is 1 nF, which leaves more of the chip's 80 kHz bandwidth, and more noise, than the datasheet's 2 kHz figure: a real board jumps more than this one. The chip's offset (here the zero is exactly half the supply; a real one is a few millivolts off, which is why sketches measure it), the 1.5% total error, temperature drift, the nonlinearity near full scale, where the output stops past full scale (here at the rails), the microseconds of response time, the ACS758's extra error away from 5 V, and the heating of the copper are not modeled.

The library

Rob Tillaart's ACS712 library works as its examples use it:

#include "ACS712.h"

ACS712 ACS(A0, 5.0, 1023, 185);   // pin, ADC volts, ADC top, mV per amp

void setup() {
  Serial.begin(115200);
  ACS.autoMidPoint();             // with nothing flowing yet
}

void loop() {
  Serial.println(ACS.mA_DC(100)); // the average of 100 readings, in mA
  delay(500);
}

mA_AC(), mA_AC_sampling() and mA_peak2peak() are there too, with the library's own sums.

Common mistakes

Measuring the zero while the load runs. autoMidPoint() takes whatever the output is at that moment as "no current", so a sketch that calls it with the motor already on reads that motor's current as zero.

Powering it from 3.3 V. Below 4.5 V the chip is out of its range and the model leaves OUT floating.

Expecting milliamps from the 30 A board. Its 66 mV an amp is 74 mA a step on an Uno.

See it in action

Motor current meter shows a 6 V gear motor's current, and the surge it draws as it starts, on an I2C LCD. Open it at /templates.