Monitoring multiple emonTx units

Are there plans to allow for multiple emonTx to be monitoried through a single emonBase unit?

I currently want to monitor 3 or 4  power points but they are located some distance from each other.

 

I've seen (overpriced) commercial units that will allow 3 separate monitor points via a single controller.E

EDIT: OK a bit more reading has answered my question :-)

glyn.hudson's picture

Re: Monitoring multiple emonTx units

Yes, it's possible. Just set the emonTx's to all be on the same frequency, network with individual node ID's. Then tell the emonBase to separate out the wireless data from the separate emonTx's

We have an emonBase example using the EtherShield library, this library in no longer supported. We have moved to using the EtherCard (see latest NanodeRF github examples), it shouldn't be too difficult to move the example to use the EtherCard library. https://github.com/openenergymonitor/NanodeRF_ethershield/tree/master/nanodeRF_recieve_multiple_emontx

The code example is just a quick demo and could be improved. It would be great to get a page on the website detailing how more than emonTx can be used with a single emonBase. We would be very graceful if in the future maybe you could write such a page. 

Andygodber's picture

Re: Monitoring multiple emonTx units

Im using one Base to read from 3 TX's.

First is for Elect PV generated, second is for Import/Export, third is for water/gas.

Im using the multi Pachube/EmonCMS sketch provided by by Francois which solved my Pachube posting issues, documented in thread: http://www.openenergymonitor.org/emon/node/376

The bits I changed to cope with with multiple TX's are basically to make sure each TX has a different node ID.

Then in the Base code, ensure you have code to extract the node ID from the RF:

byte emontx_nodeID=rf12_hdr & 0x1F;   

Finally, in your main processing code, use logic to do what you want based on the nodeID being sent:

 

 if (emontx_nodeID ==10) 
   {
   grid=emontx.power; 
   batt=emontx.battery;
   }
     if (emontx_nodeID ==11) water=emontx.irms; 
    if (emontx_nodeID ==12) generated=emontx.power;  generated=abs(generated);  if abs(generated<10) generated=0; //remove noise
 
My code is really dirty (look at how many abs functions Ive got !), but you get the gist of it.
 
Things to be aware of:
1. The more devices you have transmitting, the more risk of 'losing' data (there is a post somewhere about how 'crowded' 433Mhz and 868Mhz bandwidths are, with RF12B's getting swamped).
2. The RF is all asynchronous, so there is a risk that you could get two nodes transmitting at exactly the same time and you miss one of them in your code (I see this happen, even with only 3 TX's).
3. Increasing/keeping the transmission intervals different can help reduce 2. Im mostly using realtime transmissions, so thats why I suffer from loss, but its not important.
 
PeterN's picture

Re: Monitoring multiple emonTx units

Hi, I  would also like to build monitor with multi emontx towards on single emonbase. I currently have two emontx and one NanodeRF but no luck adapting the standard NanodeRF_Power_RTCrelay_GLCDtemp yet. The code will work with either emonTx node id 10 or 11 individually defined in // 1 on receive .   I think my problem is blue colored code:  Thanks in advance

 

All suggestions welcome:

if (rf12_recvDone()){

if (rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0)

{

int node_id = (rf12_hdr & 0x1F);

if (node_id == 10) // EMONTX

{

emontx = *(PayloadTX*) rf12_data; // get emontx data

Serial.println(); // print emontx data to serial

Serial.print("1 emontx packet rx");

last_rf = millis(); // reset lastRF timer

delay(50); // make sure serial printing finished

// JSON creation: JSON sent are of the format: {key1:value1,key2:value2} and so on

str.reset(); // Reset json string

str.print("{rf_fail:0"); // RF recieved so no failure

str.print(",power1:"); str.print(emontx.power1); // Add power reading

str.print(",power2:"); str.print(emontx.power2); // Add power reading

str.print(",power3:"); str.print(emontx.power3); // Add power reading

str.print(",voltage:"); str.print(emontx.voltage); // Add emontx battery voltage reading

data_ready = 1; // data is ready

rf_error = 0;

}

if (node_id == 11) // second EMONTX

{

emontx2 = *(PayloadTX2*) rf12_data; // get second emontx2 data

Serial.println(); // print second emontx2 data to serial

Serial.print("2 emontx2 packet rx");

last_rf = millis(); // reset lastRF timer

delay(50); // make sure serial printing finished

// JSON creation: JSON sent are of the format: {key1:value1,key2:value2} and so on

 

str.reset(); // Reset json string

str.print("{rf_fail:0"); // RF recieved so no failure

str.print(",power11:"); str.print(emontx2.power11); // Add power reading

str.print(",power12:"); str.print(emontx2.power12); // Add power reading

str.print(",power13:"); str.print(emontx2.power13); // Add power reading

str.print(",powerFactor:"); str.print(emontx2.powerFactor); // Add emontx powerFactor reading

str.print(",MainsVoltage:"); str.print(emontx2.Vrms); // Add emontx mainvoltage reading

 

data2_ready = 1; // data2 is ready

rf_error = 0;

}

if (node_id == 20) // EMONGLCD

{

emonglcd = *(PayloadGLCD*) rf12_data; // get emonglcd data

Serial.print("5 emonglcd: "); // print output

Serial.println(emonglcd.temperature);

emonglcd_rx = 1;

}

}

}

 

glyn.hudson's picture

Re: Monitoring multiple emonTx units

Hi Peter,

What you have posted looks like it should work, please post up the whole sketch, it would be good to check what you have at the beginning and in setup. 

PeterN's picture

Re: Monitoring multiple emonTx units

It's works in part for two emontxs nodes when certain code was omitted  e.g. // code is inserted  to remove the one line of code for emontx2 nodeid 11 see attached file in  the section title "// 1) On RF receive" . Search "change peter" to see my changes elsewhere in the basic template.

Once I activated  " //str.print(",MainsV:");        str.print(emontx2.Vrms); "  line of code for emontx2 by removing the // the result in  emoncms was inputs rf_fail =1 and com port output was blank. I tried block another line of code in str.print for emontx2 and open this one (no luck) just to prove it wasn't due to the number of lines of str.print,  it seems to be this one line of code mentioned above causing issue.

Another problem I observed seems to be the delay in getting feeds or updates when second emontx2 was added, seems to my untrained eye that there may be some congestion or overlap. I will monitor the number of rf_fails and other data towards cms.

My emoncms is quiet a mess now with many unused inputs etc. is there an easy way to reset all data or should I just change to new database.

Code attached for emontx and emonbase.

Thanks for support. 

Cheers

Peter

P.S. Hope I'm clear above

 

Comment viewing options

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