I'm testing three nRF24 modules, they are two transmitters and a single receiver.
The code works perfectly when there is only one transmitter sending the signal to the receiver, but I am not getting how to make two transmitters to send the signal to the receiver.
I've been using these codes. I created two codes for the transmitters, and the difference between them is the adress:
Transmitter 1
const byte address[6] = "00001";
Transmitter 2
const byte address[6] = "00002";
In the receiver code, i made these changes:
radio.begin();
radio.openReadingPipe(1, addresses[1]);
radio.openReadingPipe(2, addresses[2]);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
and
void loop() {
//-------------
if (radio.available(1)) {
char text[32] = "";
radio.read(&text, sizeof(text));
display.clearDisplay();
display.setCursor(0, 0);
display.println("---------------------");
display.println("- 1 -");
display.println("---------------------");
display.println();
display.println(text);
display.display();
Serial.print("Msg. ");
Serial.println(text);
}
delay(2000);
if (radio.available(2)){
char text[32] = "";
radio.read(&text, sizeof(text));
display.clearDisplay();
display.setCursor(0, 0);
display.println("---------------------");
display.println("- 2 -");
display.println("---------------------");
display.println();
display.println(text);
display.display();
Serial.print("Msg. ");
Serial.println(text);
}
delay(2000);
}
But i dont't know how to use "(radio.available())" and It is not correct in my code.