Author Topic: Multiple transmit nodes clashing  (Read 393 times)

j3n

  • Newbie
  • *
  • Posts: 1
Multiple transmit nodes clashing
« on: April 07, 2018, 10:33:24 AM »
Hello,
I am working from the gateway and node examples in the Rf69 library. I've moved on to send/transmit the exact same data from multiple nodes to one central receiver. I'm implementing this by changing the Node ID number on the transmitters and having different transmitting periods. However, on the receiving Gateway node I cannot get a consistent stream of data from the multiple transmit nodes. After about 30 seconds one of the transmitters just freezes or 'locks out' in that it no longer sends packets. If I reset the module it starts transmitting again but then the other transmitter will freeze and stop transmitting.

I'm presuming I have data clashing on the receiver code but I'm unsure of my next steps to rectify this. I'm already using an if condition to check which SENDERID the data is coming from. Do I need to do more with off setting the transmitting timings? Any help is much appreciated. Currently I can't go longer than 20-30 seconds without a clash and freeze.

thanks!
Send code is the Node example with NODEID and TRANSMITPERIOD variables changed only.
Receive Code below...

Code: [Select]
#include <RFM69.h>
#include <SPI.h>
//#include <SPIFlash.h>

#define NODEID      1
#define NETWORKID   100
#define FREQUENCY   RF69_433MHZ //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
#define KEY         "sampleEncryptKey" //has to be same 16 characters/bytes on all nodes, not more not less!
#define IS_RFM69HCW    true // set to 'true' if you are using an RFM69HCW module
#define LED         13
#define SERIAL_BAUD 115200
#define ACK_TIME    60  // # of ms to wait for an ack

/* for Feather M0 */
#define RFM69_CS      8
#define RFM69_IRQ     3
#define RFM69_IRQN    3  // Pin 3 is IRQ 3!
#define RFM69_RST     4

int16_t packetnum = 0;  // packet counter, we increment per xmission
RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);
//SPIFlash flash(8, 0xEF30); //EF40 for 16mbit windbond chip
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network

typedef struct {
  int           nodeId; //store this nodeId
  unsigned long uptime; //uptime in ms
  int           Pot_0;
} Payload;
Payload theData;

void setup() {
  Serial.begin(SERIAL_BAUD);
  // Hard Reset the RFM module
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, HIGH);
  delay(75);
  digitalWrite(RFM69_RST, LOW);
  delay(75);


  delay(10);
  radio.initialize(FREQUENCY, NODEID, NETWORKID);
  //radio.setHighPower(); //uncomment only for RFM69HW!
  radio.encrypt(KEY);
  radio.promiscuous(promiscuousMode);
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);
  Serial.println(buff);

}

byte ackCount = 0;


void loop() {
  //process any serial input
  if (Serial.available() > 0)
  {
    char input = Serial.read();

  }

  if (radio.receiveDone())
  {



    if (radio.SENDERID == 5)//Check if the packet destination is this radio (NODE 5)
    {
      Serial.print('['); Serial.print(radio.SENDERID, DEC); Serial.print("] ");
      Serial.print(" [RX_RSSI:"); Serial.print(radio.readRSSI()); Serial.print("]");


    }

    else if (radio.SENDERID == 8) //Check if the packet destination is this radio (NODE 8)
    {
      Serial.print('['); Serial.print(radio.SENDERID, DEC); Serial.print("] ");
      Serial.print(" [RX_RSSI:"); Serial.print(radio.readRSSI()); Serial.print("]");

    }

    if (radio.DATALEN != sizeof(Payload)) {
      Serial.print("Invalid payload received, not matching Payload struct!");
    }

    else
    {
      theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else
      Serial.print(" nodeId=");
      Serial.print(theData.nodeId);
      Serial.print(" uptime=");
      Serial.print(theData.uptime);
      Serial.print(" data=");
      Serial.print(theData.Pot_0);
      Serial.println();
      Blink(LED, 3);
    }

  }
}
void Blink(byte PIN, int DELAY_MS)
{
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN, HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN, LOW);
}

TomWS

  • Hero Member
  • *****
  • Posts: 1892
Re: Multiple transmit nodes clashing
« Reply #1 on: April 07, 2018, 10:50:09 AM »
Your transmitter code might be more useful in this case since that's what's hanging.  From your receiver code I presume you're just using radio.send() rather than sendWithRetry()?

What processor are you using on the transmitter?

Tom