Using 2 emontx with emonglcd for solar pv

It looks like I have managed to get emoncms reading correctly using 1 emontx for grid with AC AC adaptor (emontx123voltage) and 1 emontx for solar (emontx123).

I cant work our how to get the emonglcd to look at both emontx's and then tell it to use the correct feed? I am using the solarPV firmware as a starting point?

Robert Wall's picture

Re: Using 2 emontx with emonglcd for solar pv

You need to look at the part of the code where having received the RFM12B message, it is decoded. You must duplicate that, i.e. you need two "if (node_id == emonTx_nodeID) { .... }  using the two node IDs for your two emonTx's. That will give you two sets of data, one from each emonTx, which you can then use however you wish.

(The best way to get the data is to have two PayloadTX's, emontx1 & emontx2).

I can go into more detail if you can't figure it out from there.

noworries's picture

Re: Using 2 emontx with emonglcd for solar pv

Cheers Robert, new it would be something like that.

Could you elaborate on the payloadtx bit? i am very new arduino so am still working it all out.

 

Robert Wall's picture

Re: Using 2 emontx with emonglcd for solar pv

PayloadTX is a structure. It behaves in some respects like an int or a float, so having defined the structure, you create an instance of it:

PayloadTx emontx;

that's syntactically identical to writing

double realPower;

Hence you can have as many as you like (two is enough!) with

PayloadTx emontx1, emontx2;

The struct is nothing more than a container. You access the individual parts like:

emontx1.realPower = something;
emontx2.realPower = something_different;

noworries's picture

Re: Using 2 emontx with emonglcd for solar pv

Cheers robert.

A fair amount of guess work but i got it right first time...

Just need to sort the time and base error now.

glyn.hudson's picture

Re: Using 2 emontx with emonglcd for solar pv

Hi Ian, 

Just composed an email to you before I read that you've got it figured. Good work. Anyway for what it's worth here's what I wrote:

 

 

Hi Ian,

Great to hear that you have got the units running and have figured out the firmware upload process.

I would highly recommend you run both emonTx's with an AC adapter and emonTx CT123 Voltage firmware as the solar inverter will have a less than unit power factor which will cause an emonTx without AC adapter measuring apparent power to over read.

What you need to do is to set the Node ID's on the two emonTx's to be different. The default node ID on the emonTx is 10. Both of your emonTx's are set to node 10. You need to set one to be different, let's go for 9 as we recomend the following nomenclature for node ID's
:

-ID-    -Node Type-
0   - Special allocation in JeeLib RFM12 driver - reserved for OOK use
1-4     - Control nodes
5-10  - Energy monitoring nodes
11-14  --Un-assigned --
15-16   - Base Station & logging nodes
17-30     - Environmental sensing nodes (temperature humidity etc.)
31     - Special allocation in JeeLib RFM12 driver - Node31 can communicate with nodes on any network group

To do this open the emonTx CT_123_voltage firmware and change the following on line 48

const int nodeID = 9;

Now we need to tell the emonGLCD to treat data coming from CT1 on emonTx node 9 as solar PV generation and data from CT1 on emonTx Node ID 10 as grid/import export (assuming your system is solar PV type 2 as you suggested to me). Do do this edit  emonGLCD solar PV sketch. We first need to create a new payload for the second emonTx, insert a line to detect an RF packet from the new emonTx and map it to emonTx9.powerX then replace all instances of emonTx.power2 (originally CT2 of emonTx with node ID 10) to emonTx9.power1 (coming from CT1 of emonTx node ID 9).

New structure :

typedef struct { int power1, power2, power3, Vrms; } PayloadTX9;         // neat way of packaging data for RF comms
PayloadTX9 emontx9;

Detect packets from emonTx 9:
  if (rf12_recvDone())
  {
    if (rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0)  // and no rf errors
    {
      int node_id = (rf12_hdr & 0x1F);
      if (node_id == 10) {emontx = *(PayloadTX*) rf12_data; last_emontx = millis();}
      if (node_id == 9) {emontx9 = *(PayloadTX9*) rf12_data; last_emontx9 = millis();}
     
      if (node_id == 15)
      {
        RTC.adjust(DateTime(2013, 1, 1, rf12_data[1], rf12_data[2], rf12_data[3]));
        last_emonbase = millis();
      }
    }
  }

replace all instances of emonTx.powe1 with emontx9.power2:

if (SolarPV_type==2){
    usekwh += ((emontx.power1 + emontx9.power1) * 0.2) / 3600000;
    genkwh += (emontx9.power1 * 0.2) / 3600000;
    }

See attached for changes implemented in emonGLCD sketch.

Maybe sure you are using the latest emonTx_CT123_voltage code from github. I updated the calibration a couple of days ago when testing your units.

 

Best of luck, 

calypso_rae's picture

Re: Using 2 emontx with emonglcd for solar pv

What happens if the two RF messages appear at the same time?

Or is the chances of this happening minimal?

Comment viewing options

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