I'm quite unsure what is happening over here. Sometimes write method from TX returns false even though RX got the message, it's probably because the ACK from RX didn't reach the TX, but in the example code this doesn't happen.
It's basicaly rewritten example from the lib, pingpair_ack.ino
TX
#include <SPI.h>
#include <RF24.h>
#define DEBUGMODE 1
#define SERIALDATARATE 115200
#ifdef DEBUGMODE
#include "printf.h"
#endif
RF24 radio(9,8);
const uint8_t pipes[][6] = {"0BBFR", "1BBFR"};
uint8_t payload = 0;
const uint8_t payloadSize = 1;
void setup(){
radio.begin();
radio.setAutoAck(1);
radio.enableAckPayload();
radio.setRetries(2,15);
radio.setChannel(30);
radio.setPayloadSize(payloadSize);
radio.setPALevel(RF24_PA_HIGH);
radio.setDataRate(RF24_250KBPS);
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1, pipes[1]);
radio.stopListening();
#ifdef DEBUGMODE
Serial.begin(SERIALDATARATE);
printf_begin();
Serial.println("Serial debug enabled");
Serial.println("Role: sender");
Serial.println();
radio.printDetails();
Serial.println(F("---------------------------"));
#endif
}
void loop(){
#ifdef DEBUGMODE
Serial.println();
Serial.print("Beginning tranmsission, sending: "); Serial.println(payload);
uint32_t sendTime = millis();
#endif
if (!radio.write(&payload, payloadSize)){
#ifdef DEBUGMODE
Serial.println("TX failed");
Serial.println();
#endif
} else {
// wait for ack response
if (!radio.available()){
#ifdef DEBUGMODE
Serial.println("Ack payload is blank");
Serial.println();
#endif
} else {
uint8_t ackPayload = 0;
// as long there is data in the RX buffer
while (radio.available()){
radio.read(&ackPayload, payloadSize);
#ifdef DEBUGMODE
Serial.print("Received ACK payload: "); Serial.println(ackPayload);
Serial.print("Round trip time: "); Serial.println(millis() - sendTime);
Serial.println();
#endif
}
payload ++;
}
}
delay(2000);
}
TX Serial output
Serial debug enabled
Role: sender
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x5246424230 0x5246424231
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x5246424230
RX_PW_P0-6 = 0x01 0x01 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x1e
RF_SETUP = 0x25
CONFIG = 0x0e
DYNPD/FEATURE = 0x03 0x06
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
---------------------------
Beginning tranmsission, sending: 204
Received ACK payload: 255
Round trip time: 8
Beginning tranmsission, sending: 205
TX failed
Beginning tranmsission, sending: 205
TX failed
Beginning tranmsission, sending: 205
Received ACK payload: 255
Round trip time: 8
RX
#include <SPI.h>
#include <RF24.h>
#define DEBUGMODE 1
#define SERIALDATARATE 115200
#ifdef DEBUGMODE
#include "printf.h"
#endif
RF24 radio(9,8);
const uint8_t pipes[][6] = {"0BBFR", "1BBFR"};
uint8_t ackPayload = 255;
uint8_t payload = 0;
const uint8_t payloadSize = 1;
void setup(){
radio.begin();
radio.setAutoAck(1);
radio.enableAckPayload();
radio.setRetries(2,15);
radio.setChannel(30);
radio.setPayloadSize(payloadSize);
radio.setPALevel(RF24_PA_HIGH);
radio.setDataRate(RF24_250KBPS);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
radio.startListening();
#ifdef DEBUGMODE
Serial.begin(SERIALDATARATE);
printf_begin();
Serial.println("Serial debug enabled");
Serial.println("Role: sender");
Serial.println();
radio.printDetails();
Serial.println(F("---------------------------"));
#endif
}
void loop(){
// as long there is daa in the buffer
while (radio.available()){
radio.read(&payload, payloadSize);
radio.writeAckPayload(1, &ackPayload, payloadSize);
#ifdef DEBUGMODE
Serial.print("Received data: "); Serial.println(payload);
Serial.println();
#endif
}
}
RX Serial output
Serial debug enabled
Role: sender
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x5246424231 0x5246424230
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x5246424231
RX_PW_P0-6 = 0x01 0x01 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x1e
RF_SETUP = 0x25
CONFIG = 0x0f
DYNPD/FEATURE = 0x03 0x06
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
---------------------------
Received data: 204
Received data: 205
Received data: 205
Received data: 205