The nrf_to_nrf Radio Library for nRF52x Devices and nRF24L01 Compatible Communication.
A brief tutorial on payload sizes & handling
Max Payload Sizes: The nrf_to_nrf Core Library
The nrf_to_nrf library allows many configuration options, but here I want to talk about payload sizes and communication using the core nrf_to_nrf library, as well as that in combination with RF24Network and higher libraries.
The max payload size of the nRF52840s is 127 bytes. This is with CRC disabled and static payload sizes. The radios support 0, 8, 16 or 24-bit CRC, so that extra data takes up 0, 1, 2 or 3 bytes depending on your chosen options. nRF24 devices only support 0, 8 or 16-bit CRC, so users are limited in their selection when communicating with nRF24 devices.
Similary, the nRF24 will only handle 32-bytes maximum payload size, with any CRC value and either static or dynamic payloads. The nRF52x devices are slightly different, so one needs to be aware how changing these options affect the max payload size.
Max Payload Sizes:
1. Static Payloads, CRC Disabled: 127 bytes
2. Static Payloads, 16-bit CRC: 125 bytes
3. Dynamic Payloads, w/16-bit CRC: 123 bytes
4. Static Payloads, Encryption enabled, 16-bit CRC: 113 bytes
5. Dynamic Payloads, Encryption enabled, 16-bit CRC: 111 bytes
Max Payload Sizes: The RF24Network Library
The above is with the core nrf_to_nrf driver. Once we get into libraries like the RF24Network library, another 8-bytes of data are required for the network header, which contains information like the destination address, sender address, and a counter.
This means that when communicating solely between nRF52 devices, we almost always want to configure the max payload size to 123, since RF24Network will figure out the max payload size based on this information, and fragment payloads accordingly. By default RF24Network is nRF24 compatible, so only is configured to handle 32-byte payloads.
To configure RF24Network, before calling network.begin(); we want to call radio.begin(); followed by radio.enableDynamicPayloads(123); This will allow maximum payload sizes prior to fragmentation.
The same is true when using the RF24Mesh library, call radio.begin(); followed by radio.enableDynamicPayloads(123); prior to calling mesh.begin();
If using encryption, the RF24Network layer will take this into account, so the max payload sizes with RF24Network are as follows:
Max Payload Sizes in RF24Network:
1. RF24Network, default: 24 bytes before fragmentation, 144 bytes with fragmentation
2. RF24Network, w/enableDynamicPayloads(123): 115 bytes before fragmentation, 144 bytes with fragmentation
3. RF24Network, w/enableDynamicPayloads(123) + enableEncryption = true: 103 bytes before fragmentation, 144 bytes with fragmentation