Introduction: Power Monitoring Using Arduino and Log Into Google Sheet

Picture of Power Monitoring Using Arduino and Log Into Google Sheet

Since last few weeks i was thinking about making a project which can help me in keeping a track on my daily energy usages. In this project i am using a 30A current monitoring board. this board has 6 current sensor which can read upto 30A current. this board comes with an I2C interface and has 4 address lines so you can hookup up to 16 boards on the same I2C master device, which will give you total 96 current monitoring sensors.

to read the current and power calculation i am using an arduino nano with an I2C adapter. This I2C adapter makes easy to connect current monitoring board.

I will also explain how you can write data into an xl sheet and in a google sheet using arduino.

Hardware you need

1. Arduino current monitoring

2. Arduino Nano hat

3. I2C cable

Step 1: Power Monitoring Using Arduino

Picture of Power Monitoring Using Arduino

lets start with arduino code.

in this code i will write a command to read current through I2C.

this code is pretty straight forward, all you need to do is send a command to read current and the Current monitoring board will do everything for you.

In my area the AC voltage is around 120-124V. we will use this voltage reading to calculate the power uses.

in this code i am calculating current,power, watt hour, total watt hour and total kilo watt hour.

//Include Wire I2C Library
#include  <wire.h>
int address = 42; // I2C address
double voltage = 121.7;   //////// voltage reading
double tkWh = 0;
double tWh = 0;
void setup()
{
 
  Serial.begin(9600);  // Create Serial Object (9600 Baud)
  Wire.begin();
}
void loop()
{
 
    Wire.beginTransmission(address); // Start communication
    Wire.write(146); // Command header 
    Wire.write(106); // Command header 
    Wire.write(1);  // Command 1
    Wire.write(1);  // Start Channel no 
    Wire.write(1);  // End Channel no 
    Wire.write(0); 
    Wire.write(0); 
    Wire.write((146 + 106 + 1 + 1 + 1 + 0 + 0) & 255); // CheckSum
    Wire.endTransmission(); // Complete Transmission
    Wire.requestFrom(address, 5); 

   unsigned long MSB1 = Wire.read();
     MSB1= MSB1*65536;
    unsigned long MSB = Wire.read();
    MSB=MSB*256;
    unsigned long LSB = Wire.read();
    MSB1=MSB1+MSB+LSB;
    double current = ((double)MSB1)/(double)1000;  
   
    
    Serial.print(current,3); //// current on ch 1
    Serial.print(",");    
    double Power = voltage * current;  /// power on ch1
    Serial.print(Power,3);
    Serial.print(",");    
    double Wh = 0.000833 * Power;  /// Watt hour on ch1
     Serial.print(Wh,4);
    Serial.print(",");
 
    tWh = tWh + Wh;   /// total watt hour used 
    Serial.print(tWh,4);
    Serial.print(",");
 
     tkWh = tWh/1000;  /// total kilo watt hour used 
    Serial.print(tkWh,4);
  </p><p>    
    Serial.print("\n");
  
    Wire.endTransmission(); // Complete Transmission
   
  
  delay(3000);
}

Step 2: Arduino Power Monitoring Code

Picture of Arduino Power Monitoring Code

after reading the current now we will calculate the power.

power calculations are done in this section of the code.

All you need to do is burn the code in arduino and check your readings on serial port.

Serial.print(current,3); //// current on ch 1

   Serial.print(",");    
    double Power = voltage * current;  /// power on ch1
    Serial.print(Power,3);
    Serial.print(",");    
    double Wh = 0.000833 * Power;  /// Watt hour on ch1
     Serial.print(Wh,4);
    Serial.print(",");
 
    tWh = tWh + Wh;   /// total watt hour used 
    Serial.print(tWh,4);
    Serial.print(",");
 
     tkWh = tWh/1000;  /// total killo watt hour used 
    Serial.print(tkWh,4);

Step 3: Power Monitoring for Different Different Load

Picture of Power Monitoring for Different Different Load

Just for the testing purpose i changed to a different different load just to see if it works with other load, so far it worked great.

you can also find the code on git.

Power monit using arduino

Step 4: Writing Data in a Text File Using Arduino and CoolTerm

Picture of Writing Data in a Text File Using Arduino and CoolTerm

To write data into a text file i am using CoolTerm, its a really simple tool for capturing data.

to setup cool term

1. Download coolterm

2. go to connection >> option

3. select serial port >> port

4. go to connection >> capture to text file

once you setup this it will start writing all the data coming from the arduino into a text file. We will use this data to plot power usages graph.

Step 5: Creating Xl Sheet Using Arduino Data

Picture of Creating Xl Sheet Using Arduino Data

CoolTerm will save all data in a local folder and you can import this file into a XL sheet.

I seprated different different readings with a "," so that i can create tables into the XL sheet. i will suggest if you have multiple data, do the same.

Step 6: Google Sheet Using Arduino

Picture of Google Sheet Using Arduino

Now we will import the arduino data into a google sheet.

its a very simple process please follow these steps:

1. open google

2. go to google sheet

3. create a new google sheet

4. go to file import and select your arduino o/p text file

after doing this google will create a google sheet.

Step 7: Power Monitoring Graph Using Arduino and Google Sheet

Picture of Power Monitoring Graph Using Arduino and Google Sheet

one you have your data imported now you can start drawing graph.

to draw graph please do this.

1. select row 2,3,4

2. go to insert and select graph

here you can choose different different graph plots according to your choices.

Step 8: Miscellaneous

Picture of Miscellaneous

with this product you can keep track on your daily power usages, monthly power usages and plan your power usages according to that. you can also track if there is any devices which is taking too much power.

Comments

vongz (author)2017-01-11

Is it possible to implement a design that measures reactive and active energy pulses? Which sensors can be used

KenS74 (author)2016-12-14

I seem to recall that watts=amps*volts only for DC. For AC you must use W=A*V*cos(phi)/sqrt(2). The sqrt of 2 coverts peak voltage to RMS values (assuming a sinusoidal signal), because in AC you must consider the averages and not the peaks. The angle phi represents the phase angle between the voltage and current. Because these factors lower the Wattage you'll sometimes see vendors quoting the "power" of a device as being so many "VA" or "kVA" since people will see it and think it is equivalent to wattage, which it is not in an AC system.

In any case, you have developed a fine system one which I hope to build myself.

Keep up the good work!

bhaskar.anil429 (author)KenS742016-12-15

thanks.

Yes You are correct about real power, if we want to calculate real power we will need to take care of phase calibration.

but in my case i am measuring power of a resistive load. where real power is equal to the apparent power.

KenS74 (author)bhaskar.anil4292016-12-15

But I think you still need to use RMS unless your devices are already reporting RMS and not peak current and voltage.

bhaskar.anil429 (author)KenS742016-12-15

Yes, it gives RMS values..

petestrash (author)2016-09-26

Hi, both of your links for the current monitoring board link to the 4 channel 70A version. The link to same board you used is https://www.controleverything.com/content/Current?...

Thanks for the Ible.

benvromans (author)2016-06-11

Hi great instrucable, but i was wondering the factor 0.000833 to calculate Wh.

In my opinion it shoot be 0.000278 because W is per second and there are 3600 sec in 1 hour. Can you please explane.

because i am taking readings after every3 sec.

OK. Now i get the picture. You accumulate the 3 sec readings to the total Wh. So you get the total of Wh after a period.

thorathome (author)2016-06-10

I have been looking for something like this for some time. Thanks.

How big (what gauge) wire can the sensor clamps hold?

for more info please check their website....

https://www.controleverything.com/products?f[0]=field_assigned_categories%3A6085&f[1]=field_assigned_categories%3A6601

the diameter of the clamp hold is around 10mm.

About This Instructable

5,258views

41favorites

License:

More by bhaskar.anil429:Interfacing 4-20mA Current Loop Sensors With ArduinoMom I am Fine... IoT Texting ChairWebApp Controlled Relay Using Onion Omega 2 & 1
Add instructable to: