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. 

Plastic Electrical Box from El Lagar (to mount the project)

 Here are the basic instructions to get started.
  1. 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.
  2. Connect the Arduino YUN to your network using the Getting Started instructions on
  3. Create a free emoncms account at:
  4. 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
  5. Upload the sketch to your Arduino YUN
  6. In emoncms click on the Inputs tab
  7. 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.

  8. In the current1 row click on the "wrench" to edit the processes
  9. 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.

  10. Select + input, Node0:current2 and click Add.  This adds current1 and current2 together.

  11. 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.

  12. Node0: current1 config should now look like this:

  13. 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.

  14. Node0: current2 config should look like this:

  15. 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.

  16. Now we are going to create a simple Dashboard.
  17. Go to the Dashboard tab and select +
  18. Using the pencil icon edit the name of your dashboard.
  19. Click on this icon to edit the Dashboard

  20. Select Containers and the color of container you would like.
  21. 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.
  22. 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.
  23. The dashboard should now look like this.

  24. Add text to the top of the container by selecting Text-->heading-center and clicking anywhere to place.  Select Configure to modify the text.

  25. Click on the button that says "Changed, press to save".
  26. Click on the "eye" to view.
  27. Try adding the Visualization rawdata for zoomable historical graphs.  Or the dial widget for a gauge.

#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
  // Initialize Console
  emon1.current(1, 105.0); // Current: Analog input pin, calibration.
  emon2.current(2, 105.0); // Analog inputs A1 and A2 respectively

void loop()


void updateData()
   double valIrms1 = emon1.calcIrms(1480);
   double valIrms2 = emon2.calcIrms(1480);
  HttpClient client;
  String updateURL =  "{current1:" 
            + String(valIrms1) +",current2:" + String(valIrms2) + "}&apikey=" + apikey;
  // Make a HTTP GET request to the API: