Unable to address RF24 at level 2

Hi all, hopefully I put this in the correct category as I need help to get a network of RF24 transceivers to talk to each other .

I have 8 nanos and RF24's (8 nodes) all trying to talk to each other.
6 of them play nicely together and work perfectly so there is no problem on the hardware side. These 6 nodes are addressed as 00-05. Obviously at this point I run out of address on level 1 as each node will only talk to 5 other nodes (I think!). So I am trying to get the remaining 2 nodes connected on level 2 via node 01, which is on and working. I have given them addresses 011 and 012 (in octal format) Which I think are the right addresses but as they do not work, maybe not!
I can physically swap all the nodes around and as long as the addresses are kept to 00-05 (and other bits of the sketch are adjusted accordingly), then everything works so I am assuming it is an addressing problem that I don't understand. Any help sorting out how to address level 2 RF24's, assuming that is the problem, would be gratefully appreciated.




#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>

RF24 radio(9, 10);               // CE, CSN
RF24Network network(radio);
const uint16_t mainbox = 00;     //name and address of this node (master node)           // this must be included for all reed switch nodes
const uint16_t scoreboard = 01;  //name and address of score board node (in Octal format )
const uint16_t bluebox = 02;     //name and address of blue box node (in Octal format )
        // 3 other boxes addressed 03-05 all work OK
const uint16_t yellowbox = 011;  //name and address of yellow box node (in Octal format )
       // 1 other box addressed 012 not working
//Set all variables
int incomingdata;
int sendvalue;

void setup() {

  SPI.begin();
  Serial.begin(9600);           // initialize the serial link (monitor)
  radio.begin();                //initialize the RF transceiver
  network.begin(85, mainbox);   //initialize the RF network  //(channel, the address of this node) 
  radio.setDataRate(RF24_1MBPS);
  }

void loop() {
 
  network.update();
  while (network.available())  // Is there any incoming data to the main box?
    {   RF24NetworkHeader header;
        network.read(header, &incomingdata, sizeof(incomingdata));
        {  if (incomingdata == 100) Serial.print("input from node 011 ")  ;  
        }
    }
  delay(250);
  sendvalue = 200;
  network.update();
  RF24NetworkHeader header(yellowbox);                             // Address where the data is going
  bool ok = network.write(header, &sendvalue, sizeof(sendvalue));  // Send the data
    
}
 



``

This is the code for node 00


#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>

RF24 radio(9, 10);               // CE, CSN
RF24Network network(radio);

const uint16_t mainbox = 00;     //name and address of master node          // this must be included for all reed switch nodes
const uint16_t scoreboard = 01;  //name and address of score board node (in Octal format )
const uint16_t yellowbox = 011;  //name and address of box node (in Octal format )

// Set all variables
int incomingdata;

void setup() {

  SPI.begin();
  Serial.begin(9600);             // initialize the serial link (monitor)
  radio.begin();                  //initialize the RF transceiver
  network.begin(85, scoreboard);  //initialize the RF network     //(channel, the address of this node) 
  radio.setDataRate(RF24_1MBPS);
  }

void loop() {

  network.update();
  while (network.available())  // Is there any incoming data ?
    {   RF24NetworkHeader header;
        network.read(header, &incomingdata, sizeof(incomingdata));
    }
    
}
 

This is the code for node 01


#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>

RF24 radio(9, 10);               // CE, CSN
RF24Network network(radio);
const uint16_t mainbox = 00;     //name and address of master node    // this must be included for all nodes
const uint16_t scoreboard = 01;  //name and address of score board node (in Octal format )
const uint16_t bluebox = 02;     //name and address of blue box node (in Octal format )
const uint16_t yellowbox = 011;  //name and address of yellow box node (in Octal format )

// Set all variables
int incomingdata;
int sendvalue;

void setup() {

  SPI.begin();
  Serial.begin(9600);            // initialize the serial link (monitor)
  radio.begin();                 //initialize the RF transceiver
  network.begin(85, yellowbox);  //initialize the RF network     //(channel, the address of this node)  
  radio.setDataRate(RF24_1MBPS);
  }

void loop() {

  network.update();
  while (network.available())  // Is there any incoming data ?
    {  RF24NetworkHeader header;
       network.read(header, &incomingdata, sizeof(incomingdata));
       {  if (incomingdata == 200) Serial.print("input from master node 00 ") ;      
       }
    }
  delay(300);
  sendvalue = 100;
  network.update();
  RF24NetworkHeader header(mainbox);                                // Address where the data is going
  bool ok1 = network.write(header, &sendvalue, sizeof(sendvalue));  // Send the data

}
 


This is the code for node 011

And this is the link to where I got all my info from.

Thank you for your time.

Well your code works fine for me:

-> input from master node 00 
-> input from node 011

The addresses of node 01 children will always end with 1. So 011,021,031 & 041 are all valid children of node 1.
The addresses of node 02 children will always end with 2. So 12,22,32, & 42 are all valid children of node 2.
For node 11, the children will always end with 11. So 111, 211, 311 & 411 are all valid.

Finally, you should try to avoid using delays in your code when using RF24Network. The nRF24L01 radios will buffer up to 3 payloads, but its best to call update() as frequently as possible.

Thank you for your quick reply. The delays were just put in this test code to make sure they weren't all trying to TX/RX at the same time. they're not used in the proper code but I appreciate the tip.

So if there's nothing wrong with the code (I glad about that!) why does it work for you and not me!? I have updated all the libraries to the latest versions. Any ideas what your PC upload or Nano or RF24 is doing that mine isn't?

They are fully working :stuck_out_tongue:

The first thing I would do in your shoes is just run the RF24 gettingStarted example included with the base RF24 library on each node to verify they all work. Then see the RF24/COMMON_ISSUES.md at master · nRF24/RF24 · GitHub document if having any issues. See the printDetails() function to verify SPI communication.

From there I would run the stock RF24Network examples included with the RF24Network library, again to verify. Then I would modify them as follows:

const uint16_t this_node = 01;   // Address of our node in Octal format
const uint16_t other_node = 00;  // Address of the other node in Octal format

Set the addresses and CE/CS pins per your devices.
On master/tx node set this_node = 00, other_node = 011
On one RX node, you want this_node = 01, other_node = 00
On the other RX node, you want this_node = 011, other_node = 00

OK thanks.
I have already run a simple test program on each node to check that the RF24 is communicating with the Nano, all with no problems. I think this verifies the SPI communication. Also, as it all works perfectly when only using level 1 nodes I assume that means they are all communicating OK.

I will work through your suggestions and see if I can make any sense of it all.

Thanks again for your time.

No prob, typically the only reason routing wouldn't be working when comms work at level 1 is a coding issue or strange hardware issue with the radios themselves.

This was the conclusion I came to, so I'm glad you were able to confirm my code was OK.

Regarding hardware issues, some of the RF units came with little 'adaptor' boards and some of the 'adaptor' boards were bought separately. However these boards were a pain in the arse and extremely unreliable and as I think all they were were (very poor) voltage regulators I chucked them all away! I now wire the RF units directly to the Nano boards including the 3.3v direct from the Nano.

Can you confirm that these extra 'adaptor' boards have nothing to do with the actual comms side of things.

Hmm, that might be part of your problems.

I use the adapter boards on most of my Nano or Nano like devices. They convert the 5v down to 3.3v so make sure you hook them up correctly. I would advise using them.

The Nano simply doesn't have the capacity to handle nRF24L01 radios on the 3.3v rail, but you can try modifying the PA Level etc to see if the system functions at a lower power level.

void setup() {

...
  radio.begin();
  network.begin(85, scoreboard);
  radio.setDataRate(RF24_1MBPS);
  radio.setPALevel(RF24_PA_MIN, 0);  <<----ADD THIS

Tried modifying the PA Level as you suggested but didn't make any difference..

So went on to checking hardware, again! and.....

FINALLY sorted.
In the main project, node 01 (scoreboard) is only used to receive and never transmits anything, so there was never a problem. If you look at my 3 little test sketches above, node 01 was not transmitting anything. But of course it was required to transmit when it became a 'parent' and node 011 was transmitting via 01 back to node 00 (main). Although I had swapped numerous boxes for numerous addresses the node 01 always remained the same because it was the only one not required to transmit. Also the scoreboard was the only node that was always on, whereas all the boxes might not always be in use. So it made more sense to make that one the 'parent' node. When I finally kicked the scoreboard into touch and used one of the other boxes as node 01 everything sprung into life.

Don't know if that makes any sense but the short version is - a faulty RF24 that would only receive and not transmit.

So thanks again for your time and confirming the code was OK.
Thanks