The ACS712 Current Sensor with an Arduino

Overview

The ACS712 Current Sensor is a cool little device for making current measurements.  Better, its really easy to use with an Arduino.

In this sample project,  I’ll show you just how easy it is to connect up, program and put to immediate use.

Other ACS712 Henry’s Bench Articles

ACS712 User Guide Discusses the device directly.

ACS712 AC Current Measurement  shows how to measure AC current with an Arduino

18650 Battery Charger shows another implementation of the ACS712

ACS758 Tutorial  Shows a similar device for monster currents.

What You Will Need

An Arduino – I used an Arduino UNO

An ACS712 Current Sensor Module –  I chose to use the 5 amp version.  There are 20 amp and 30 amp versions also available.   If you’re not all that familiar with this module,  you can read my online user manual.

If you don’t have one of these modules and think that you may want one, you can try these links. It will only set you back a few dollars.

eBay

Amazon

Bang Good

Deal Extreme

A Load – I used a 10 Ohm potentiometer rated for 3.16A.   That said, about anything will do.  A light bub or a different kind of resistor that can dissipate the current will do.

If you really want to duplicate my project exactly, you can buy one HERE.   Its a real handy development tool to have around.

A Power Source –  I used a MingHe B3603 Power Supply because I wanted to have any easy means of validating the measurements on my Arduino.   If you want to know more about this buck converter, you can read my online user manual.

A Bench Supply –   I used an HY3010E.   You’ll probably have something different.   That’s OK.  However, if you’re going to duplicate my set up,  you will want something that provides at least 12V at 2.00A (or 24 Watts).

The ACS712 Sample Project Schematic

The drawing below shows I hooked things up.   I realize its a little small, but you can click on it to see a larger version.  I’ve also include a printable PDF at the end of this article.

ACS 172 Sample Project Schematic

Power Supply and Potentiometer Set Up

I set the potentiometer so that it would read 10 Ohms.

On the B3603,  I choose to limit the current to 1.500 amps and I set the voltage for 03.00 volts.

Once the program is running, I increase the voltage on the B3603 up to 10 volts and verify the results on the serial monitor by comparing to the indication on my B3603 current display.

The ACS712 Example Project Code

You can copy and paste the code you see below.

/*
Measuring Current Using ACS712
*/
const int analogIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500; 
double Voltage = 0;
double Amps = 0;

void setup(){ 
 Serial.begin(9600);
}

void loop(){
 
 RawValue = analogRead(analogIn);
 Voltage = (RawValue / 1024.0) * 5000; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 
 
 Serial.print("Raw Value = " ); // shows pre-scaled value 
 Serial.print(RawValue); 
 Serial.print("\t mV = "); // shows the voltage measured 
 Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
 Serial.print("\t Amps = "); // shows the voltage measured 
 Serial.println(Amps,3); // the '3' after voltage allows you to display 3 digits after decimal point
 delay(2500); 
 
}

Basically the Arduino measures the input at the analog pin, converts it to millivolts, subtracts the offset and then finally divides it by the scale factor of the current sensor.

In other words, its nothing more than a simple Arduino voltmeter that interprets the output of the ACS712.

The program then makes use of the Arduino Serial Monitor to look at the results.

Running the Sample Project

Give it whirl once you’ve connected things up and keyed your program in.

You’ll notice that increasing the voltage increases the current.

If you’re using the B3603, you can  validate your results by using the current display.

Otherwise, you can use can use ohms law as follows:

Current = Voltage You Applied / The Resistance of your Load

Project PDF

ACS 712 Sample Project

 

 

 

65 Comments

  1. selva April 18, 2017
  2. capnfatz@gmail.comAuthor March 31, 2017
  3. Aniket March 30, 2017
  4. capnfatz@gmail.comAuthor March 26, 2017
  5. zeineb March 24, 2017
  6. capnfatz@gmail.comAuthor March 23, 2017
  7. johnson March 21, 2017
  8. capnfatz@gmail.comAuthor February 23, 2017
  9. Ramona February 23, 2017
  10. capnfatz@gmail.comAuthor February 1, 2017
  11. Chris February 1, 2017
  12. Umar January 5, 2017
  13. Greg December 23, 2016
  14. capnfatz@gmail.comAuthor December 20, 2016
  15. Mehdi December 19, 2016
  16. Mayra Lorena Altamirano Crespo November 23, 2016
  17. capnfatz@gmail.comAuthor October 24, 2016
  18. capnfatz@gmail.comAuthor September 20, 2016
  19. Kyrian September 20, 2016
  20. capnfatz@gmail.comAuthor September 19, 2016
  21. marljon September 17, 2016
  22. capnfatz@gmail.comAuthor May 21, 2016
  23. tariq May 21, 2016
  24. Ara 201 May 18, 2016
  25. ralphi May 16, 2016
  26. capnfatz@gmail.comAuthor May 13, 2016
  27. Josua May 11, 2016
  28. zzzzz April 30, 2016
  29. capnfatz@gmail.comAuthor April 12, 2016
  30. Anna April 12, 2016
  31. Sofia April 11, 2016
  32. capnfatz@gmail.comAuthor April 9, 2016
  33. Sofia April 9, 2016
  34. hamza April 8, 2016
  35. capnfatz@gmail.comAuthor April 7, 2016
  36. anna April 7, 2016
  37. capnfatz@gmail.comAuthor March 31, 2016
  38. Charan March 29, 2016
  39. capnfatz@gmail.comAuthor March 29, 2016
  40. Savneel Pratap March 28, 2016
  41. capnfatz@gmail.comAuthor March 8, 2016
  42. sujith March 8, 2016
  43. capnfatz@gmail.comAuthor March 3, 2016
  44. novan March 3, 2016
  45. Stefan February 12, 2016
  46. capnfatz@gmail.comAuthor February 11, 2016
  47. capnfatz@gmail.comAuthor February 11, 2016
  48. sara February 11, 2016
  49. Stefan February 11, 2016
  50. capnfatz@gmail.comAuthor February 11, 2016
  51. Stefan February 11, 2016
  52. Edward January 14, 2016
  53. pratik January 6, 2016
  54. capnfatz@gmail.comAuthor December 4, 2015
  55. justin December 4, 2015
  56. capnfatz@gmail.comAuthor November 17, 2015
  57. dale November 16, 2015
  58. capnfatz@gmail.comAuthor August 25, 2015
  59. CRASH August 25, 2015
  60. capnfatz@gmail.comAuthor July 3, 2015
  61. miamon July 3, 2015
  62. miamon June 16, 2015
  63. capnfatz@gmail.comAuthor June 15, 2015
  64. miamon June 15, 2015

Add a Comment

Your email address will not be published. Required fields are marked *