Maker.io main logo

nRF24L01 Modules: First Step into Wireless Transceiving

2023-11-03 | By Antonio Velasco

License: Public Domain

In my first year, which I entered without too much electronics knowledge, I got the opportunity to be involved in UC Irvine’s Open Project Space - a program where students would complete fun projects and be exposed to embedded systems early on. While I worked with many new and exciting components, my favorite part was working with the wireless transceiver, the nRF24L01 module. It was very cool, not just because I learned about how electronics communicate with each other, but also because it opened up a world of possibilities for projects that would require communication, like a weather station that could be placed outside with sensors or controlling a light switch from far away.

Weather Station

Here's the weather station I made for UCI's Open Project Space. The two Arduinos are not connected at all, and you can view one of the NRF24L01s connected to the right, just under the LCD.

What is the nRF24L01?

The nRF24L01 module is a component that allows for wireless communication between two separate Arduino boards. It utilizes the NRF24 radio transceiver and, on a PCB, attaches to an antenna to create a functioning radio transceiver. It uses a 2.4 GHz band and baud rates of 250 kilobits per second, 1 megabit per second, and 2 megabits per second. It typically performs best at a range of up to 50m, but with low interference, it can possibly go much further. I’ve been able to have it work outside of my dorm while having the receiver inside.

How to utilize the nRF24L01

Using the nRF24L01 module is relatively simple, given the pinout which should be indicated on the part. Typically, it will appear as such:

Pinout

Ground and VCC provide the power and should be connected to the respective Arduino pins. CE (or CS) and CSN are the chip enable and chip select not pins, respectively, which are used with a command in the NRF24L01 library to instantiate the object and to enable or disable SPI connection. MISO and MOSI (Master in, slave out; and vice versa, respectively) are to be connected to the respective SPI pins for each Arduino. The same goes for SCK, which is the serial clock. For the Arduino Uno and Nano, SCK, MISO, and MOSI go to pins 13, 12, and 11 respectively. For the Arduino Mega, this would be 52 for the SCK, 50 for MISO, and 51 for MOSI.

It’s important to note that VCC should be connected to the 3.3V pin on the Arduino and not the 5V, as its operating voltage is 1.9-3.6V. Although the module does operate with 3.3V, it works with 5V logic and still allows us to connect it with the Arduino.

I’ve always used SparkFun Jumper Cables to connect them easily, but it can also be useful to make a custom PCB for it if your project is something that will be long-term.

Rover

Here's an example of the NRF24L01 modules all wired up with an RC rover that I made in Open Project Space. Both use jumper cables to connect the Arduino and the NRF24L01.

PCB

Here's a PCB I created for it as well, with the NRF on the left with the respective pins connecting to the middle part where the Arduino would be.

Now that you’ve connected the hardware side of things, it’s time to code it up. Make sure to download and include the NRF24L01 library before getting started. The most important thing, after declaring the object and the CE/CSN pins, is to set a consistent baud rate between both the transmitter and the receiver. Then, you need to establish the receiver address/the address the transmitter will be sending to. This can be any 5-character code, as long as the transmitter is pointing to the same address that the receiver is setting to itself. This is for one-way communication–if you wish to send bidirectionally, you will need to set two different receive addresses on each transceiver, along with setting two different transmit addresses to send to each other. For example, if I have transceiver 1 with a receiving address of AAAAA and a transmitting address of BBBBB, transceiver 2 should have a receiving address of BBBBB and a transmitting address of AAAAA. It’s possible to build up a network as each module can listen to 6 other modules at the same time since each channel can support that many.

Finally, the last thing to do is to set the channel #. This should be the same between both transceivers. There is the capability to choose any channel # between 1-125. 124's worked for me a number of times. This tends to be the biggest issue after everything else is set up correctly as other WiFi networks or IoT items may interfere with certain channels. If there appears to be no connectivity between the two, try different channels until it works.

Conclusion

That should provide a rough introduction to using the NRF24L01! There’s more ground to cover when it comes to coding for specific applications, but this should provide enough information to get you all set up and started on your wireless projects. While there are a number of transceivers out there, I personally find the NRF24L01 a perfect place to start given its ease of installation and the smooth compatibility with the Arduino.

制造商零件编号 NRF24L01P-MODULE-PCB
KIT EVAL NRF24L01+ PCB ANTENNA
Nordic Semiconductor ASA
制造商零件编号 NRF24L01
IC RF TXRX ISM>1GHZ 20QFN
Nordic Semiconductor ASA
制造商零件编号 A000005
ARDUINO NANO ATMEGA328 EVAL BRD
Arduino
制造商零件编号 A000067
ARDUINO MEGA2560 ATMEGA2560
Arduino
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum