Go Down

Topic: Sending Multiple Packets using NRF24L01+ and RF24/RF24network (Read 263 times) previous topic - next topic



I'm a beginner to using the RF24network and i'm having trouble organizing the data when it hits the receiver. I have a temperature sensor and an accelerometer each hooked up to their respective Unos. I can send over data from the temperature sensor without issue in one payload but i'm having trouble getting the network to recognize a separate packet. When both arduinos send over the data, it is getting mixed up together so the output has the correct numbers but they are jumbled.
Code: [Select]
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

RF24 radio(8,9);               
RF24Network network(radio);
const uint16_t home_node = 00;     
const uint16_t temp_node = 01;     
const uint16_t accel_node = 02;

struct payload_t {           
  int temp;
  int humi;
struct accelpayload_t {           
  int x;
  int y;
  int z;

void setup(void)
  Serial.println("Hello, my name is GEORGE and I will collect the following data for you: TEMPERATURE, HUMIDITY, LOCOMOTION");
  network.begin(/*channel*/ 92, /*node address*/ home_node);

void loop(void){
  network.update();                  // Check the network regularly

  while ( network.available() ) {     // Is there anything ready for us?
    RF24NetworkHeader header;
    payload_t payload;
    Serial.print(" Temperature ");
    Serial.println(" Celsius ");
    Serial.print(" Humidity ");
    Serial.println(" % ""relative");
    RF24NetworkHeader accelheader;
    accelpayload_t accelpayload;
    Serial.print("accelerations are x, y, z: ");
    Serial.print(accelpayload.x);    // print the acceleration in the X axis
    Serial.print(" ");       // prints a space between the numbers
    Serial.print(accelpayload.y);    // print the acceleration in the Y axis
    Serial.print(" ");       // prints a space between the numbers
    Serial.println(accelpayload.z);  // print the acceleration in the Z axis

Now i realize the end of the code in the loop is completely wrong so it is essentially a placeholder at this point. If anyone could point me in the right direction on how to organize my payloads that would be amazing.

Thank you!

Go Up