Emontx Shield + Ethernet Shield

Hello,

I'm already using EMoncms on my own server, but I'm a newbie at the hardware level. I have an arduino uno + ether shield,can I plug the emontx shield on the ethershield, using the emontx sketch and the ethernet library to send variables using http get ?

Thanks in advance

Guillaume

markp's picture

Re: Emontx Shield + Ethernet Shield

I doubt you can stack the ethershield and emontx shield together - there is likely to be pin conflicts, plus there isn't a combined tx + base sketch.

The shield is designed to send readings via the rfm12b back to an emonBase (Nanode or similar).

At some point someone may come up with a way of doing this, though I'm not sure if there are enough pins on an Arduino to handle the TX functions as well as the radio module and ethernet. 

gcarlier's picture

Re: Emontx Shield + Ethernet Shield

Ok thank you, still investigate

guillaume

mharizanov's picture

Re: Emontx Shield + Ethernet Shield

It is possible and I have done it. see my experience here

 

http://harizanov.com/2012/04/rfm12b-and-arduino-ethernet-with-wiznet5100...

glyn.hudson's picture

Re: Emontx Shield + Ethernet Shield

It should be possible, you will need to change the RFM12B CS pin since this is required for Etherent Shield: see emonTx Shield documentation: http://wiki.openenergymonitor.org/index.php?title=EmonTx_Arduino_Shield#Hardware_Setup_Instructions

The Ethernet shield will need to be stacked underneath the emonTx Shield

gcarlier's picture

Re: Emontx Shield + Ethernet Shield

Thank you very much, I will try

Guillaume

gcarlier's picture

Re: Emontx Shield + Ethernet Shield

For information, I've just finished mounting, and it's working, with an Arduino Uno + Ethernet Shield + Emontx Shield, following instructions from the wiki and precious informations from mharizanov , thanks to him, and  I'm posting to Emoncms values from arduino + Ethernet

Still struggling with calibration, CT sensors sends some random values, even if there's nothing plugged on female jack, is it normal ?

Thanks for help

 

Guillaume

parbar's picture

Re: Emontx Shield + Ethernet Shield

I have the same setup with UNO, ethernet card (w5100) but I have made my own shield with a breadboard (one ds18b20 and one CT). Yesterday I connected it up and managed to do some measurements. I just modified the Webserver example supplied with arduino to show values on a webside.

Next step is to send data to emoncms.org. Could you share your arduino code for me?

I also have some more work also with calibrating the CT I used a 47 ohm burden and only had an 5uF cap available but most of the time it seems to delivery reasonable values. I will get an 10 uF capacitor and probably change the burden. I aim to do measurements up to max 30 A (rms) so with higher burden then the 33 ohm recommended should give higher resolution?. Then I will calibrate it.

Thnaks

Pär

Robert Wall's picture

Re: Emontx Shield + Ethernet Shield

"so with higher burden then the 33 ohm recommended should give higher resolution"

When you do that, you run the risk of saturating the c.t., leading to an inaccurate waveform and inaccuracy in the measurements.

gcarlier's picture

Re: Emontx Shield + Ethernet Shield

Hello,

Here's the code I use to send to my emoncms server

 

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,67 };
byte gateway[] ={ 192, 168, 1, 254 };

IPAddress server(192,168,1,10); // Emoncms Server on SYNOLOGY
EthernetClient client;

#define FILTERSETTLETIME 10000 // Time (ms) to allow the filters to settle before sending data

const int CT1 = 1;
const int CT2 = 1; // Set to 0 to disable
const int CT3 = 0;
const int CT4 = 0;


#define freq RF12_433MHZ // Frequency of RF12B module can be RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.
const int nodeID = 10; // emonTx RFM12B node ID
const int networkGroup = 210; // emonTx RFM12B wireless network group - needs to be same as emonBase and emonGLCD

#include <JeeLib.h> // Download JeeLib: http://github.com/jcw/jeelib
#include "EmonLib.h"
EnergyMonitor ct1,ct2,ct3, ct4; // Create instances for each CT channel

typedef struct { int power1, power2, power3, power4;} PayloadTX; // create structure - a neat way of packaging data for RF comms
PayloadTX emontx;

const int LEDpin = 9; // On-board emonTx LED

boolean settled = false;

void setup()
{
         //ENABLE NETWORKING
        pinMode(10, OUTPUT);                  // Ethernet select pin
        digitalWrite(10, LOW);               // Explicitly enable Network
        
  
  Serial.begin(9600);
  Serial.println("emonTX Shield CT123 example");
  Serial.println("OpenEnergyMonitor.org");
  Serial.print("Node:emontx ");
  Serial.print(nodeID);
  Serial.print(" Freq: ");
  if (freq == RF12_433MHZ) Serial.print("433Mhz");
  if (freq == RF12_868MHZ) Serial.print("868Mhz");
  if (freq == RF12_915MHZ) Serial.print("915Mhz");
 Serial.print(" Network: ");
  Serial.println(networkGroup);
             
  if (CT1) ct1.current(1, 59.292); // Setup emonTX CT channel (channel, calibration) 111.
  if (CT2) ct2.current(2, 45.523); // Calibration factor = CT ratio / burden resistance
  if (CT3) ct3.current(3, 111.885);
  if (CT4) ct4.current(4, 38.885);
  
 //emonTx Shield Calibration = (100A / 0.05A) / 33 Ohms
  rf12_set_cs(8);
  rf12_initialize(nodeID, freq, networkGroup); // initialize RFM12B
  rf12_sleep(RF12_SLEEP);

  pinMode(LEDpin, OUTPUT); // Setup indicator LED
  digitalWrite(LEDpin, HIGH);
  
  
}

void loop()
{
  if (CT1) {
    emontx.power1 = ct1.calcIrms(1480) * 233.0; //ct.calcIrms(number of wavelengths sample)*AC RMS voltage
    Serial.print(" "); Serial.print(emontx.power1);
    }
  
  if (CT2) {
    emontx.power2 = ct2.calcIrms(1480) * 233.0;
    Serial.print(" "); Serial.print(emontx.power2);
  }

  if (CT3) {
    emontx.power3 = ct3.calcIrms(1480) * 235.0;
    Serial.print(" "); Serial.print(emontx.power3);
  }
  
   if (CT4) {
    emontx.power4 = ct4.calcIrms(1480) * 235.0;
    Serial.print(" "); Serial.print(emontx.power4);
  }
  
  
  Serial.println(); delay(100);
  

  // because millis() returns to zero after 50 days !
  if (!settled && millis() > FILTERSETTLETIME) settled = true;

  if (settled) // send data only after filters have settled
  {
    send_rf_data(); // *SEND RF DATA* - see emontx_lib
    digitalWrite(LEDpin, HIGH); delay(8); digitalWrite(LEDpin, LOW); // flash LED
    
    delay(15000); // delay between readings in ms
    }
    
        
    // Open serial communications and wait for port to open:
  Serial.begin(9600);
  EthernetClient client;
  
  // start the Ethernet connection:
  Ethernet.begin(mac,ip); 

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected to EMONCMS");
    
    //POWER COULOIR SUR CT1
    client.print("GET /powerbase/api/post?apikey=d356882fe194da4aa72954807&node=1&json={emon_couloir:");
    client.print(emontx.power1); //POST CT1 VALUE
    client.print(",");
    client.print("emon_prises:");
    client.print(emontx.power2); //POST CT2 VALUE
    client.print("}");
    client.println(" HTTP/1.0");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();
    Serial.println("POWERMON COULOIR & PRISES: VALUES SENT");
    delay(500);
    }
    else   {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed TO EMONCMS");
    client.stop();
          }
 
       //STOPPE LA PREMIERE REQUETE
       client.stop();
 
   // ENVOIE LES VALEURS AU SCRIPT PHP
  Serial.begin(9600);
  Ethernet.begin(mac,ip); 

  if (client.connect(server, 80)) {
    Serial.println("connected TO SYNOLOGY PHP");
    
    //POWER COULOIR SUR CT1
    client.print("GET /enermon/emontxdata.php?emon_couloir=");
    client.print(emontx.power1); //POST CT1 VALUE
    client.print("&");
    client.print("emon_prises=");
    client.print(emontx.power2); //POST CT2 VALUE
    client.println(" HTTP/1.0");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();
    Serial.println("POWERMON PHP POSTS COULOIR & PRISES: VALUES SENT");
    delay(500);
    }
 
    else   {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed TO SYNO PHP");
    client.stop();
          }
    
 }

Guillaume

parbar's picture

Re: Emontx Shield + Ethernet Shield

I have the 013-000 and my conclusions from "report-yhdc-sct-013-000-current-transformer" is that it should be out of saturation if Rb is under 200 ohms (for 30 A). I guess I will use something like 70 ohms and be in 50 A area. My mains fuse is 25 Amps. I have access to an variable current source so I will try doing some calibration later. 

Am I thinking right here?

parbar's picture

Re: Emontx Shield + Ethernet Shield

gcarlier  Thanks!! 

 

 

parbar's picture

Re: Emontx Shield + Ethernet Shield

I'm not sure but maybe you should hide the API??

I have no RFM12 so I quess I can skip that part.

Are you sending data to 2 places?

EMONCMS first and then SYNOLOGY PHP

/Pär

gcarlier's picture

Re: Emontx Shield + Ethernet Shield

Hi,

The API key is fake.

I'm sending two CT sensors values to 2 cms different inputs, and then the same values to a PHP script for further processing to others online services like thingspeak or open.sen.se

Guillaume

 

alco's picture

Re: Emontx Shield + Ethernet Shield

Guillaume, do you mind to post an example of that php-script?

I'm currently using COSM and emoncms and now I fetched both JSON strings in the arduino sketch. but that's not an really flexible sollution at all. Because I have to remove my nanodeRF basestation everytime that I wan't to change something for that processing to COSM. So a separate PHP script on my own server would be a nice work-a-round this.

Robert Wall's picture

Re: Emontx Shield + Ethernet Shield

I have the 013-000... 

You might be OK in that case. The test will be to see how much the waveform distorts (both amplitude and phase) with your maximum current and chosen burden. If you are happy with the result, then all is well.

glyn.hudson's picture

Re: Emontx Shield + Ethernet Shield

Sorry for the late reply, but there is a good guide to choosing a suitable sized burden resistor for the power given a certian CT and power monitoring range in the building blocks section here: http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface 

parbar's picture

Re: Emontx Shield + Ethernet Shield

Regarding burden size, I will go for max 50 A => 70 ohm burden (68 or 75 standard values); After calibration I might report it in the Forums, however it can take some time before I have the time.....

 

gcarlier's picture

Re: Emontx Shield + Ethernet Shield

@alco

Here's an exemple in php to post data from arduino to sen.se, using parameters from previous script

guillaume

sensePublishingEvent !
"; echo "Header :
"; print_r ($header); echo "
Url :
".$url."
"; echo "
paramsToPostInJSON :
".$paramsToPostInJSON.""; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POSTFIELDS, $paramsToPostInJSON); $result = curl_exec($ch); curl_close($ch); ?>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.