I try to send sensor data from node 01 to node 00. but node 00 can not display data received. while from the child node, the data successfully sent.
I use arduino nano. and file RF24Network_config.h #define SERIAL_DEBUG_ROUTING I have un comment. is there something wrong with my code? please help me, i am confused my error where. because the try error does not show up
my code
transmiter
#include <RF24Network.h>
#include <RF24.h>
#include <DHT.h>
#include <SPI.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
RF24 radio(7,8); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 01; // Address of our node in Octal format ( 04,031, etc)
const unsigned long interval = 2000; //ms // How often to send 'hello world to the other unit
unsigned long last_sent;
long packet_sent=1;
struct payload_t { // Structure of our payload
long counter;
float temperature;
float humidity;
};
void setup(void)
{
Serial.begin(9600);
Serial.println("RF24Network/Transmiter/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
dht.begin();
}
void loop(void){
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;
float t = dht.readTemperature();
float h = dht.readHumidity();
payload_t payload = {packet_sent++,t,h};
RF24NetworkHeader header(/*to node*/ 00); // Send it to the base
bool ok = network.write(header,&payload,sizeof(payload));
if (ok){
Serial.print("Packet : ");
Serial.print(payload.counter);
Serial.print(" Temperature : ");
Serial.print(payload.temperature);
Serial.print(" *C Humidity : ");
Serial.print(payload.humidity);
Serial.print(" %");
Serial.println();
}
else{
Serial.println("Data Sensor Send Failed");
}
}
}
receiver
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7,8); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 00; // Address of our node in Octal format ( 04,031, etc)
struct payload_t { // Structure of our payload
long counter;
float temperature;
float humidity;
};
void setup(void)
{
Serial.begin(9600);
Serial.println("RF24Network/Receiver/");
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;
payload_t payload;
bool ok = network.read(header,&payload,sizeof(payload));
if (ok){
Serial.print("Packet : ");
Serial.print(payload.counter);
Serial.print(" Temperature : ");
Serial.print(payload.temperature);
Serial.print(" *C Humidity : ");
Serial.print(payload.humidity);
Serial.print(" % Dari Node : ");
Serial.println(header.from_node);
}
else{
Serial.println("Data Sensor not receive");
}
}
}
my output
