Using dynamic payload lengths for NRF24L01 with PDLIB_NRF24L01

In the previous post I have mentioned about the library which I developed for the NRF24L01 module. In the first release I could not include some of the features it had, such as Dynamic Payload capability and Ack Payload capability. I have included those features in the version 1.02. Following is a small description about the changes.

Dynamic Payload

Dynamic Payload capability is very useful in communication. This enables modules to communicate using non-static payload lengths. For example if I don’t have this feature, in order to send 10 bytes of data among the modules, I will have to configure both the devices to accept 10 data bytes. Later, if I want to change the number of bytes to 15, I will have to reconfigure the devices.

However, with Dynamic Payload enabled we don’t need to do that. We can simply send data between modules without configuring the data length. But the maximum data length for NRF24L01 is 32 bytes.

To configure the feature, we only need to call the function NRF24L01_EnableFeatureDynPL() with the required pipe number after we initialize the module. Then we can perform communication using the same functions we used previously. (Please refer to the previous post for more details)

Ack(Acknowledgment) Payload

Ack Payload is anothe very useful feature. It can be used as a method to get some information from the RX device by coupling a payload with the ACK packet. For example, let’s say we have a RX node where we connected a heater and a temperature sensor. The TX device now can send a message to the RX device to set the heater value. In the same time the RX device can read the temperature sensor data and send it to the TX device as the payload for the ACK packet. So there the TX device becomes a RX device and vice-versa for a small time.

To configure this feature, we need to call the NRF24L01_EnableFeatureAckPL() function. This function will internally enable the Dynamic Payload feature for pipe 0.

To submit the Ack Payload we can use NRF24L01_SetAckPayload() function.

If we are using interrupts we need to make sure that we properly clear all the interrupts. Since TX and RX devices interchange their roles in this configuration, there can be DATA_READY as well as DATA_SENT interrupts in the same module. We can use functions NRF24L01_GetInterruptState() and NRF24L01_ClearInterruptFlag() to do this task easily.

Previous Post:

Click here

Git repository:

Thank you.


One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s