Checking writeAckPayload of nrf24l01

Hi,

I am using nrf24l01+ to send data from one arduino to another, each one with a nrf24l01+ module. Using the method "write" I can check if the message was succesfully sent to the other arduino cuse it returns a boolean.

However I am using writeAckPayload cause I need one arduino to send some data and the other should immediatly reply with another data. The docs say it is much better using writeAckPayload instead of write (on the reply side) cause I dont need to change the mode of the module (writing/listening). But as far as I know, writeAckPayload does not provide a boolean that could tell me if the response of the second arduino arrived to the first.

I want this: 1st arduino sends AAA to 2nd arduino -> 2nd arduino sends BBB to 1st arduino -> both arduino can check if the 2 messages were sent/received succesfully.

I could use the write method in the 1st and 2nd arduino but as I said, the method writeAckPayload is better suitable for this but I see not way to check if the 2nd response was indeed received by the 1st. I am using this docs RF24: RF24 Class Reference

but as I said, the method writeAckPayload is better suitable for this

How did you determine that?

The next time a message is received on pipe, the data in buf will be sent back in the acknowledgement.

This is used to buffer a message to send WHEN A MESSAGE IS RECEIVED.

That method can NOT be used to initiate communications.

The pair of programs in this link uses ackPayload and should help point you in the right direction.

I suggest you use the TMRh20 version of the RF24 library - it solves some problems from the ManiacBug version

...R

@PaulS you misunderstood me. First I make module start the communication with "write" method. After that the second module receive the data and can reply the ACK providing also custom data using the method "writeAckPayload" . If I didnt do that I would have to make a "write" in the first module, receive the data and make another "write" to send data back.

It's not me who is saying this method is WAY BETTER, everybody says that cause you DONT need to manually change the mode of the chip (stoplistening starlistening) to send the reply back if you use the ACK to send the data back. You also have the benefit to only send the information once cause you only need one single "write" call and one single ACK payload.

@Robin2 the link you provided is exactly what I am doing but check this ilne:

radio.writeAckPayload(1, ackData, ackLen);

It's not possible to know if the ACK was succesfully sent or not. On the other hand when you use write it returns true/false

boolean rslt = radio.write( dataToSend, sizeof(dataToSend) );

I cant believe people who did this library didnt care about returning the result of the "writeAckPayload".

I am already using http://tmrh20.github.io/RF24 as my library to nrf24l01+ it's much better and works fine with delays.

I cant believe people who did this library didnt care about returning the result of the "writeAckPayload".

Because the writeAckPayload() method doesn't actually send any data AT THE TIME THE CALL IS MADE.

It simply defines what the ACK payload will be when a message is received and needs to be acknowledged.

batata004:
@Robin2 the link you provided is exactly what I am doing but check this ilne:

radio.writeAckPayload(1, ackData, ackLen);

It's not possible to know if the ACK was succesfully sent or not. On the other hand when you use write it returns true/false

Have you tried my program pair? They show the data that is sent in both directions.

Maybe I do not understand what is troubling you?

...R

Yes Robin2 I used what you say but my trouble is that: I need to make sure the ACK was received. I can check if "write" was succesfull but as far as I know it's not possible to check if ACK was indeed received by the arduino that sent the information?

I can't see anything in the nRF24L01+ datasheet that tells the "receiver" that it has successfully sent the ACK message. Whereas, if the "sender" is expecting an ACK it will not show a successful write until it receives the ACK. In the sense that the purpose of the ACK is to keep the "sender" happy this is probably understandable.

If my reading of the datasheet is correct then I think you have two choices

  • Don't use ackPayload to send data from the "receiver" to the "sender" - just get both devices to switch roles.
  • Or, get the "sender" to send another message to the "receiver" with a repeat of the data from the ACK.

...R

batata004:
I can check if "write" was succesfull but as far as I know it's not possible to check if ACK was indeed received by the arduino that sent the information?

If write returns success on a standard send to an acknowledging address, it received the acknowledge and so any attached acknowledge payload.

If you only have one address that uses acknowledge payloads, you can check for an empty tx fifo in the acknowledging station.

You have to reload the payload after a reception on the acknowledging pipe anyway, so this code could be expanded a little.

Whandall:
If you only have one address that uses acknowledge payloads, you can check for an empty tx fifo in the acknowledging station.

Because of role-reversals the language can get a bit confusing here.

Does this mean that if A sends to B and B sends an ackPayload that B can test its tx fifo to see if the ackPayload was sent correctly? I could not see anything in the datasheet about that.

...R

Yes. If the payload was sent, it vanishes from the fifo, as expected.

I only tested well configured and non congested setups yet, so I'm not shure what happens in case of an retry.

@Robin2 yes you are right. I think I understand what you said, so the best way is to avoid using ACK payload and switch roles to send the information back. There is indeed no way to check if the ACK was received, according to the documentation.

Thank you so much for clarifying this