Home / Tutorials / Arduino Tutorial / Arduino Current Sensor Tutorial

# Arduino Current Sensor Tutorial

Current sensors can have different applications: power supplies, over-current protection, and motor control to name a few. In this Arduino current sensor tutorial, we will look at how to read current using the ACS712 sensor.

### Arduino Current Sensor using ACS712

The ACS712 contains a hall effect sensor that converts its input current to a magnetic field. The strength of this magnetic field gets stronger as the current gets higher. As we discussed in this article, hall effect is a phenomena when a voltage exists on a current-carrying conductor due to the presence of a magnetic field. In short, the current gets converted to a magnetic field which is then converted to voltage.

The module shown contains just three output pins:

The VCC pin can receive up to 8 V but ideally should be only 5 V. The OUT pin produces a voltage proportional to the current read in the input terminals. When no current is read, the OUT pin gives out a voltage that is half of VCC.

Converting the output voltage from the sensor to current is straightforward. The datasheet shows this:

It turns out, there are three versions of the ACS712. The module I own features the ACS712ELCTR-05B-T. The table says that the sensitivity of this type is 185 mV/A. Thus, to get the current reading, we use the formula

$I = \frac{V}{185}$

Where V is the voltage from the OUT pin of the sensor. Note that the current in this formula will be in milliamperes.

Another thing to note is the range of current it can detect. For the 05B model, the maximum current is +/- 5 A. The +/- sign indicates that it can read current in both directions.

### Interfacing the Current Sensor to Arduino

The ACS712 connects directly to any Arduino board. Its VCC pin connects to the 5 V pin of the Arduino, GND pin to GND and the OUT pin connects to the A0 pin.

To test if the sensor is working, upload the AnalogReadSerial sketch to your Arduino. When there is no current, the serial monitor should display a value of around 512 --- 2.5 V for a 10-bit ADC.

The sketch below converts the voltage output from the sensor to current. The serial monitor shows the current reading:

In this sketch, I accumulate the current readings and take their average. Doing this leads to a stabler output.

I hope this tutorial helps you in any way. For questions or clarifications, kindly drop a comment below!