nRF24l01 Addressing problem

Hi, im quite new to Arduino, and im trying to build a large network in my home, up to now this is how should be look:

Everything was ok until i have add the node012.
After may try i have found that changing the value from "const uint16_t this_node = 012;" to "const uint16_t this_node = 021;" this node was able to send the data to node01.

So i tried many configuration and i found that this node can send data successfully only if i assign: 10, 11, 21, 30, 31 and here i just stopped to try.
All other address is not working, there is a reason for this?

Here is my (not beautiful) Sketch in case you want to see:

//============for TX/RX====///
#include "printf.h"
#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>
const int TxRxChannel = 90;      // Channel
RF24 radio(0, 1);                // CE, CSN
RF24Network network(radio);      // Network uses that radio
const uint16_t this_node = 021;  // Address of our node in Octal format ( 04,031, etc)
const uint16_t node01 = 01;      // Address of the other node in Octal format

//=========for TX=========//
const unsigned long interval = 100;  //ms  // How often to send data to the other unit
unsigned long last_sent=0;
const int sizeofTXnode01 = 3;            
uint8_t TXnode01 [sizeofTXnode01];
uint8_t SentTXnode01 [sizeofTXnode01];
unsigned long last_update = 0;   
unsigned long intervalTime=1000*5;   // every x sec.

//=========DHT=========//
#include "DHT.h"
#define DHTTYPE DHT11 
const int DhtPin = 7;       
DHT dht(DhtPin, DHTTYPE);   // Hyumidity and temperature Sensor (DHT)
float DHThum;
float DHTtemp;

//=========BPM085=========//
#include <Wire.h>
#include <Adafruit_BMP085.h>
const int I2C_SCL = 5;      // Barometric Pressure Sensor (BMP085)
const int I2C_SDA = 4;      // Temperature Sensor (BMP085)
Adafruit_BMP085 bmp;
float BMPpress;
float BMPtemp;

float averageTemp;

void setup(void) {
  delay(2000);
  Serial.begin(115200);
  delay(1000);
  radioSetup();
  delay(1000);
  dht.begin();
  delay(1000);
  BMP085setup();
  delay(1000);
  for (int i = 0; i < sizeofTXnode01; i++)TXnode01[i] = 0; //All buffer = 0

  Serial.println("===>>>Wether node 012<<<===");
     
}

void loop(void) {
  unsigned long Now = millis(); 
  if ( Now - last_update >= intervalTime) { // If it's time to send a message, send it!
    last_update = Now;    
    
    DHThum  = dht.readHumidity();
    DHTtemp = dht.readTemperature();
    if (isnan(DHThum) || isnan(DHTtemp)) {
     Serial.println(F("Failed to read from DHT sensor!"));
     return;
    }
    
    BMPpress = bmp.readPressure()/1000.0;
    BMPtemp  = bmp.readTemperature();
    averageTemp = (DHTtemp + BMPtemp)/2;
    
    TXnode01[0] = averageTemp;
    TXnode01[1] = DHThum;
    TXnode01[2] = BMPpress;
  
    //Serial.println("Temperature "+String(TXnode01[0])+"°C; Humidity "+String(TXnode01[1])+"%; Pressure "+String(TXnode01[2])+"kPa");
  
    SendData(TXnode01, sizeofTXnode01, node01);                     // Send  
  }
}

void radioSetup(){
  SPI.begin();
  printf_begin(); //Used to enable printf on AVR devices
  if (!radio.begin()) {
    Serial.println(F("Radio hardware not responding!"));
    while (1) { }// hold in infinite loop
  }
  network.begin( TxRxChannel, this_node);
  //radio.setDataRate(RF24_2MBPS);
  //radio.setPALevel(RF24_PA_MAX); 
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate(RF24_1MBPS);
  radio.printDetails();  
}

void BMP085setup(){
  Wire.begin(I2C_SDA, I2C_SCL);
  delay(10);
  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP085 sensor, check wiring!");
    while (1) {}
  }
  
}

void SendData(uint8_t TX[], int TXSize, uint16_t other_node){
  int failCounter = 0;
  
  RETRY:
  unsigned long now = millis();              
  if ( now - last_sent >= interval) { // If it's time to send a message, send it!
    last_sent = now;    
    RF24NetworkHeader header(other_node);
    bool ok = network.write(header, TX, TXSize ); // Send Data
    printArray("TX node ", other_node, TX, TXSize); // Mess, Array, Size     //if (header.to_node == other_node) 
    if (ok) return; 

    failCounter++;
    Serial.println("TX to node "+String(other_node,OCT)+" Failed "+String(failCounter)+" times");
    if (failCounter < 10) goto RETRY;
    Serial.println("TX to node "+String(other_node,OCT)+" DROPPED");
    failCounter =0;
  }else {
    delay(interval- (now - last_sent));
    goto RETRY;
  }
}

void printArray(String mess, uint16_t node, uint8_t Array[], int Size){
  Serial.print(mess+String(node,OCT)+": [size "+String(Size)+"] ");
  for (int i = 0; i < Size; i++) Serial.print(String(Array[i])+", ");
  Serial.println();  
} 

Also if you have any suggestion to improve this Sketch please let me know.

Thank you!

if I remember well the RF24Network convention for the topology, numbering goes the opposite way

  • children of node 01 are 011, 021, 031, 041, and 051
  • children of node 02 are 012, 022, 032, 042, and 052

(remember it's octal representation and Since a single node can only connect to 6 other nodes (1 parent and 5 children) subnets need to be created if using more than 6 nodes)

1 Like

Wow, after reading pages and pages about nRF24l01 I didn't understand this simple thing.
Thank you very much!!!