This example sketch shows how the same sketch can be written to a large number of devices, which are configured later via Serial input.
#include "RF24Network.h"
#include "RF24.h"
#include <SPI.h>
#include <printf.h>
RF24 radio(7, 8);
RF24Network network(radio);
void setup() {
Serial.begin(115200);
while (!Serial) {
}
while (!mesh.getNodeID()) {
if (Serial.available()) {
mesh.setNodeID(Serial.read());
Serial.print("Set NodeID: ");
Serial.println(mesh.getNodeID());
}
}
Serial.println(F("Connecting to the mesh..."));
if (!mesh.begin()) {
if (radio.isChipConnected()) {
do {
Serial.println(F("Could not connect to network.\nConnecting to the mesh..."));
} else {
Serial.println(F("Radio hardware not responding."));
while (1) {
}
}
}
}
unsigned long displayTimer = 0;
void loop() {
mesh.update();
if (millis() - displayTimer >= 1000) {
displayTimer = millis();
mesh.write(&displayTimer, 'M', sizeof(displayTimer));
}
}
#define MESH_DEFAULT_ADDRESS