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

Arduino YUN

Power Supply for YUN

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

 Here are the basic instructions to get started.

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(); 

}