Moteino R5 - Transmitting two different sets of data...Is it possible?

Started by G550_Pilot, June 26, 2016, 02:03:38 AM

G550_Pilot

I am attempting to complete a sketch that transmits my water usage based on an interrupt routine (ie - it will only transmit when water is flowing) but also to transmit temperature and pressure data every one minute regardless.

So I started with two different payloads like this:
    // What information are we going to be transmitting back to our gateway?

    typedef struct {                             // RF payload datastructure
      float GAL;
      float GPM;
      float GLM;                                       
    } Payload;
    Payload pool_water;

    // What information are we going to be transmitting back to our gateway?
    
    typedef struct {                             // RF payload datastructure
      int box_temp;
      int filter_psi;                                             
    } SensorPayload;
    SensorPayload pool_sensors;


Then I have a routine set up to transmit water usage but only if there are changes:
    // We only transmit if there are changes to send....


      if (pool_water.GPM!=GPMlast || pool_water.GAL!=GALlast || pool_water.GLM!=GLMlast)  //Check and see if we used any pool_water.....
      {
        power_spi_enable();
    
        if (debug)
           {
           Serial.println("We are going to transmit now.......");
           }
    
        rf12_sleep(RF12_WAKEUP);
        delay(100);
        rf12_sendNow(0, &pool_water, sizeof pool_water);
        rf12_sendWait(2);

        // Make last reading match curent reading until they change
        GALlast = pool_water.GAL;
        GPMlast = pool_water.GPM;
        GLMlast = pool_water.GLM;
    
        power_spi_disable();
       }


And then I have a routine setup that transmits every 60 seconds:

    void take_sensor_readings()
    {
      Serial.println("Getting Sensor Readings...");
      take_ds18b20_reading();
      delay(500);
      get_filter_pressure();
      delay(500);
      power_spi_enable();
      rf12_sleep(RF12_WAKEUP);
      rf12_sendNow(0, &pool_sensors, sizeof pool_sensors);
      rf12_sendWait(2);
      rf12_sleep(RF12_SLEEP);
      power_spi_disable();
      if (debug){
        Serial.print("TEMP: "); Serial.print(pool_sensors.box_temp);
        Serial.print(", Filter PSI: "); Serial.print(pool_sensors.filter_psi); 
        Serial.print(", Sensor Voltage: "); Serial.println(sensorVoltage);
      }
    }


Both of those work great, the only problem is that they are over writing each other when the data is transmitted. As long as I have no water flowing, I get my temp and pressure readings without a problem. As soon as water starts flowing, then those readings are getting overwritten with my meter readings, gallons-per-minute, etc.


I was wondering if there is anyway at all to vary the time data is transmitted as well as what data is transmitted.

Thanks

Felix

What do you mean by "readings are getting overwritten with my meter readings"?
Are you using RFM12b?
Which library are you using?

G550_Pilot

Hi Felix -

These are the libraries I am using and this in on a Mote R5USB

#include <RFM69.h>         
#include <SPIFlash.h>     
#include <WirelessHEX69.h>
#include <EEPROM.h>
#include <SPI.h>
#include <TimerOne.h>

When the temps get sent they are recorded in F like this: 86.2, 89.5

Then when the water meter reading are sent over, they overwrite my recorded reading of 86.2 and 89.5 with 17980 (for example). I am using emoncms to track all of my sensors.

perky

If the receiving is interrupt driven, is there a possibility of the interrupt for the water flow data packet overwriting the data for the regular temperature and pressure data before the main loop has had chance to decode it? If so, maybe it should have two packet structures defined and the two populated independently, or maybe a flag to indicate a receive packet structure is in use which gets cleared by the main code, and new incoming packets are discarded until that 'resource' becomes free? Or maybe the transmitter is overwriting the transmit packet with new data before that resource is free?
Mark.