Go Down

Topic: Display The Node Communication Sequence on Multiceiver nRF24l01 (Read 63 times) previous topic - next topic

totagsayogya

Hallo, I'm here creating a project about multiciver communication using nRF24l01. I have succeeded in doing so, but I am having trouble knowing the order of incoming data on the receiving node. Does anyone know how to display the order of nodes that send data on the receiver and can be displayed on the serial monitor

Whandall

Yes, use available(&).

Like in this sketch that needs to filter incoming pipes to reload AckPayload data.

Code: [Select]
#include <RF24.h>

const byte rAddress[] =  "1Node" "2Node" "3Node" "4Node" "5Node";
byte ackData = 1;
byte theMessage[32];

RF24 radio(8, 10);

void loadAckData(byte pipe) {
  radio.writeAckPayload(pipe, &ackData, sizeof(ackData));
  ackData++;
}

void setup(void) {
  Serial.begin(9600);
  radio.begin();
  radio.setChannel(108);
  radio.setDataRate(RF24_2MBPS);
  radio.enableDynamicPayloads()
  radio.enableAckPayload();
  for (byte i = 0; i < 5; i++) {
    radio.openReadingPipe(i + 1, &rAddress[i * 5]);
  }
  loadAckData(2);
  loadAckData(3);
  loadAckData(4);
  radio.startListening();
}

void loop(void) {
  byte pipeNum = 0;
  if (radio.available(&pipeNum)) {
    if (pipeNum == 2 || pipeNum == 3 || pipeNum == 4) {
      loadAckData(pipeNum);
    }
    byte len = radio.getDynamicPayloadSize();
    radio.read(theMessage, len);
    Serial.print(F("received ["));
    Serial.print(len);
    Serial.print(F("] "));
    for (int x = 0; x < len; x++) {
      if (theMessage[x] < 16) {
        Serial.write('0');
      }
      Serial.print(theMessage[x], HEX);
    }
    Serial.print(F(" via "));
    Serial.println(pipeNum);
  }
}

Posting your code could help to help you.
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

Go Up