Hi I made four absolutely similar boards with stm32 bluepill and nrf24l01 onboard. And on this moment I want allign them in line and to make connection from base 00, thry child 001, then thry child 011 up to child 0111. Now I have sucsessfuly reached only level 2 chlild such as 011 and 021, level 3 and a child 0111 or 0211 stays unreached for now. The level 3 board is absolutly workable I chechked it on level 2. Here is my code examples. Please give me a advise what can be wrong.
Base
/*
Copyright (C) 2012 James Coliz, Jr. maniacbug@ymail.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
Update 2014 - TMRh20
*/
/**
Simplest possible example of using RF24Network
TRANSMITTER NODE
Every 2 seconds, send a payload to the receiver node.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#define RED_led PA8
#define GRN_led PA9
#define BLU_led PA10
#define BAT_sens PA3
#define RFM_enbl PC14
#define UID_BASE 0x1FFFF7E8U // Unique device ID register base address
RF24 radio(PA0, PA4); // CE, CSN
RF24Network network(radio); // Network uses that radio
uint32_t UnitID_Part_1;
uint32_t UnitID_Part_2;
uint32_t UnitID_Part_3;
uint16_t this_node = 00; // Address of our node in Octal format
uint16_t node_array[4]={0,01,011,0111}; // Address of our node in Octal format
uint16_t other_node = 01; // Address of the other node in Octal format
uint16_t node_total_count = 03; // Node total count in Octal format
uint16_t led_blink_count = 00; // Led blink count in Octal format
const unsigned long interval = 1500; //ms // How often to send 'hello world to the other unit
unsigned long last_sent; // When did we last send?
unsigned long packets_sent; // How many have we sent already
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(115200);
UnitID_Part_1 = (uint32_t)(UID_BASE);
UnitID_Part_2 = (uint32_t)(UID_BASE+0x04);
UnitID_Part_3 = (uint32_t)(UID_BASE+0x08);
if (UnitID_Part_1==0x66dff56)
{
this_node = 00;
}
//delay(5000);
Serial.println("Start ");
Serial.println("UID [HEX] : "+String(UnitID_Part_1, HEX)+" "+String(UnitID_Part_2, HEX)+" "+String(UnitID_Part_3, HEX));
Serial.println("RF24Network/examples/helloworld_tx/");
pinMode(RFM_enbl, OUTPUT);
digitalWrite(RFM_enbl, HIGH);
pinMode(RED_led, OUTPUT_OPEN_DRAIN);
pinMode(GRN_led, OUTPUT_OPEN_DRAIN);
pinMode(BLU_led, OUTPUT_OPEN_DRAIN);
pinMode(BAT_sens, INPUT);
digitalWrite(RED_led, HIGH);
digitalWrite(GRN_led, HIGH);
digitalWrite(BLU_led, HIGH);
SPI.begin();
radio.begin();
network.begin(/channel/ 90, /node address/ this_node);
}
void loop() {
network.update(); // Check the network regularly
unsigned long now = millis(); // If it's time to send a message, send it!
if ( now - last_sent >= interval )
{
last_sent = now;
Serial.print("Sending to ");
Serial.println(node_array[other_node],DEC);
payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/*to node*/ node_array[other_node]);
bool ok = network.write(header,&payload,sizeof(payload));
led_blink_count=other_node+1;
if (ok)
{
Serial.println("ok.");
while (led_blink_count!=0)
{
digitalWrite(GRN_led, LOW);
delay(100);
digitalWrite(GRN_led, HIGH);
delay(100);
led_blink_count--;
}
}
else
{
Serial.println("failed.");
while (led_blink_count!=0)
{
digitalWrite(RED_led, LOW);
delay(100);
digitalWrite(RED_led, HIGH);
delay(100);
led_blink_count--;
}
}
if (other_node<node_total_count)
{
other_node++;
}
else
{
other_node=01;
}
}
}
Child
/*
Copyright (C) 2012 James Coliz, Jr. maniacbug@ymail.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
Update 2014 - TMRh20
*/
/**
Simplest possible example of using RF24Network,
RECEIVER NODE
Listens for messages from the transmitter and prints them out.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#define RED_led PA8
#define GRN_led PA9
#define BLU_led PA10
#define BAT_sens PA3
#define RFM_enbl PC14
#define UID_BASE 0x1FFFF7E8U
RF24 radio(PA0, PA4); // CE, CSN
RF24Network network(radio); // Network uses that radio
uint32_t UnitID_Part_1;
uint32_t UnitID_Part_2;
uint32_t UnitID_Part_3;
uint16_t this_node = 01; // Address of our node in Octal format ( 04,031, etc)
uint16_t other_node = 00; // Address of the other node in Octal format
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(115200);
UnitID_Part_1 = (uint32_t)(UID_BASE);
UnitID_Part_2 = (uint32_t)(UID_BASE+0x04);
UnitID_Part_3 = (uint32_t)(UID_BASE+0x08);
if (UnitID_Part_1==0x66aff55)
{
this_node = 01;
}
if (UnitID_Part_1==0x66bff52)
{
this_node = 011;
}
if (UnitID_Part_1==0x674ff55)
{
this_node = 0111;
}
//delay(5000);
Serial.print("Start ");
Serial.println(this_node);
Serial.println("UID [HEX] : "+String(UnitID_Part_1, HEX)+" "+String(UnitID_Part_2, HEX)+" "+String(UnitID_Part_3, HEX));
Serial.println("RF24Network/examples/helloworld_rx/");
pinMode(RFM_enbl, OUTPUT);
digitalWrite(RFM_enbl, HIGH);
pinMode(RED_led, OUTPUT_OPEN_DRAIN);
pinMode(GRN_led, OUTPUT_OPEN_DRAIN);
pinMode(BLU_led, OUTPUT_OPEN_DRAIN);
pinMode(BAT_sens, INPUT);
digitalWrite(RED_led, HIGH);
digitalWrite(GRN_led, HIGH);
digitalWrite(BLU_led, HIGH);
SPI.begin();
radio.begin();
network.begin(/channel/ 90, /node address/ this_node);
}
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
payload_t payload;
network.read(header,&payload,sizeof(payload));
Serial.print("Received packet #");
Serial.print(payload.counter);
Serial.print(" at ");
Serial.println(payload.ms);
digitalWrite(GRN_led, LOW);
delay(500);
digitalWrite(GRN_led, HIGH);
}
}