I have a RemoteUnit which is the Central Rx unit and there are three are two Tx which send different data to the Rx.
Individually each Tx is able to send the data to Rx. But when I power up both Tx units together, I have a problem. The Pipe number always gets set to "2" and correspondingly the Switch case never evaluates Case 1 .
This is how the Radio addresses are defined :
byte rf_Address[][6] = {"PRX00", "PTX01", "PTX02"} ; // Radio pipe addresses for CentralUnit_Rx, MainUnit_Tx, GFMReader_Tx
This is the initialization of the Central_Rx unit :
// Setup and configure radio
radio.begin();
radio.setChannel(108); // Above most Wifi Channels
radio.setDataRate( RF24_250KBPS );
radio.enableDynamicPayloads(); // Ack payloads are dynamic payloads
radio.openReadingPipe(1, rf_Address[0]); // Define address for first Tx unit
radio.openWritingPipe(rf_Address[1]);
radio.openReadingPipe(2, rf_Address[0]); // Define address for second Tx unit
radio.openWritingPipe(rf_Address[2]);
radio.enableAckPayload();
radio.writeAckPayload(1, &ackDataToMain, sizeof(ackDataToMain)); // pre-load data for first acknowledgement
radio.writeAckPayload(2, &ackDataToGFM, sizeof(ackDataToGFM));
radio.startListening();
And this is the code inside loop()
void loop(void)
{
// READ THE PUSH BUTTONS ONCE EVERY SCAN`
rem_PB_State();
// RADIO COMMUNICATION SECTION.
byte pipeRxd ;
if ( radio.available(&pipeRxd)) {
Serial.print( " Data on Pipe :"); // Print the Pipe number....
Serial.println(pipeRxd);
switch (pipeRxd) {
case 1:
radio.read( &dataFromMain, sizeof(dataFromMain)); // Get the Payload from MAIN Tx
lcd.setCursor(0, dataFromMain.cursorRow); // and Process it....
sprintf(lcdMessage, "%s", dataFromMain.recdMsg);
lcd.print(lcdMessage);
delay(5);
radio.writeAckPayload(1, &ackDataToMain, sizeof(ackDataToMain)); // Send Ack Payload to Main Tx
break;
case 2:
radio.read(&GFM_PulseData, sizeof(GFM_PulseData));
lcd.setCursor(0, 2);
sprintf (lcdMessage, "GFM Pulse = %6ul", GFM_PulseData);
lcd.print(lcdMessage);
delay(5);
radio.writeAckPayload(2, &ackDataToGFM, sizeof(ackDataToGFM));
break;
default:
break;
}
}
}
How does the Pipe number get set to "2" always ??