# How to measure total energy usage of an arduino board

I have a project that I'm currently working on. We have built a green wall, wich consists of plants on a wall

Now, we have a pump situated at the bottom that waters all the plants. There is an arduino board that decides when to put the pump on. Powering it is a solar panel and wind turbine. We want to know how much energy we have saved by using the solar panel and turbine.

Question:

How do I measure the amount of energy, in Wh, used from 00h00 that day? Is there a library? Or is this not possible with Arduino?

Thanks a lot.

To clear up some things

No, the pump is not fueled directly by the Arduino pin. We are using a motor shield.

Yes, there is an accumulator in the circuit. The solar and wind power recharge a battery which in turn powers the components.

I would like to know the entire energy consumed, not just the pump.

• You want to know the current used by the board, not the volts. The volts will be constant. The current will change as the motor turns on/off. Mar 27 '14 at 5:30
• Or more accurately, you want the energy (in Wh, Watt-hour) consumed since 00:00. To calculate the energy, you need the voltage, which is a constant, and the trend of current (in A or mA, Ampère) over time. Mar 27 '14 at 5:40
• Ok i'll try that
– DLJ
Mar 27 '14 at 5:41
• You mentioned a pump: is it directly sourced by an Arduino pin (I hope not). What are the specs for the pump? I guess most energy consumed will come from there, hene you may possibly consider eneegy for Arduino itself negligible. Mar 27 '14 at 5:50
• @jfpoilpret Using solar and wind power, chances are that neither voltage nor current is constant. Otherwise your method is correct. Energy[Wh] = V[V] × I[A] × t[s] / 3600[s/h] Mar 27 '14 at 5:50

In order to calculate the amount of energy you have to calculate the power first.

The relation is

Energy = (Power * Time of usage)

How to calculate the power?

The voltage for each device in the system is constant. What changes is the current withdrawal in each component in the project. The main thing you have here is the pump and how much does it consume current. Usually, you will have on the "plate" of the pump the current withdrawal of it.

Say it consumes 2 Amps. If that is not available there, use a DMM "Digital Multimeter" and connect in series with the pump and measure the amount of current.

If there are any other major/important components in your project just calculate the current withdrawal from them.

Now add up all the currents and say you ended up with 2 Amps.

If all the components are operating at the same voltage, just multiply the total amount of current withdrawal by the voltage. WHY? Because: P(power) = V(voltage) * I(current)

If not, just find the power of each component. Add up all the powers of all you components.

Now you will only have to calculate the energy.

E(Energy) = Power * time

Time here refers to how long is your system working? Is it a full day, couple of hours. IT doesn't matter. Usually to make things easier use time (in terms of hours).

Say your power ended up with 3kW kilo Watt You've run the system for 2 hours every day Energy = 3 * 2 = 6 kWh

If you've kept this for a full month. Energy save in a month = 180kWh.

Just find out how much do the ministry cost for each kWh, and you'll know how much money you've saved!

• I think this formula can't apply asi-is in this case as current consumption will vary dramatically when the pump is on (and that's not always fortunately). Mar 27 '14 at 6:19
• He can find out the starter current ( In rush current) and see how much percentage increase sis that from normal operation. He then can add this percent -just in case- to compensqte for this error. Of course he has to see on avg how many times is he pump turned on. I think that will not make a big difference because the duration of starter current is really small. Mar 27 '14 at 6:26
• I think this can help me a lot. I'll try it and then say what happens. Thanks!
– DLJ
Mar 27 '14 at 19:44

There are some chip that measure current flow (like ACS714). Just be sure to buy a chip that will not fry under your load, and mount it in serie with the pump. That chip will bring an analog (but there a re "smarter" chip witch use i2c or spi) signal to arduino, using the formula on the datasheet you can find out real (well, as always there are small error) current flow.

You should already know the voltage of the pump, but you can easily read it with a similar chip or even a voltage divider, just pay attention if you are using PWM as if it will fake your reading)

Now, as already pointed out by Adel Bibi, you can multiply the voltage of the pump with the current value readed (find power), multiply with the time elapsed from the last measure and sum up with precedent measure (integral of the power by time)

you can do the same on the wind/solar panel, just invert the sign of the current (as you are Producing and not Consuming power) and voilà!

With the accumulator in the system, current draw will increase as that is topped off. The accumulator provides sufficient pressure to drive the system. As system pressure draws down, the pump turns on to bring up the accumulator, with maximum draw nearing cut-off pressure. Taking the total run time of the pump in question (@DLJ) you may chop this up into discrete chunks and measure the draw over those periods, plot that out. I like that greenwall, and I want one. -- Aloha nui loa, MKK edit -- As an aside, even a 12V pump driving the smallest 1 liter accumulator to 250 kPa, will draw up to 3A for a few moments, given the size of your system. What motor shield are you using?