Go Down

Topic: nRF24L01 receiving from 2 transmitter at the same time  (Read 106 times) previous topic - next topic

ninooronica

Hello, I am trying to receive the data from my 2 transmitter and output it in the serial monitor at the same time. Basically what I am trying to do now is just reading both radios at the same time and printing the data in serial monitor. but this method do not seem to work and the data are getting mixed up upon printing the data from tx1 and tx2.

Both transmitters are sending the data in packets continuously

This is the sample code on how i print the data in my receiver:

Code: [Select]


if ( myRadio.available())   {

    myRadio.read( &packet_tx1, sizeof(packet_tx1) );
    myRadio.read( &packet_tx2, sizeof(packet_tx2) );
    Serial.print("TX1");
    Serial.print(", "); Serial.print(packet_tx1.data1);
    Serial.print(", "); Serial.print(packet_tx1.data2);
    ...
    Serial.println();
    ...
    Serial.print("TX2");
    Serial.print(", "); Serial.print(packet_tx2.data1);
    Serial.print(", "); Serial.print(packet_tx2.data2);
    Serial.print(", "); Serial.print(packet_tx2.data3);
    ...
    ...
    ...
    Serial.println();
    delay(1000);
  }



I expected it to print the data in sequence what i am trying to do is printing the data from tx2 after the tx1 prints its data. but unfortunately it prints the data from transmitters randomly and in no order also there are times the data from tx1 and tx2 are getting mixed up.

It seems that the sending of the data are becoming interrupted due to the transmitters sending data
 same time with no timing at all.

Is what i am trying to do possible ? What method can use to print the data simultaneously?
Hope anyone can help me with my problem.


Robin2

Why have you started two Threads?

Please click Report to Moderator and ask to have them merged.

In your other Thread you seem to have a problem with my example programs. Please post the exact programs that you uploaded to your Arduinos so that I can see what the problem may be. My examples do work - other Forum members have used them.


An nRF24 has only one receiver so it can only receive one message at a time. If two Arduinos are sending messages continuously they will probably cause data corruption. The polling system in my Tutorial avoids that problem.

...R

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

Go Up