Measure voltage and amperage drawn by an Arduino?

so I'm in a green engineering class in high school, and my friend and I have been tasked with a special project, measuring the amount of power drawn by an arduino so that we can determine the energy efficiency of each person's project (automated model homes).

My plan is to run the DC wall power supply through a circuit that will determine the voltage and amperage drawn by the arduino from the DC wall power supply, and then output the power to the Arduino (where it was going originally. The big problem here is that I don't know the equivalent resistance of the Arduino, because it varies as the Arduino does different things (turns on motors, blinks lights, etc.).

As the output of this ammeter/voltmeter circuit I would like to have two leads that output an analog voltage that correlate to amperage and voltage, which I can then read from Arduino code.

The code is not the problem here (duh, this is an EE site), I just don't know enough about circuits to make an ammeter that has an analog output.

For voltage, I thought about just running the positive of the power supply to an analog pin with a 5MOhm resistor in between. Would this work?

• Don't you think 5 Megohms is a bit high? If you mean 5m ohm (0.005 ohms), to resolve 1mA you'd need to be able to reliably resolve 5uV. Do you have a meter that will measure that? If you have a 200mV range on a 4-1/2 digit meter, you could resolve 2mA, which might be okay. Commented Jan 24, 2014 at 22:11
• For what it's worth, arduinos are crap with regard to low-power operation. The ATmega328P can manage extremely low power draw with some clever programming, but the arduino boards have lots of peripherals that you cannot turn off, and draw lots of quiescent current. You should be aware that this will likely inject a large static offset in your current-draw readings. Commented Jan 25, 2014 at 5:50
• @ConnorWolf thanks for the insight, that is good to know. This is more of a school-project challenge, but if you have any insight on how to counter this that would be awesome. Commented Jan 26, 2014 at 23:19
• Measure a arduino running a nop loop, and use that for the "base" power consumption. subtract this base draw from the contestant's entries to determine how much power they're using beyond the unavoidable draw of the arduinos. Commented Jan 27, 2014 at 11:10

The best way to do this would be like a real multimeter/ammeter measures current. Put a very low value shunt resistor (<1 ohm) in series with the DC power supply (cut the connection and connect it back together through a resistor). The only thing you have to watch out for in this scenario is that the higher your load, the greater the voltage drop across the shunt.

So, using Ohm's law:

V = IR

Assuming a 20 mA load through a 1 ohm shunt:

V = .02A * 1 ohm = .02mV

So, with a 20 mA load, the shunt drops 20mV. As you can see, using a 1 ohm shunt is particularly convenient because the voltage drop equals the current (20mA results in 20mV drop).

The Arduino has a voltage regulator on board, so as long as the voltage at the Arduino stays above about 6 volts everything should be fine. Keep in mind that this method measures ALL of the current used by the Arduino, including inefficiencies of the linear regulators and the current usage of the AVRs. However, for a rough figure of current consumption this is fine. Remember that power consumption will be the current through the shunt times the wall supply voltage (minus the voltage drop across the shunt, but that will probably be negligible). Since your wall supply voltage is known, you only need a lead showing current.

The fact that you're trying to measure this with an Arduino complicates the issue. You need a common ground between the DC power supply and your measuring Arduino. Depending on the Arduino's power source (if you connect both Arduinos to USB), that means you cannot just choose the more negative lead on the shunt to be ground (doing so would cause a short and probably some smoke). This means you need to design a differential amplifier using an Op-Amp.

This is fairly simple, but I highly recommend you simply use a multimeter to measure the voltage drop across the shunt. This will be both easier to implement and more accurate.

• Right, I came to this realization like an hour before reading this haha. Thanks for the great explanation, +1 and accept. Commented Jan 26, 2014 at 23:18