I’d like to show you how to make an Electricity Monitor for your home that utilises some of the key capabilities of the Arduino Yun or Particle Photon that make them a great choice for Cloud Enabled sensor projects such as this.
Features :
- WiFi connection allows continuous monitoring of Power Consumed
- Utilises TEMBOO for Cloud Support with Google APIs
- Cloud Support: Writes Power Consumption to a Google Drive Spreadsheet
- Graphing, analysis etc.. available via Google Spreadsheet
A nice feature of the project is that the monitoring is flexible and it’s completely wireless (except for the Current Transformer of course), allowing continuous monitoring from a PC or phone and permanent storage on the Cloud.
Measured accuracy was 6% (typical), which is excellent for such a simple circuit. Even better accuracy was observed after calibration.
Step 1: You Will Need

You will Need :
- Arduino Yun
- Alternatively, a Particle Photon
- Current Transformer (e.g. SCT-013-030)
- 2 x 10kOhm Resistors
- 1x 47uF Capacitor
- Some wires, Breadboard
- A 5V Power Supply for the Yun (I used a Smart Phone Charger).
Step 2: Make the Circuit

The circuit is very simple. It consists of a Voltage Divider to bias the ADC of the Arduino to a DC Voltage and Voltage Output Current Transformer to add an AC Voltage proportional to the AC Current flowing in the Cable. The Capacitor forms a Low Pass filter with the resistors to remove noise.
Lots more details are available at the Open Energy Monitor Project.
Build the Circuit as shown here.
Step 3: Arduino Yun / Temboo
Step 4: Electricity Measurement
Step 5: Arduino Measurement Routine
The Complete Arduino Code involves:
- For 5 Seconds
- Take a Sample from the ADC
- Filter Out the DC component from the potential Divider Circuit and noise using a Digital Band Pass Filter
- Calculate the Mean Square (MS) Value of the current (i.e. square the values and get the running Average)
- Calculate the RMS value from the MS value by square-rooting it.
- Multiply by the RMS Voltage (230V in Ireland / UK ; 110V in the USA).
- Scale to allow for the Current transformer gain and ADC.
Here’s the relevant code section
void loop() { // send the value of analog input 0: r2 = r1; r1 = r0; r0 = analogRead(A0); u2 = u1; u1 = u0; // 0.5Hz to 200Hz Band Pass Filter u0 = 0.2929*(r0-r2) + 1.411*u1 -0.4142*u2; v = u0; // Calculate Mean-Square Current (Amps) AMS = 0.99*AMS +0.01*v*v; // Calculate Root-Mean-Square (Amps) Arms = sqrt(AMS); // Convert to RMS Power: // Multipy by 230V (rms) // 30*5/1024 accounts for the gain of the Current Transformer and ADC Prms = 230*30*Arms*5/1024; delay(1);
You don’t need to understand it to do the project but you might find it interesting.
u0 = 0.2929*(r0-r2) + 1.411*u1 -0.4142*u2;It is an IIR filter because it operates on input values (past and present) and its own output values (past and present). The Response of the BPF is shown above.
0.2929 (z+1)(z-1)
=================
(z-0.9952)(z-0.4162)
Step 6: Monitoring the Output
See the Console Window Output as shown in the Picture. The Arduino Code Outputs the RMS Power to the Console every 5 seconds.
The Console is located in the Arduino IDE as though you’re opening a Serial Monitor Window. But when you have an Arduino Yun connected over IP by Tools -> Port this opens the Console instead.
You can access the Console output from your Smart Phone. I use JuiceSSH for Android.
Just setup an SSH connection to your Yun. The default credentials are:
Username : root
Password: arduino
Once logged into the Yun type : telnet localhost 6571
Now your Power Readings will appear on the JuiceSSH Console every 5 seconds.
The Google Docs Spreadsheet is written Once Per Hour. Because the Power is averaged over an Hour the Data in the Spreadsheet will be in Watt Hours.
NOTE: You need to Create a Spreadsheet first with the same name as referred to in the code:
const String SPREADSHEET_TITLE = “ElectricityUsage”;
Also, don’t forget that the Spreadsheet Columns need names in the first row to avoid errors. See the Picture from Temboo previously.
Particle Photon
For the Photon utilises a RESTful interface. So to access the RMS Power for example:
https://api.particle.io/v1/devices/abcabc123/Prms?access_token=ffeffe098098
The interface exposes: Prms, Ptot and result
CALIBRATION:
Make sure the Monitor reads close to Zero when the Transformer is not connected to the mains cable.
Mine read 16Watts. This converts back to 69mA in the mains cable (16W/230V).
Therefore the transformer current is 69mA/1800 = 38uA , and the Transformer output Voltage is 38uA * 62 Ohms = 2.4mV .
This is equivalent to 1/2 LSB of the ADC which is an excellent result; well within the expected accuracy.
Calibrate the Monitor by running it for a day and comparing with the energy consumption recorded on your home’s Electricity meter. Multiply the Prms calculation by this factor so they agree.
My system accuracy was -6%. Which is excellent. Nevertheless I add a 1.06 CAL factor to correct for this.