To make it clear for someone to understand I am pasting the code which I am trying to run on each nodes
#include <RF24/RF24.h>
#include <RF24Network/RF24Network.h>
#include <iostream>
#include <ctime>
#include <stdio.h>
#include <time.h>
using namespace std;
RF24 radio(RPI_V2_GPIO_P1_18, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
RF24Network network(radio);
// Address of our node
const uint16_t this_node = 00;
// Address of the other node
const uint16_t other_node = 011;
const unsigned long interval = 2000; //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;
};
int main(int argc, char** argv)
{
// Refer to RF24.h or nRF24L01 DS for settings
radio.begin();
delay(5);
network.begin(/*channel*/ 90, /*node address*/ this_node);
radio.printDetails();
while(1)
{
network.update();
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));
printf("Received payload # %lu at %lu \n",payload.counter,payload.ms);
}
//sleep(2);
delay(2000);
//fclose(pFile);
}
return 0;
}
The above code is running in raspberry pi which I am using as base
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(9,10); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 01; // Address of our node
//const uint16_t other_node = 01; // Address of the other node
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx/");
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;
bool test = network.read(header,&payload,sizeof(payload));
if (test)
{
Serial.print("Received packet #");
Serial.print(payload.counter);
Serial.print(" at ");
Serial.println(payload.ms);
}
else {
Serial.print("forwarded");
}
}
}
This is in first arduino which is the child in my case
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(9,10); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 011; // Address of our node
//const uint16_t other_node = 00; // Address of the other node
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx/grandchild");
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);
}
}
This is in second arduino, the granchild.
If I am sending message to the child, I am getting “OK” in the console in raspberry pi, but If I send it to grandchild I get “sending failed” though I am getting the data in the serial monitor.
[EDIT: Basically sending ack from grandchild to base]
[EDIT: I was able to get this working so range is not an issue anymore] On top of this, the child grandchild setup only works when child and grandchild are both in the range of Base that is raspberry pi.
I am not able to figure out the reasons, any help will be of great help please someone help me out on this