I am trying to use standard examples provided in RF24Network library.
- Have a Arduino UNO connected to NRF24L01 Module. (TX)
- and I have 4 Arduino Mega 2560 boards connected to NRF24L01 each. (RX)
I am trying to send transmit data to all 4 nodes in a loop, but only 3 of them are successfully receiving the data and 4th node always fails.
/******MY TX CODE *********/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
const uint16_t BASENODEADDRESS = 00;
const uint16_t NODEADDRESS[] = {01,02,03,04};
const char *TXSTRING[] = {"Hello to 01 from BASE","Hello to 02 from BASE","Hello to 03 from BASE","Hello to 04 from BASE"};
int CHILDNODES = 4;
char ACKSTRING[32]="";
RF24 radio(7,8);
RF24Network network(radio);
void setup() {
Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(90, BASENODEADDRESS);
}
void loop() {
network.update();
// put your main code here, to run repeatedly:
for (int i=0; i < CHILDNODES ; i++ )
{
Serial.println("++++++++++++++++++++++++++++++++");
Serial.print("SENDING TO : 0");
Serial.println(NODEADDRESS[i],OCT);
Serial.println("++++++++++++++++++++++++++++++++");
RF24NetworkHeader header(NODEADDRESS[i]);
bool SENDOK = network.write(header,&TXSTRING[i],sizeof(TXSTRING[i]));
if(SENDOK)
{
Serial.print("Sent to: 0");
Serial.println(NODEADDRESS[i],OCT);
bool RECOK = network.read(header,&ACKSTRING,sizeof(ACKSTRING));
if(RECOK)
{
Serial.print("ACK RECEIVED from : 0");
Serial.println(NODEADDRESS[i],OCT);
Serial.println(ACKSTRING);
Serial.println("++++++++++++++++++++++++++++++++\n\n\n\n\n\n\n");
}
else
Serial.println("NO ACK RECEIVED");
}
else
Serial.println("Sending Failed.");
delay(5000);
}
}
/********* MY RX CODE **********/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(30,31); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t MYADDRESS = 04; // Address of our node in Octal format ( 04,031, etc)
// I AM USING 01,02,03 and 04 as node addresses
const uint16_t BASENODEADDRESS = 00; // Address of the other node in Octal format
char RECStr[32] = "";
char ACKStr[15] = "Hey from: 04";
void setup(void)
{
Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(90, MYADDRESS);
}
void loop(void){
network.update(); // Check the network regularly
while ( network.available() ) { // Is there anything ready for us?
RF24NetworkHeader header; // If so, grab it and print it out
RF24NetworkHeader header2(BASENODEADDRESS);
payload_t payload;
bool ok = network.read(header,&RECStr,sizeof(RECStr));
if(ok)
{
Serial.println("Received from Base :");
Serial.println(RECStr);
bool ok2 = network.write(header2,&ACKStr,sizeof(ACKStr));
if (ok2)
Serial.println("ACK Sent to base");
else
Serial.println("ACK Failed");
}
else
Serial.println("Nothing Received from Base");
}
}
Please help.