RFM12B Blocking

I have recently added a home brewed weather station module to my home automation system and whilst it worked ok initially I'm now finding that after it starts transmitting data my Raspberry mounted RFM12Pi V2 stops receiving not just this new node but my other 2 nodes located elsewhere in the property. I'm thinking perhaps the transmission is failing and retrying and results in the same thing occurring for the other nodes as they all try to resend after not receiving acks.

If I switch off the weather station the other 2 nodes reappear again

Has anyone else experienced this kind of problem ?

Below is the arduino code I use for transmitting data via the RFM12B, I took out the power saving stuff as the weather station is mains powered via a 12v supply (Arduino Pro Mini)

#define USE_ACK           // Enable ACKs, comment out to disable
#define RETRY_PERIOD 5    // How soon to retry (in seconds) if ACK didn't come in
#define RETRY_LIMIT 5     // Maximum number of times to retry
#define ACK_TIME 10       // Number of milliseconds to wait for an ack

typedef struct {
     int temp;     // Temperature reading *10
     int humidity;     // Humidity % *10
          int gust;         // Peak Wind Speed in mph*100
          int wind;         // Average Wind Speed in mph*100
          int angle;        // Wind Direction in degrees * 10
          int tips;         // Rain Bucket Tip Count 0.44 mm of rain per tip
          int temperature;  //Temperature from BMP085 * 10
          int pressure; //Pressure from BMP085 in mBar
          int brightness;   //Brightness Value (0-1023)
} Payload;

Payload datatx;

//--------------------------------------------------------------------------------------------------
// Send payload data via RF
//-------------------------------------------------------------------------------------------------
static void rfwrite(){
  #ifdef USE_ACK
   for (byte i = 0; i <= RETRY_LIMIT; ++i) {  // tx and wait for ack up to RETRY_LIMIT times
      while (!rf12_canSend())
      rf12_recvDone();
      rf12_sendStart(RF12_HDR_ACK, &datatx, sizeof datatx);
      byte acked = waitForAck();  // Wait for ACK
      if (acked) { return; }      // Return if ACK received
 
   delay(RETRY_PERIOD * 1000);     // If no ack received wait and try again
   }
  #else
     while (!rf12_canSend())
     rf12_recvDone();
     rf12_sendStart(0, &datatx, sizeof datatx);
     return;
  #endif
}

// Wait a few milliseconds for proper ACK
#ifdef USE_ACK
  static byte waitForAck() {
   MilliTimer ackTimer;
   while (!ackTimer.poll(ACK_TIME)) {
     if (rf12_recvDone() && rf12_crc == 0 &&
        rf12_hdr == (RF12_HDR_DST | RF12_HDR_CTL | myNodeID))
        return 1;
     }
   return 0;
  }
#endif

Similar code is used for the other 2 nodes although I'm thinking of making changes so at least the retries get staggered differently for each node and they don't block each other (if indeed this is what is happening)

Bra1n's picture

Re: RFM12B Blocking

I've disabled Acks on the weather station and all nodes are now being received ok but I'd still like to know why the errant node not receiving an Ack apparently blocks the RFM12Pi V2 for all nodes

Comment viewing options

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