Can't get Robin2 RF-24 autoAck to work

I've spent a week trying to get my version of Robin2's to work. I had it working 6 months ago. So I went back to his original version and still no luck. A link to his sketches is Here. I've run connection check software and both boards are interfacing with the RF-24's properly. I'm using an Arduino Mega for the xmttr and an Uno for the rcvr.

I've got the CE & CSN pins properly connected. I can get a one way communication out of them, just no autoAck.

The only difference between now and 6 months ago is a different computer. I uninstalled and re-installed the Arduino IDE. I updated the libraries. I just can't seem to get this to work.
Can somebody please help? I've been working this well over a week. I thought I had these perfected last September.
Here is the transmitter code. Both sketches are the same as Robin2's except I added a channel assignment and changed the serial baud rate to 115200.

// SimpleTxAckPayload - the master or the transmitter. 
// Uses Arduino Mega

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN   48
#define CSN_PIN 49

const byte slaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';
int ackData[2] = {-1, -1}; // to hold the two values coming from the slave
bool newData = false;

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

//===============

void setup() {

    Serial.begin(115200);
    Serial.println(F("Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino"));
    Serial.println("SimpleTxAckPayload Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setChannel(120);
    radio.enableAckPayload();

    radio.setRetries(5,5); // delay, count
                                       // 5 gives a 1500 µsec delay which is needed for a 32 byte ackPayload
    radio.openWritingPipe(slaveAddress);
}

//=============

void loop() {

    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
    }
    showData();
}

//================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        if (radio.isAckPayloadAvailable()) {
            radio.read(&ackData, sizeof(ackData));
            newData = true;
        }
        else {
            Serial.println("  Acknowledge but no data ");
        }
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }

    prevMillis = millis();
 }


//=================

void showData() {
    if (newData == true) {
        Serial.print("  Acknowledge data ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        Serial.println();
        newData = false;
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

The transmitter output looks like this

20:28:46.313 -> SimpleTxAckPayload Starting
20:28:47.323 -> Data Sent Message 0 Tx failed
20:28:48.334 -> Data Sent Message 0 Tx failed
20:28:49.350 -> Data Sent Message 0 Tx failed
20:28:50.353 -> Data Sent Message 0 Tx failed
20:28:51.371 -> Data Sent Message 0 Tx failed
20:28:52.387 -> Data Sent Message 0 Tx failed

The receiver code

// SimpleRxAckPayload- the slave or the receiver
//
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN  10
#define CSN_PIN 9                            

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
int ackData[2] = {109, -4000}; // the two values to be sent to the master
bool newData = false;

//==============

void setup() {

    Serial.begin(115200);

    Serial.println("SimpleRxAckPayload Starting");
    radio.begin();
     radio.setChannel(120);
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);

    radio.enableAckPayload();
    
    radio.startListening();

    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // pre-load data
}

//==========

void loop() {
    getData();
    showData();
}

//============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        updateReplyData();
        newData = true;
    }
}

//================

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        Serial.print(" ackPayload sent ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        newData = false;
    }
}

//================

void updateReplyData() {
    ackData[0] -= 1;
    ackData[1] -= 1;
    if (ackData[0] < 100) {
        ackData[0] = 109;
    }
    if (ackData[1] < -4009) {
        ackData[1] = -4000;
    }
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // load the payload for the next time
}

The Receiver only has one line
20:29:19.966 -> SimpleRxASimpleRxAckPayload Starting

There are two ways you can fix this:

  1. Read the update in the tutorials first post:

  2. Update your code to be compatible with the new version of the library (v1.1.7 dates way back to 2016, while the latest version (v1.3.11) was released in December of last year. So, there have been multiple improvements to it):

  • Add a call to enableDynamicPayloads() in the RX code AFTER the call to enableAckPayload().
  • Make sure you call stopListening() before calling openWritingPipe() in the TX code. If the TX code never calls startListening(), then you only have to call stopListening() once - right after you've configured the radio.

Yeah basically the library was updated and broke the functionality of the tutorial. Robin was quite frustrated about it as one can understand he would be. You re-installed everything on the new computer including the latest library.

  1. Update your code to be compatible with the new version of the library (v1.1.7 dates way back to 2016, while the latest version (v1.3.11) was released in December of last year. So, there have been multiple improvements to it):

Thanks gfvalvo, this worked perfectly. I never saw Robin's February edit and I'm usually pretty good at details. I should have posted here sooner.

Robin was quite frustrated about it as one can understand he would be.

Deva_Rishi, I could understand why Robin would be frustrated

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.