arduino energymeter_bb.png

I belong to a village of Odisha, India where frequent power cut is very common. It hampers the life of every one. During my childhood days continuing studies after dusk was a real challenge. Due to this problem I designed a solar system for my home on a experimental basis. I used a solar panel of 10 Watt ,6V for lighting few bright LEDs. After facing lot of hardships the project was successful. Then I decided to monitor the voltage, current, power & energy involved in the system. This brought the idea of designing an ENERGY METER.I used ARDUINO as the heart of this project because it is very easy to write code in its IDE and there are huge numbers of open source library available in the internet which can be used according to the requirement.I have experimented the project for very small rated (10Watt) solar system but this can be easily modified to use for higher rating system.

Energy monitoring by
1.LCD display
2. via internet (Xively upload)
3. Data logging in a SD card

You can also see my other instructables on


Remove these adsRemove these ads by Signing Up

Step 1: Parts Required :

Picture of Parts Required :

1. ARDUINO UNO (Rev-3)

4. RESISTORS (10k ,330ohm)

Step 2: Power and Energy

Power :
Power is product of voltage (volt) and current (Amp)
Unit of power is Watt or KW

Energy is product of power (watt) and time (Hour)
E= Pxt
Unit of Energy is Watt Hour or Kilowatt Hour (kWh)

From the above formula it is clear that to measure Energy we need three parameters
1. Voltage
2. Current
3. Time

1-40 of 49Next »
GiovanniQ23 days ago

Could you post the complete code for current reading please? I need it for a project. Thanks!

deba168 (author)  GiovanniQ21 days ago

You can refer the following link.It explains details on how the hole effect current sensor works.It also include a sample code for current measurement.

IzyanA2 months ago

hai deba! i have a similar project to do. but i cant do with the parts xively. how was it? hmm

npitz3 months ago

Hi Deba, I have similar project to do. But I have to work with 53V 20Ah lithium-ion battery
supply voltage and ACS712 30A. would you explain? please let me
know and share you work kindly, it will be helpful. my email

auva.pearl3 months ago

Hi Deba, I have similar project to do. But I have to work with 230v ac supply voltage. have you done with 230v supply voltage? please let me know and share you work kindly, it will be helpful. my email

deba168 (author)  auva.pearl3 months ago

I have not tried.You can go through the following link

Hey I had one problem in Arduino code for current measurement. Why did you multiplied actual value to 10 in order to get amp value?

deba168 (author)  gaurav masiwal4 months ago

As per data sheet of ACS 712 , analog output = 100mV/A

But I get the output in Volt.


karcsika9226 months ago

Hi deba. I have one question and one sugestion . First the question ,why do you used the : totamps,avgamps,amphr ,where the energy formula only used the watt and time ?
The sugestion is ,if you allready have amp hours use that in the energy formula

deba168 (author)  karcsika9226 months ago

As you have seen in my code I takes 150 samples of current reading with a time interval of 2 millisecond .Now sum all the samples ( total amps) and to get the exact value of current you have to take the mean or avg of the all samples (a method of digital signal processing ).This current reading is more accurate and reliable than the instantaneous value of current (one sample).

Thanks for your suggestion.It will also works.

What i don't understand is that tree parameters in this case

// totamps=totamps+amps; // total amps
// avgamps=totamps/time; // average amps
// amphr=(avgamps*time)/3600.0000; // amphour

without this the energy reading are still right

VOLTAGE : 4.967 Volt
CURRENT :0.061 Amps
POWER :0.302 Watt
ENERGY CONSUMED :0.0040 Watt-Hour

deba168 (author)  karcsika9226 months ago

Yes you can directly use the current reading by writing the analogWrite(A1) without summing and averaging.But the averaging method is more accurate and reliable. amphr is calculated for additional parameter to be displayed in LCD .As I used 16x4 char LCD there is no space for displaying that.If you do not want to use this parameter you can omit it.There is no problem in the final result.

Thank you, i suspected it is for another part of the project , just i thought i missed something. I have a small problem , when i read the energy consumed with the original code , I have the following effect. When i have a load it is ok,the energy meter is counting ok,but when i switch off the load the energy reading value drops to 0.00 . I show you : load on

ENERGY CONSUMED :0.046 Watt-Hour

ENERGY CONSUMED :0.047 Watt-Hour

ENERGY CONSUMED :0.049 Watt-Hour

ENERGY CONSUMED :0.050 Watt-Hour
load off
ENERGY CONSUMED :0.001 Watt-Hour

load on and stars with

ENERGY CONSUMED :0.055 Watt-Hour

deba168 (author)  karcsika9226 months ago

Sorry I mislead something I understood your question wrongly.I thought the averaging of samples.

Energy = volt x current x time WH

As long as your load is present it draws some current ,so you get a some value for energy.

But when the load is disconnected then it draws no current (0 amps).

Energy =volt x 0 x time = 0 WH

Now think if you stored the amps value in a variable, it will go on increase as time elapsed. But we need the current (amps) at that instant.So you have to calculate the average value.

In this case suppose the instantaneous value of current may be zero but total amps variable still hold the previous amps value .So you will not get zero.

But if i comment in the code // the totalamps avgamps and amphr and i left only the amp volt time in the formula.. (i get that mentioned effect,witch now i understand why it is 0 when no load) , but where it is storing that information ? because the amps are only instant actual values and only the time is counting foward

deba168 (author)  karcsika9226 months ago

Any thing placed in the void loop() block is execute infinitely.

Now lets starts from beginning , when the program runs first time the value of totamps=0.0. It enter the loop() and takes a amps reading add to the total amps.

Now totalamps =0 + present reading of amps = x (assume)

In the second iteration totalamps = x + new reading = y (assume)

In the 3rd iteration totalamps = y + new reading

This is the way how it store the previous value.

Yes,I know.

Thank you,but i think i wrote to complicated and I have to exercise my technical description about this kind of things.

The thing is, i taken out the avgamps , totalamps and amphr from the loop and left only the amp,voltage and time product. and still the energy was counting and...I solved this when writing this lines : the time is always iterating and if apply value of curent-voltage it adds up whit the product of time... which is not correct.

PS: sorry for the long comment/chat discussion about the suggestions and opinions

deba168 (author)  karcsika9226 months ago

:) :)

Its OK..

deba168 (author)  deba1686 months ago

One thing now I noticed in my code is that

I used the following calculation

watt =voltage*amps;


But I think this will give you zero as in the calculation of watt I used amps instead of avgamps.

I should use avgamps =totalamps / no of samples

Because if I use the formula avgamps=totalamps/time

then Energy = voltage x avgamps x time = voltage / ( totalamps/time )x time

that means time is cancelled out in numerator and denominator.

I request you try it.If you got the result correctly let me inform so that I will edit my code.

I tried but there we work with the average value and that is no adding up to the energy formula. I am curious now about what i wrote in my previous comment: if i comment in the code // the totalamps avgamps and amphr part and i left
only the amp, volt , time in the formula.. , but where it
is storing that information of previous measurement ? because the amps are only instant and actual
values and only the time is variable and counting forward

Yes,thank you. I missed that,you are right.

KOTSOS57 months ago

Hello my friend, it's a great instructable like the other one you did with the management of solar charger, can you combine these two projects in one so that you can make a use of one arduino and one lcd?

deba168 (author)  KOTSOS57 months ago

I will definitely try.When I tried earlier there are two main challenges I faced

1. Shortage of digital pin in arduino

2. Running out of memory space

Consumption of memory space can be optimized by an efficient software.But I am not a experienced programmer so my software is not much efficient in memory consumption point of view.

Few weeks before I found that a TWI/I2C serial interface board with LCD(which have only 4 wires) also available in the eBay.It will solve the first problem.

The next challenge is only the software part .So I request community members to please help

Ya.... I have used I2C LCD.... Its too perfect to use in projects. Must try it.

deba168 (author)  ajinkyadixit7 months ago

thanks for suggestion..

achand87 months ago

Hello, whats the spec of the solar panel? It looks too big for a 6v panel. What's the charging time of the 5.5Ah battery using your panel on a sunny day?

deba168 (author)  achand87 months ago

My solar panel spec are

5watt ,oc voltage = 10v ,sc current =0.61A .

The picture is actually a 10W,12V solar panel I shown as an example.

I never measured actually how much time it will take..

But I will definitely do this in future..

funky8111 months ago

Hi Deba,

Thanks for sharing this. It's really helpful.
Regarding the number 696 in Voltage calibration, where do you get it?
Do you mind to explain it ?


deba168 (author)  funky8111 months ago

The Vout from voltage divider goes to ARDUINO pin A2.

If I write the code

void setup()




void loop()





Run this piece of code and click the serial monitor you will get a number like may different from 696 .Actually this number represents the ADC value corresponds to the voltage output from voltage divider.So calibrate accordingly.

funky81 deba16811 months ago

Nice...thanks for the answer.

I already vote you. Good Luck brother

deba168 (author)  funky8111 months ago

Thanks brother..

efearon1 deba1687 months ago
Deba168, is it possible to use a shunt resisyor in the place of a hall effect sensor.
deba168 (author)  efearon17 months ago

Yes you can use it..

deba168 (author)  funky8111 months ago

Hey funky for your better understanding I make a real time simulation in 123D circuits.see it in voltage measurement step

svenkatesh39 months ago

can we able to give 230v ac supply as Vin in voltage divider ??

deba168 (author)  svenkatesh38 months ago

venkatesh never do this..otherwise your ARDUINO will fry immediately :(

It is possible to measure 230v ac by arduino but need some tricks.

You have to first step down the voltage to a lower level by using a step down transformer,rectify it and then use a voltage divider to step down further to a voltage less than 5v (because arduino analog pin accept voltage lesser than +5v)

For more details,19287.0.html

yes deba i step down to 12v and made voltage divider output as 3.54v dc...

How do i calculate current in amps i am using Lm358 current sensor circuit can u help me how to calculate using this op-amp ??

Do you mind sending the circuit you used to step down the mains voltage

deba168 (author)  svenkatesh38 months ago

can you show your circuit by which you measure current..?

x8938 months ago

Great works!

I add current meter INA219 on input and out and control in/out consumption.

1-40 of 49Next »