feeds from multiple emontx

Hi,

Before finding OEM I have installed solar PV with a built in Immersun (solar PV diverter) to heat the HW. With this setup I need to monitor the HW temp to decide whether to turn on the immersion heater with mains supply.

A second emontx has been installed to measure the temp in the HW tank. I can see the output in emoncms. I am however struugling to get the display into the glcd. At the moment I am using the Home Energy Monitor software and the room temp quadrant is not needed.

How do you change this to import the 2nd emontx temp, which is running the Low Power Temp module, and display on the glcd in place of the Room Temp?

Regards

Steve

Robert Wall's picture

Re: feeds from multiple emontx

The short answer is you look at the sketch, understand how it works and writes to the GLCD, and you rewrite it to suit!

The long answer is the sketch as it stands is programmed to receive data from two places - an emonTx for energy measurements and an emonBase for the time of day. If you want to keep the time function (probably not?) then you need to modify that roughly in line with the other and then write that second temperature to the display in place of the room temperature, and change the wording too. If you do keep the time from the base, then you need to add a bit more code and that could be a problem as the GLCD is right on the limit of what's possible given the amount of memory available.

If you're happy to pursue that, then I can give you a more detailed steer - which I guess you'd appreciate?

stegr's picture

Re: feeds from multiple emontx

As you've guessed programming is not my forte. The code appears to call functions in other sketches and in doing so confuses me. The problem then arises as to where the differentiation between the two emontx comes.

Time display is a nice to have but no-were near essential so it can be ditched is necessary. If you can give me a more detailed steer then it would be greatly appreciated.

Thanks for the offer.

Steve

Robert Wall's picture

Re: feeds from multiple emontx

Ok, give me a few days

Series530's picture

Re: feeds from multiple emontx

To try to give you a "simple" explanation I'll tell you what I did .... some consider me to be simple!

Data is sent as an RF signal in little packets of information. If every piece of electronics used the same RF signal it would be a mess as everything would be sent and would clash between units. So, what we do is we send some data at some frequencies between units and at a different RF frequency on other units. We also send that information in different formats so as to minimise the chances of data clash. 

With the EMON project the information is all sent at the same basic frequency and in the same format but we allow one unit to differentiate itself from another by allocating a different channel. So, the data sent between one emonTX and the base unit can be sent on one channel while the data between another emonTX unit and the base unit can be sent on a different channel. Then, sending the data from the base unit to the GLCD can be done on a third channel. The trick then is to read the incoming data from each of the emonTX units sequentially based upon looking for channels, then construct something to send to the GLCD which is a concatenation of the received data and send this data out on a different channel to the GLCD or, if you simply read all of the data straight into the GLCD, concatenate the results and choose a place to display them on the screen.

In my sketches I actually have the GLCD and the emon base unit listening to one emonTX simultaneously and I also have the emon base unit listening to another emonTX at the same time as listening to the first one. I then build a new packet of data and send it to the internet. So, my use is slightly different to yours, but the principles still apply.

 

So, the principle of reading is along the lines of the following:

This is a simple example of two payloads. They simply read in a pair of integer values but you can make the payloads whatever you like provided they agree with the structure of the payload which is being sent by each emonTX unit.

 

typedef struct { int MeterReading;
                   int Active ;
                 } PayloadTX; // create structure - a neat way of packaging data for RF comms  
  PayloadTX MeterMonitor;

  typedef struct { int MeterReading;
                   int Active ; int flag;
                 } PayloadTXI; // create structure - a neat way of packaging data for RF comms  
  PayloadTXI ImmersionMonitor;

// This last one is another payload should you wish to transmit a concatenation of results.

 typedef struct { int MeterOut1; int MeterOut2;
                   int Active ;
                 } PayloadTXI; // create structure - a neat way of packaging data for RF comms 
  PayloadGLCD GLCDData;

Here is a snippet of a loop where we read in the payloads

void loop () {

#ifdef UNO
  wdt_reset();
  #endif

dhcp_dns();   // handle dhcp and dns setup - see dhcp_dns ta

if (rf12_recvDone()){     
      if (rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0)  // make sure the data is valid
      {
        int node_id = (rf12_hdr & 0x1F); // read the node id ... essentially the transmission channel
        byte n = rf12_len;

 

        if (node_id==17)  \\ if the channel id is 17 then do this
            {
 
             
                Serial.println(F("Data received from Consumer Meter"));

                MeterMonitor=*(PayloadTX*) rf12_data;

                //Then do stuff based upon what has been read

                Serial.println(MeterMonitor.MeterReading);

            }

        if (node_id==22) \\ if the channel id is 22 then do this
            {   

              
             

                 Serial.println(F("Data received from Immersion Monitor"));

                ImmersionMonitor=*(PayloadTXI*) rf12_data;

 

               //Then do stuff based upon what has been read

                Serial.println(ImmersionMonitor.MeterReading);

              }

         

 

        // Then If you wish to transmit the data to someplace else you can load it into another structure like this

         GLCDData.MeterOut1=MeterMonitor.MeterReading;

         GLCDData.MeterOut1=ImmersionMonitor.MeterReading;

      // and transmit this new payload on a different channel again

        // or you can populate the display with the data along these lines

                    int displayPower=(ImmersionMonitor.MeterReading);
                    sprintf(str1,"%d A",displayPower);
                    glcd.drawString(80,57,str1);

         // or you can simply work with sections of each payload without concatenation

 

                    int displayPower=(int)(GLCDData.MeterOut1);
                    sprintf(str1,"%d A",displayPower);
                    glcd.drawString(80,57,str1);

 

Here now is some data from the emon TX:

// These defines set the frequency and the channel for operation. You will need the same code in your GLCD sketch so that the frequencies and channels match. Note though that the myNodeID definition will be different on each emon TX (17 and 22 for this example 

#define myNodeID 17 //node ID of tx (range 0-30)
            #define network 129 //network group (can be in the range 1-250).
            #define freq RF12_433MHZ //Freq of RF12B can be RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. Match freq to module
  

// Now the payload 

typedef struct { int MeterReading;
                   int Active ;
                 } PayloadTX; // create structure - a neat way of packaging data for RF comms 

  PayloadTX MeterMonitor;

// Now some data populated into the structure

MeterMonitor.MeterReading=100;

// and here is some data being transmitted

rf12_initialize(myNodeID,freq,network); //Initialize RFM12 with settings defined above
           Serial.print("Node: "); Serial.print(myNodeID);
           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(network);
          
           // send a payload with the channel set to 255. This tells the emonGLCD that the system is calibrating        
           // Put the revision code of the software in the vrms variable
          
           int ii = 0; while (!rf12_canSend() && ii<10) {rf12_recvDone(); ii++;} 
           rf12_sendStart(0, &MeterMonitor, sizeof MeterMonitor);

This is the general idea. I hope that this helps a little.

 

Ian

 

 

Robert Wall's picture

Re: feeds from multiple emontx

Ian - I'll leave it to you then to help Steve through this.

Series530's picture

Re: feeds from multiple emontx

Hi Robert and Steve,

 

I'll do what I can but it may be problematic as I'm away all of next week while we launch a new business venture and after that I hope to have very little spare time. 

 

Certainly drop messages and I'll see what I can do. Responding with tried and tested detailed responses may be more difficult.

 

Ian

stegr's picture

Re: feeds from multiple emontx

Thanks for the pointers.

I'm sure it will take me a few weeks to understand and incorporate the ideas into my system.

If and  when I don't understand I'll come back b either way I'll let you know.

 

Regards

Steve

 

Comment viewing options

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