Wireless communication is a big part of modern-day circuit boards and devices because everyone wants to do away with cables. Think about the wireless mouse, keyboard, or game controller you use. It would be a poor user experience dealing with wires linking the device to the PC or console. Luckily, the nRF24L01 module changed the game by providing a low-cost RF wireless transceiver. Take a look! It has some of the best features in its segment, and we will look at it in detail below, plus how to interface it with Arduino.
What are nRF24L01 and nRF24L01+?
Plus (+) is an increment, so the nRF24L01+ is a newer version of the nRF24L01 wireless transceiver. The primary difference between the two is the plus version can do an extra 250kb/s on-air data rate, while nRF24L01 only has 1Mb/s and 2Mb/s.
Therefore, you can mix the two in your project so long as the data transfer rate is 1Mb/s or 2Mb/s. Other than that, the two are identical, especially considering the outward appearance.
What's Good About the nRF24L01?
If looking for an affordable and reliable two-way RF transceiver module, the nRF24L01 is the best because it has the following advantages.
This module is one of the most affordable wireless transceivers in its segment because it costs less than $2.
Ease to Pair with Microcontrollers/Arduino Boards
If you want to build or develop a prototype of a wireless system for your project, it is easy to pair the module with different microcontrollers. They include:
- Arduino (using the RF24 Library)
- ARM, MCU, STM32, AVR, and PIC using SPI communication protocol.
Operates on the 2.4 GHz Frequency
The 2.4 GHz band operating frequency offers more flexibility in wireless communication than the lower ones because it allows higher bitrate usage. Also, it utilizes GFSK modulation to transmit data, enabling the baud rate to either be 1Mb/s or 2Mb/s. Running on the lower baud rate and in an open space gives the module a range of 100 meters.
High Transmission Range
This module can send the signal over several meters when set up correctly. However, the nRF24L01+ (PA/LNA) is better for long-distance transmission performance. It has a transmission range of 1,000 meters with no barrier primarily due to IPX antenna and power amplifier,
With such impressive features, the module has multiple applications that include the following:
- Game controllers
- VoIP headsets
- Active RFID
- Toys like RC vehicles
- Asset tracking systems
- Home and commercial automation
- Wireless PC peripherals
- Sports watches
- Remote control systems for advanced media centers
- Consumer electronics RF remote control
- 3-in-1 desktop bundles
nRF24L01 Transceiver Module Pinout
This module has the following pinout diagram.
nRF24L01+ Module vs. nRF24L01+ PA/LNA Module
Structurally, the nRF24L01 is smaller than the PA/LNA version because it features an onboard antenna. The latter has an SMA connector with an external duck (IPX) antenna, making it bigger.
PA and LNA stand for Power Amplifier and Low-Noise Amplifier, respectively. However, the most significant difference between the two is in performance. The PA boosts the power signal during transmission while the LNA amplifies the weak and uncertain signal coming into the antenna to a usable voltage level.
An nRF24L01+ PA/LNA block diagram
The incoming signal is usually in microvolts or lower than -100dBm, and the LNA raises it to about 0.5-1V. A duplexer connects the two to the antenna, preventing the more powerful PA from overloading the sensitive LNA signal.
The nRF24L01+ PA/LNA version features an RFX2401 chip that integrates LNA, PA, and transmit/receive switching circuitry. Combined with the duck antenna, the chip enables the module to attain a 1000-meter transmission range.
How Does The nRF24L01+ Transceiver Module Work?
The nRF24L01+ transmits and receives data on specific frequencies called channels. These frequencies are between 2.4GHz and 2.525GHz (2400MHz - 2525MHz), with each RF channel taking up less than 1MHz of bandwidth. Therefore, this gives 125 selectable channels in total with a 1MHz spacing.
It is important to note that a channel can only occupy 1MHz or less when transmitting 250kb/s or 1Mb/s. If sending data at a rate of 2Mb/s, you need a 2MHz bandwidth to ensure there is no overlapping and minimize crosstalk.
The module also has a multiplier feature (multiple transmitters, single receiver), where each of the 125 channels has six data pipes. Technically, each of the six is a logical channel in the physical RF channel.
You can configure each data pipe to have a unique physical address, with the primary receiver acting as a hub. This hub can switch to a transmitter at any time to each channel, but one at a time.
Like the nRF24L01, this module is highly energy-efficient, requiring about 12mA when transmitting (lower than an LED). It has an on-chip voltage regulator that accepts 1.9 - 3.6V, but the other pins can operate at 5V logic. Therefore, you can connect the transceiver to Arduino directly (without using a logic-level converter).
Socket adapter plate board for 8Pin NRF24L01, wireless transceive module for Arduino.
How to Interface nRF24L01+ Module with Arduino
The nRF24L01 and nRF24L01+ have the same pinouts, so interfacing them is a similar process. You will need the following items:
- Two Arduino UNO, NANO, or MEGA microcontrollers
- Two nRF24L01, nRF24L01+, or nRF24L01+ PA/LNA transceiver modules
- Jumper wires
- Arduino IDE
You need to build two circuits, one to act as a transmitter and the other a receiver. The wiring for both is identical. We will use the nRF24L01+ for this example.
nRF24L01+ Arduino circuit diagram
Make the following connections:
Arduino UNO and NANO share the same SPI interface pins, which means you can interchange them. However, the MEGA hardware SPI pins are different. Here's how to switch the pins.
Arduino UNO vs. NANO vs. MEGA. Note the differences in the pinouts.
Transmitter Arduino Code
To simplify the task of interfacing the two, use the RF24 Library. Open the Arduino IDE library manager by going to Sketch > Include Library > Add. ZIP library. Select the library zip file, then write the following code for the transmitter.
This Arduino code is for sending a "Hello World" message from the transmitter. It begins by importing the three libraries. After that, it creates an object that takes in two parameters as the PINs. These show the CE and CSN connections.
Next, the code creates a byte array to represent the pipe address for the two modules to communicate. The address lets you pick the specific module to share with, which should be the same in the transmitter and receiver. You can change this address value to any 5-letter string, and it is necessary when you have several modules in the network.
The next step is to initialize the radio object (begin and open-writing-pipe) using the transmitter address. Finish this section with the stop-listening function to set the module as a transmitter.
The last part creates an array of characters to assign the transmission message, Hello World. Radio. Write sends the message to the receiver. The first parameter is the message to send, and the second is the number of bytes in that text.
You can send 32 bytes at a time because that is the maximum packet size of the nRF24L01+.
Type this code for the receiver.
In the setup function, begin the serial communication, then use the open-reading-pipe function to set the address to the same one as the transmitter. The argument's first parameter is the stream number, which can be from 1-6 (frequency channel), and the second is the address for collecting the data.
Next, set the transceiver and receiver mode to listen and receive the data without transmitting. Lastly, the loop function continuously checks if any data is coming in using radio. Available. If this boolean parameter returns true (when there is data in the buffer), the program creates an array containing 32 characters. All these characters are zero at this point.
The radio. Read function reads the incoming data and stores it in the array, replacing the zeros. Lastly, the println function displays the message on screen, which should be several lines of "Hello World" as received.
To conclude, the nRF24L01 is a reliable solution if you want to build a low-cost transceiver RF module for your project. Contact us if you need further clarification on the device or how to integrate it into your project.