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 73Next »
ngpha made it!22 hours ago

hi, Deba. due to short circuit the positive source touch to the arduino, so all of my equiment blow-up -die. I have to build myself a new type. Now i upload it to thingspeak as

here is my new prototype. I make a plastic case for it.

deba168 (author)  ngpha19 hours ago

Hey it looks really very nice.Thingspeak graphs are more eye catching than Xively. Thank you for sharing.

Oh sad thing.I will advice before giving power to the circuit, checkrepeatedly.Though it happened to me also.

Hi Deba.

Great Project. It helps me a lot. I just wanna ask about the LCD display. Did u use the serial or parallel LCD??

Thank you.

deba168 (author)  Noor ShahirahS19 hours ago

Hi Deba.

Great Project. It helps me a lot. I just wanna ask about the LCD display. Did u use the serial or parallel LCD??

Thank you.

BelialD12 days ago

Whould anyone know if the ACS712 is capable of accurate calculations of 0-20mA at 1-30V? I want to make something very similar to this project but calculate the total mA passing through over time.

deba168 (author)  BelialD11 days ago

I think it will work,but you will not get the exact reading.May get some error.

BelialD deba16811 days ago
Any approximation of the error? Do you think it will it be lower than 4%?
deba168 (author)  BelialD6 days ago

You refer the following links for more details on ACS712 current sensor.

ngpha7 days ago
(removed by author or community request)
deba168 (author)  ngpha6 days ago


Hi deba. What if a solar tracker is added to your project? Is it possible to combine your codes with the solar tracker code in one arduino sketch? Is it possible to run your project with solar tracker in a single arduino simultaneously? Just like multi-threading?

deba168 (author)  jaykentchriss6 days ago

I have not tried yet.I think it works.Have a try at your own risk.

sabs.28110 days ago

Hello Sir. How did you get the 696?

thank you.

ngpha sabs.2817 days ago

696 get by the line command


this is the value which the pin 3 in Uno read

RaغibA8 days ago

I'm using Arduino mega 1280. I used the following code, But Ampere values are in negative.

can you help me with this matter?


Measuring Current Using ACS712


const int analogIn = A0;

int mVperAmp = 66; // 66 for 30A Module

int RawValue= 0;

int ACSoffset = 2500;

double Voltage = 0;

double Amps = 0;

void setup(){



void loop(){

RawValue = analogRead(analogIn);

Voltage = (RawValue / 1023.0) * 5000; // Gets you mV

Amps = ((Voltage - ACSoffset) / mVperAmp);

Serial.print("Raw Value = " ); // shows pre-scaled value


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



sabs.28110 days ago

Hello. I have seen your images attached. Can you please tell me the code to obtain sample1 value which was 927.18?

thank you very much

npitz4 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

deba168 (author)  npitz11 days ago

Sorry friend.I don't know much about the Li Ion Battery Charging.

IzyanA4 months ago

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

deba168 (author)  IzyanA11 days ago

Tell me the exact problem you are facing.I will help you.

ngpha made it!1 month ago

I ask my friend do it for me. Now I can't upload it to I want to upload my data on can someone help me the code. Thanks

deba168 (author)  ngpha11 days ago

Hey it looks great.

Good day!.. Your project is great.... What if a 12 volts battery will be used?... Do we need to use the same 10 kilo ohms resistances of the voltage divider? or do we need to change it to a higher value in order the ardiuno will not damage?.. Sorry my english :) ...

deba168 (author)  jaykentchriss11 days ago
miragempro18 days ago

Thanks for the tutorial, I was looking for one of those. but I would like to know how to make a program that displayed the value in US dollars spent, for example: I want a dimmer to shower, and want to know how much I spent in real (Brazil's currency) or US dollars, the time that I was in the shower, an example would be 10 10-minute bath what it would cost in US dollars? that would be displayed on the LCD and stored. And put a password, limiting shower time my son in 10 minutes and when the time is up, the water cools, the doubt is how to code. a hug

GiovanniQ2 months ago

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

deba168 (author)  GiovanniQ1 month 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.

auva.pearl5 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.pearl4 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 masiwal6 months ago

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

But I get the output in Volt.


karcsika9227 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)  karcsika9227 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)  karcsika9227 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)  karcsika9227 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)  karcsika9227 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.

1-40 of 73Next »