roysoala on the web

share ideas, documents, and projects

Posts Tagged ‘SCT-013-030

Energy Monitoring using Pachube, Arduino 1.0 and SCT-013-030

with 29 comments

Energy monitoring using Arduino through it’s serial monitor completely well explained by We need some modifications on it to increase the monitoring capability with real time and historical graphical interface like pachube.

There are stuffs we’re gonna use in this project:


1x Arduino + EthernetShield. (i used Uno + Wiznet EtherShield)

Voltage sensing electronics:

1x 230V/9V AC-AC Power Adapter

1x 100kOhm resistor for step down voltage divider.

1x 10kOhm resistor for step down voltage divider.

2x 10kOhm resistors for biasing voltage divider

1x 10uF capacitor (for noise filtering purpose)

Current sensing electronics

1x CT sensor SCT-013-030 (Max 30A)

2x 10kOhm resistors

1x 10uF capacitor

Since we use SCT-013-030 for the CT sensor, we don’t need to use burden resistor because it’s include on the device with 62  Ohms resistance and 1800 turn ratio.

In this project, we want to display Irms and Vrms pachube style graphical. Therefore, we need to get Irms and Vrms from arduino calculation with data source coming  from  Analog ports where sensors connected.

We modify the EmonLib at EmonLib.cpp by adding :

double EnergyMonitor::calcVrms(int NUMBER_OF_SAMPLES)
  int SUPPLYVOLTAGE = readVcc();
    for (int n = 0; n < NUMBER_OF_SAMPLES; n++)
    lastSampleV = sampleV;
    sampleV = analogRead(inPinV);
    lastFilteredV = filteredV;
    filteredV = 0.996*(lastFilteredV+sampleV-lastSampleV);      // Root-mean-square method current
    // 1) square voltage values
    sqV = filteredV * filteredV;
    // 2) sum
    sumV += sqV;
  double V_RATIO = VCAL *((SUPPLYVOLTAGE/1000.0) / 1023.0);
  Vrms = V_RATIO * sqrt(sumV / NUMBER_OF_SAMPLES);
  //Reset accumulators
  sumV = 0;
   return Vrms;
On the EmonLib.h by adding :
double calcVrms(int NUMBER_OF_SAMPLES);
And the sketch gonna be :
#include "EmonLib.h" // 
Include Emon Library EnergyMonitor emon1;             // Create an instance 
void setup() 
 emon1.voltage(2, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift   
 emon1.current(1, 29); // Current: input pin, calibration. Cur Const= Ratio/BurdenR. 1800/62 = 29. 

void loop() {   
double Irms = emon1.calcIrms(1480); // Calculate Irms only   
double Vrms = emon1.calcVrms(1480); // Calculate Vrms only   
Serial.print(Irms); // Irms   
Serial.print(","); //   
Serial.println(Vrms); // Vrms 
with sketch shown  above, we can get Irms, Vrms from serial monitor Arduino.
In order to posting it to pachube to get historical and realtime graphics, use this sketch and modify it to suit your API_KEY on pachube.
With a jQuery touch  plus a lil bit php coding, we can get the interface we want to show; the current status, Irms and Vrms detail  graph powered by pachube.

Written by roysoala

April 20, 2012 at 9:34 am