Go Down

Topic: How to make master node can receive and send package using rf24network? (Read 110 times) previous topic - next topic

CHOE86

Hello, all,
I am a beginner in this field, I learned to use rf24network. I want to build a sensor in the room that will be sent to the master node using the rf24network library. I use arduino nano and the example program at https://tmrh20.github.io/RF24Network/examples.html. but I get constraint, how to make the master node can receive and send the reply packet for its child node, whereas I can only send sensor data from child node to the master node.
is there any input for me, i want the child node to send sensor data to master node and master node reply message received from child node. I do not have a schematic view of the program that I will make. because i am a beginner in this field. please input somewhat i can have a view to solve my problem this.
thank you

Robin2

You have not said if you have been able to achieve any wireless communication between two Arduinos. If not have a look at this Simple nRF24L01+ Tutorial

Do you really need to use the network feature? Please describe the project you want implement - there may be an easier way.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

CHOE86

You have not said if you have been able to achieve any wireless communication between two Arduinos. If not have a look at this Simple nRF24L01+ Tutorial

Do you really need to use the network feature? Please describe the project you want implement - there may be an easier way.

...R
Hello Robin
for communication 2 arduino has succeeded. the child node successfully sends its sensor data to the master node. but my obstacles. how the master node reply to messages from the child node. so the scenario I want, when the child node sends a message to the master node, the master node directly reply that the message has been received by the master node. where the message is sent to the child node. I am confused to rf24network how do one node can function to receive and send messages. in the example rf24network library there is only one-way communication where the transmitter sends the packet to the receiver. can you help me with the problems I am facing so I can find a way out.
thank you

Robin2

Your writing is very hard to understand because you have a whole lot of thoughts jumbled together. And some of the seem incomplete. See how much easier it is to make sense of it when I break up your Reply #2 into paragraphs
Quote
for communication 2 arduino has succeeded. the child node successfully sends its sensor data to the master node.

but my obstacles.

how the master node reply to messages from the child node.

so the scenario I want, when the child node sends a message to the master node, the master node directly reply that the message has been received by the master node.

where the message is sent to the child node.

I am confused to rf24network how do one node can function to receive and send messages. in the example rf24network library there is only one-way communication where the transmitter sends the packet to the receiver.

can you help me with the problems I am facing so I can find a way out.
I think when you read it the way I have presented it you will see that some parts are hard to understand.



I am not familiar with the network library - I have never needed to use it. However I am 99% certain that every message that is transmitted is automatically acknowledged without you needing to do anything.



You have not replied to my second question in Reply #1 "Do you really need to use the network feature? Please describe the project you want implement - there may be an easier way."

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

CHOE86

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
Code: [Select]
#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
Code: [Select]
#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

Go Up