I'm using two NRFs (TX and RX), when the RX is disconnected the loop function on the TX take nearly 50ms to complete.
When the RX is powered and get connected to TX, the loop function takes only 2.5 ms.
I'm going to go crazy about this, and i can't find the answer.
autoACK, dynamic payload and ACKpayload are all enabled.
Radio setup code:
void setupRadio() {
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication
radio.setPALevel(RF24_PA_MIN); // Output power is set for maximum while unbinding
radio.openWritingPipe(pipeOut);
radio.setAutoAck(true);
radio.enableDynamicPayloads();
radio.enableAckPayload();
radio.stopListening(); // Start the radio comunication for Transmitter
radio.powerUp();
}
Radio transmit code:
void transmitRadio() {
if (radio.write(&txArray, sizeof(TxData))) {
if (!rxConnected ) {
rxConnected = true;
}
if (radio.isAckPayloadAvailable()) {
radio.read(&payload, sizeof(struct ackPayload)); //read the payload, if available
} else {
noAckCount++;
}
} else {
if (rxConnected && millis() - t2 > 2000) {
rxConnected = false;
}
}
}
Do you remember from 5 months ago that you cannot get help unless your show the complete code for both Arduino setups? Are you putting in serial.Print() messages to track the program execution and see what is taking the extra time? That will be the first thing people trying to help will ask you to do. It's called "debugging".
The transmitter waits for an ACK from the receiver. If it times out without receiving one it retries. Eventually it gives up. In your case this is apparently about 50 ms. See section 7 of the data sheet.
I think I see a problem in how you have it wired but without a schematic I cannot be sure. Post an annotated schematic that shows exactly how you have wired it. Be sure to show all power, ground connections, power sources as well as anything else connected. Note any leads over 10"/25 cm in length. `
Yes I did the debugging and found that the piece of code causing this issue was the transmitRadio() function, and that's why I didn't post the full code plus it is more than 1000 line of code (RX is excluded).