This report documents the nRF24L01 data radio. The nRF24L01 is an excellent, inexpensive, and well-packaged option for short-range wireless communications. I will discuss the radio’s hardware interface and firmware, and present a driver I have written targetting the AVR platform.
In the mechatronics courses in computer science and software engineering at UVic, we have gone through several different radios for wireless data transfer. In 2006 we used the paired WRL-08950 and WRL-08946, which were very cheap but also slow and extremely unreliable, and only offered one-way communication. In 2008 we used the TXRX24G, which provided high speed, high range, bidirectional communication. However, it suffered from transmission unreliability and a complex interface that made the software driver quite difficult to develop and maintain. We have used Bluetooth solutions on occassion, but they are very expensive and complex, and thus not suitable for classes that might need a dozen or more radio units to satisfy the needs of all its projects. Over the last few years, students have spent too much time dealing with radio problems instead of doing more interesting and relevant course work.
The Nordic Semiconductor nRF24L01 is descended from the TXRX24G, but it offers some important features that make it much easier to deal with:
- Enhanced Shockburst™: This is Nordic’s link layer protocol that gives the radio auto-acknowledgement, auto-retransmit, and packet loss detection capability. It will make the wireless link much more reliable without adding complexity to the students’ application programs.
- SPI bus: The nRF24L01 implements a 4-wire Serial Peripheral Interface bus. This allows the software driver to use the microcontroller’s native high speed SPI module for communications instead of having to do manual bit bashing, which is less reliable, slower, and more difficult to implement.
- External antenna: This should improve the new radio’s sensitivity and range over those of the old radios.
- MultiCeiver™: Each radio can receive packets on up to six different addresses. This allows us to implement features such as selective packet broadcasting without sacrificing other functionality.
- Other features: Variable packet widths, packet queueing, ack packet payload, etc.
All examples and code in this report are based on the Atmel AT90USB1287 microcontroller (referred to as the AT90), but any microcontroller with an SPI driver should be able to use the radio. In particular, the WinAVR toolchain should be able to compile this driver for any AVR chip, with some minor edits. The port names and interrupt name may have to be changed to suit a given chip or application. The driver code includes a fork for the Arduino. That fork is written for the Arduino Mega, but it can be updated to work with other Arduino platforms by changing the pin assignments.
Table of Contents
- Hardware
- Serial Peripheral Interface
- Firmware
- Config Register
- EN_AA Register
- EN_RXADDR Register
- SETUP_AW Register
- SETUP_RETR Register
- RF_CH Register
- RF_SETUP Register
- STATUS Register
- OBSERVE_TX Register
- CD Register
- RX_ADDR_Pn Registers
- TX_ADDR Register
- RX_PW_Pn Registers
- FIFO_STATUS Register
- ACK_PLD Register
- TX_PLD Register
- RX_PLD Register
- DYNPD Register
- FEATURE Register
- Driver
- Future Development
- Examples
- References