Nrf24L01 1-to-1 communication with 2 inputs [SOLVED]

I am trying to do a 1-1 one-way communication between 2 arduinos using the NRF24L01 module.

On my transmitter side, I have 1 Ultrasonic Sensor and the readings will be sent over to the receiver side.

This is my code for my transmitter side:

 unsigned long US1_Measurement = distance;
  RF24NetworkHeader header(node01);    // (Address where the data is going)
  bool ok3 = network.write(header, &US1_Measurement , sizeof(US1_Measurement )); // Send the data

This is my code on my receiver side:

while ( network.available() ) {     // Is there any incoming data?
    RF24NetworkHeader header;
    unsigned long incomingData;
    network.read(header, &incomingData, sizeof(incomingData)); // Read the incoming data
    Serial.println(incomingData);    // Print the sensor readings
  }

This is working. Now what I am trying to do now is, on my transmitter side, i want to add an additional ultrasonic sensor. So now i want my transmitter to send both readings from my ultrasonic sensors to the receiver at the same time. I am not sure on how to send both readings at the same time.

Any help would be much appreciated. Thanks

Put the values in a 'struct' or array and sent that.

1 Like

okay, tried it out, it worked. thanks

1 Like

If your question was answered to your satisfaction, please mark it as solved so the other members will not open the thread only to find that you no longer need assistance.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.