loading

Please see a new simpler approach here


Objective: This Instructable shows how making an interface box that, when spliced into an extension cord, allows common microcontrollers like Arduino to measure AC current as a DC voltage signal proportional to AC current. My specific application is measuring refrigerator energy usage.

The challenge: Measuring AC current with a microcontroller such as an Arduino would at first seem simple using readily available current sensor modules based on ACS712 IC - BUT ITS NOT.

ACS712 data sheet

After all, the module requires just 3 connections: +5 Vcc, ground, and analog voltage out. The problem is that measuring AC current with the ACS712 module yields a sine wave centered around 1/2 Vcc; the greater the current, the greater the peak-to-peak magnitude about the center line. Thus, the average voltage will always be 1/2 Vcc regardless of the current draw. This type a signal is not easily processed by the microcontroller's A/D function. Fortunately, with some signal conditioning, we can get a VDC signal that's portortional to the AC current drawn.

Please see YouTube video regarding how the signal conditioning works. I strongly recommend viewing the video before building this project

Results. The completed project allows AC current to be easily measured as a VDC signal and a microcontroller.

Props. Signal conditioning circuit original design by Lewis Lofin.

Original Loflin circuit

Warning. This project requires the construction of a moderately complex circuit in a tight space. If you're new to circuit construction, this is probably not a good first project.

Step 1: Parts and Tools

Parts:

One each unless otherwise noted

  • Perf Board - Radio Shack dual mini board 276-148
  • Project enclosure 4 x 2 x 1" - Radio Shack 270-1802
  • 5 Amp Range Current Sensor Module ACS712 - Amazon.com or ebay. Also available in 20A and 30A versions
  • 3 wire AC power cord and plug - hardware store. The orange colored plug I used is GE #54283. The AC power cord came from my scrap box.
  • 3 conductor wire (for connection to Arduino or other microcontroler -length as needed)
  • LM358AN IC OPAMP
  • Signal Diode 1N914
  • (3) 10Kohm resistors, (1) 47 10Kohm resistor, (1) 100Kohm resistor
  • 4.7 uF, 25V aluminum electrolytic capacitor radial leads
  • (2) 3-pin 0.1" Female header, (1) 3-pin 0.1" Male header
  • 10K trim pot - Adafruit.com, ID: 356 or similar
  • JST-PH Battery Extension Cable - 500mm - Adafruit ID: 1131 or similar

Tools:

  • Soldering iron
  • Multimeter to measure VDC and "Kill a Watt Meter", or similar to measure AC current (both are only needed for initial calibration)
  • Dremal or similar tool to cut away material from plastic enclosure.
  • Wire cutters
  • Screwdriver


Step 2: Build an Extension Cord With ACS712 Module in the Middle

See photo and diagram.

The terminals of the ACS712 module should connect "in series" to the extension cord hot wire. The hot wire connects to the skinny prong of the plug - it is usually a black wire. It doesn't matter which ACS712 module screw terminals connects with which wire lead.

I made my cord about 18 inches long, but you can make it longer if needed.

Step 3: Build, Test, and Calibrate the Signal Conditioning Circuit Board

See photo and circuit diagram.

Build.

Solder the components to the perf. board as shown. I used point to point wiring method.

Test.

a) Make the following connections:

  1. Signal Conditioning Circuit Board input side GND, Signal, and +5VDC lines to GND, OUT and VCC pins of ACS712 module
  2. Signal Conditioning Circuit Board output side GND +5VDC lines to 5VDC power source.
  3. Signal Conditioning Circuit Board output side GND and A/D pin lines to Multimeter set to VDC range.
  4. Extension cord female plug to a variable AC load - I used a 3 way light bulb (50W, 200W & 250W)
  5. Extension cord male plug.to Kill A Watt meter (set to AC Current range) which is then plugged into AC wall outlet.

b) Test method:

Gradually increase the AC load. The VDC at the multimeter should increase as the AC is increased, as should the Kill A Watt meter Amp readings.

Adjust the Trim Pot of the Signal Conditioning Circuit Board so that at with no AC load the VDC signal is around zero. You may not be able to get it all the way down to zero VDC. I got 0.463 VDC with no AC load.

Calibration.

Using the above test setup, apply a variable AC load and measure AC current load (AMPS) and the VDC signal output. (See the data table I recorded using the 3 way lightbulb mentioned above) This is your calibration data, with the volts being the "X" value and amps the"Y" value.

Plug this data into a spreadsheet or a pocket calculator with linear regression function to determine the trend line equation.

For my data, I got the following calibration equation using Excel:

y = 1.9545X - 0.8035

So for 1.0 VDC, the AC current would be 1.151 A

Step 4: Installation in Plastic Enclosure & Use

Install.

Cut down the vertical ribs as shown so that the circuit board will fit inside.

Cut 3 slots along the top edge as shown to hold the extension and signal cables in place. The slots should be a little shallow so that the lid kind of crimps the cables in place.

A small screw or hot glue will hold the signal conditioning board in place, the ACS 712 module is just held in place by the extension cord.

To Use.

Connect the AC load you wish to measure up to AC outlet using the extension cord and run the signal cable GND, +5VDC and A/D Pin lines into your microcontroller. Remember to convert the measure DC voltage value to AC Amps using your calibration equation.

Final Comment.

I find this device quite similar to a commercial product known as a "Powerswitch Tail," sold by Adafruit.com and others. The Powerswitch Tail allows a microcontroller to easily and safely turn on AC loads, while the device I've shown here allows measurement of AC current loads, so perhaps this could be a commercial product someday?

Powerswitch Tail

<p>Hi can it measure small current, let say around 10mA ?</p>
<p>It doesnt work for me :/</p><p>Is the problem in my integrated circuit? I used this:</p><p><a href="https://www.gme.sk/data/attachments/dsh.310-517.1.pdf" rel="nofollow">https://www.gme.sk/data/attachments/dsh.310-517.1....</a></p>
What is the maximum current this circuit can measure? From the trend line I can see for maximum 5v reading it can go for max of 10 amps reading. Please confirm.
<p>This would depend on the board used. 712 is a 10amp board but you can get up to 30am I've found.</p>
<p>so this tut is good and the only one I can find on the hall effect sensor but what I am trying to build is a circuit that will sense how much current is moving though a DC circuit then based on the value being over or under a predefined amount turn an led on or off.<br><br>I am not sure on the specifics yet but will be looking at a 5v circuit with a small current. <br><br></p>
<p>how about the wave from acs712? can i see?</p>
<p>Cool. Thanks for sharing this!</p>
<p>Do it in software. Cheeper then hardware.</p><p>/*</p><p>Measuring AC Current Using ACS712</p><p>*/</p><p>const int sensorIn = A0;</p><p>int mVperAmp = 66; // use 100 for 20A Module and 185 for 5 Module</p><p>double Voltage = 0;</p><p>double VRMS = 0;</p><p>double AmpsRMS = 0;</p><p>void setup(){ </p><p> Serial.begin(9600);</p><p>}</p><p>void loop()</p><p>{</p><p> Voltage = getVPP();</p><p> VRMS = (Voltage/2.0) *0.707; </p><p> AmpsRMS = (VRMS * 1000)/mVperAmp;</p><p> Serial.print(AmpsRMS);</p><p> Serial.println(&quot; Amps RMS&quot;);</p><p>}</p><p>float getVPP()</p><p>{</p><p> float result;</p><p> int readValue; //value read from the sensor</p><p> int maxValue = 0; // store max value here</p><p> int minValue = 1023; // store min value here</p><p> uint32_t start_time = millis();</p><p> while((millis()-start_time) &lt; 1000) //sample for 1 Sec</p><p> {</p><p> readValue = analogRead(sensorIn);</p><p> // see if you have a new maxValue</p><p> if (readValue &gt; maxValue) </p><p> {</p><p> /*record the maximum sensor value*/</p><p> maxValue = readValue;</p><p> }</p><p> if (readValue &lt; minValue) </p><p> {</p><p> /*record the maximum sensor value*/</p><p> minValue = readValue;</p><p> }</p><p> }</p><p> // Subtract min from max</p><p> result = ((maxValue - minValue) * 5.0)/1023.0;</p><p> return result;</p><p>}</p>
<p>Can you please explain the code ? </p>
<p>Thanks for the idea, I tried the code you suggest, using int mVperAmp = 185; for my 5 amp ACS712 sensor.</p><p> With no current draw - that is the AC power line disconnected, the code results were 0.27 to 0.35 amps RMS, with 50W incandescent bulb load (0.43 amps per Kill a watt meter) the code result was 0.49 to 0.53 amps RMS, with 200W incandescent bulb (1.75 to 1.81 amps per kill a watt meter) the code result was 1.39 to 1.48 amps RMS, and with 250W incandescent bulb (2.17 to 2.19 amps per Kill a watt meter) the code result was 1.68 to 1.72 amps RMS. </p><p>My household AC line voltage was about 125 VAC per Kill a Watt meter. My Arduino UNO was powered by the USB port of my computer.</p><p>I had a 2nd AS712 module, so I repeated the test with nearly identical results. </p><p>So my conclusion is the code results are too high at no or low current and too low at higher current levels - least in my real world testing. Perhaps the code would work better if a had laboratory grade household AC power in my house.</p>
<p>In the source sketch is used 1024, and why do not you use the coefficient?</p>
<p>This code you have written is for which controller ?</p><p>Can you please provide code for pic18f4550 or any source or reference for the same.</p>
The set h came from here.<br><br>http://henrysbench.capnfatz.com/henrys-bench/acs712-arduino-ac-current-tutorial/
Sorry, not &quot;set h&quot;, but sketch
<p>Thank you for your reply. But as my project is based on PIC18F4550 Micro-controller, can you provide me code or reference for the same</p>
<p>Thank you. This helpde me for my project. can you please tell me how to interface/connect acs712 with pic18f4550 and also the code for the same.</p>
<p>what about of the negative value in the measure of the ac current with acs 712 30a</p>
<p>You need to use two current sensor to eliminate negative value. At this situation he didn't mention to that I think. </p>
<p>https://dutraleo.wordpress.com/2013/07/28/acs-712-em-corrente-alternada-ca/</p>
<p>Please suggest what changes are required in the circuit if I wish to use 30 Amp sensor instead of 5 Amp sensor used in the above description. I am an electrical engineer having less knowledge of electronic circuits.</p>
<p>Hello, I wish to ask you for the use of an operational amplifier from LC Tech, made around LM358 (http://www.lctech-inc.com/Hardware/Detail.aspx?id=13a99e81-4d35-44ab-b1e9-f24228c4be7f). I think can be used to amplifi the output from ACS7212 es well. </p>
<p>Can this setup be used to measure current value of 230 V AC supply</p>
<p>Hi. I think this is a great write-up. I've got all the parts ordered and being shipped to me.</p><p>I'm not too experienced with reading wiring diagrams, so it would really help me to have a photo of the under side of the board showing the soldering connections.</p>
<p>Hi, I think the 100K resistor (R1) should not be parallel with OPAMP output,instead it should be series to OPAMP output and C1 as the maximum capacitive load LM258 can handle is 50pf and you are using 4.7uf! </p>
<p>I may have missed something here, but you have not said much about the placement of the cord relative to the sensor. The field from an infinite straight line conductor falls off as the inverse function ( 1/r ) so it is good to be close ( strong signal ) and fixed ( or calibration will change ). For 2 parallel conductors the 1/r dependence is changed. With 0 distance between the centers of the two conductors there is no field at all. Hence separating the conductors may help, with proper placement the field will add at the sensor. I think it would be worthwhile to look into these issues.</p>
<p>ACS712 is an invasive Hall effect sensor and the sense conductor is built on the chip at appropriate distance for the effect.</p>
<p>Hi,</p><p>what is the wattage value of all resistors ?</p>
<p>So ACS712 can directly be connected with mains?</p>
<p>Is the value of current calculated is its rms value ?</p>

About This Instructable

146,253views

98favorites

License:

More by e024576:Small Parts Rack From Repurposed Chick-Fil-A Fruit Cups Magnetically Attached Small Part Bins Arduino Controlled Game: Pong-Bot Vs Human  
Add instructable to: