Getting Started with Energy Monitor Shield for the Arduino YUN
The Energy Monitor Shield v0.1 was designed to connect two Current Transformers to the Arduino YUN.
MATERIALS:
Energy Monitor Shield + 2 Current Transformers
Plastic Electrical Box from El Lagar (to mount the project)
Here are the basic instructions to get started.
Connect the shield to the Arduino YUN. Insert the Current Transformers (CTs) into the jacks. Clip the CTs around the primary AC inputs of your residence or office. Try not to die in the process. In this type of installation the direction of the CTs is not relevant. Make sure the clamps are completely closed.
Connect the Arduino YUN to your network using the Getting Started instructions on Arduino.cc
Create a free emoncms account at: http://energia.crcibernetica.com
Copy the code below into a new sketch. The only variable that needs to be edited is the String "apikey". Change apikey so that it is the same as the Write API key found in your Account settings at http://energia.crcibernetica.com
Upload the sketch to your Arduino YUN
In emoncms click on the Inputs tab
After a few minutes the two Inputs current1 and current2 should appear. If nothing appears then go back to step 4 and check your Arduino and code.
In the current1 row click on the "wrench" to edit the processes
Select Log to feed, CREATE NEW: node:0:current1, Feed engine: Fixed Interval with Averaging 15s and click Add. It is important that the interval is 15s. This sends the current1 value to a feed that can be used later in a graph.
Select + input, Node0:current2 and click Add. This adds current1 and current2 together.
Select Log to feed, CREATE NEW: node:0:current_total, Feed engine: Fixed Interval With Averaging 15s and click Add. It is important that the interval is 15s. This will create a feed called current_total that can be used later in graphs.
Node0: current1 config should now look like this:
Go back the Input main tab again. This time in the current2 select the "wrench" to edit. This time we will only need one process. Select Log to feed, CREATE NEW: node:0:current2, Feed engine: Fixed Interval With Averaging 15s and click Add. It is important that the interval is 15s.
Node0: current2 config should look like this:
Now click on the Feeds tab. There should be three Feeds. The Id number is not important but the Names should be exactly what is shown here.
Now we are going to create a simple Dashboard.
Go to the Dashboard tab and select +
Using the pencil icon edit the name of your dashboard.
Click on this icon to edit the Dashboard
Select Containers and the color of container you would like.
Click anywhere on the Dashboard to place the Container. Resize the Container so that it takes us half the screen. Don't worry about the exact size, it can be changed later.
In Visualizations select Realtime and click anywhere on the screen. Don't worry about the error message that says "Authentication not valid". Move and resize the graph so that it is inside the Container. Click on the Configure tab and select the Feed: node:0:current_total. Save changes.
The dashboard should now look like this.
Add text to the top of the container by selecting Text-->heading-center and clicking anywhere to place. Select Configure to modify the text.
Click on the button that says "Changed, press to save".
Click on the "eye" to view.
Try adding the Visualization rawdata for zoomable historical graphs. Or the dial widget for a gauge.
CODE:
#include "Bridge.h"
#include "HttpClient.h"
#include "EmonLib.h" // Include Emon Library
String apikey = "xxxxxxxxxxxxxxxxx"; //emoncms Account--> "Write API Key"
EnergyMonitor emon1;
EnergyMonitor emon2;
void setup()
{
// Initialize Bridge
Bridge.begin();
// Initialize Console
Console.begin();
Console.println("Ready...");
//while(!Console);
emon1.current(1, 105.0); // Current: Analog input pin, calibration.
emon2.current(2, 105.0); // Analog inputs A1 and A2 respectively
}
void loop()
{
updateData();
delay(15000);
}
void updateData()
{
double valIrms1 = emon1.calcIrms(1480);
double valIrms2 = emon2.calcIrms(1480);
HttpClient client;
String updateURL = "http://energia.crcibernetica.com/input/post.json?json={current1:"
+ String(valIrms1) +",current2:" + String(valIrms2) + "}&apikey=" + apikey;
Console.println(updateURL);
// Make a HTTP GET request to the API:
client.get(updateURL);
Console.flush();
}