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.