NRF24L01: wireless communication module for Arduino

NRF24L01

Probably you need to create some DIY project using Arduino or any other element and you have to make use of wireless communication. And that’s because you have some kind of module or device that allows you to transmit using IR, RF, Bluetooth, WiFi, etc. In other words, you must be clear about what you need to know what type of signal would be the most appropriate in your case.

In this case we have a guide on the NRF24L01 for you. It is a wireless communication chip that will provide you with what you need to send and receive signals. The type of signals it handles are RF or radio frequency, that is, long wavelength waves, and therefore low energy, which in the electromagnetic spectrum are between 3 Hz and 300 Ghz frequency.

What is NRF24L01?

NRF24L01

The NRF24L01 is a chip manufactured by Nordic Semiconductor. If you complete purchase, the chip comes mounted on a small PCB with some auxiliary elements you need, and therefore composing a module. You can use it in several ways, among them connecting it to Adruino as I will show you later.

NRF24L01, as can be deduced from its name, is a wireless communication device using RF or radio frequency with the ability to operate at 2.4Ghz – 2.5 Ghz. This is the free band for free use. You know that other bands are reserved and you have to pay if you want to use them to transmit information. Also, it has a transmitter + a receiver.

Specifically, the frequency band you can use is 2400 Mhz to 2525Mhz, with the possibility of selecting between 125 channels with 1Mhz spaces between them. However, it is not recommended to use 2.4Ghz frequencies if you are using WiFi networks, drones operating on this frequency, etc., or there will be interference. That’s why it’s preferable to use from 2.501Mhz onwards.

As for its characteristics, it works from 1.9 to 3.6v, so it will be easy to power it with the Arduino board itself with the 3.3 connection, using batteries, and even with some power supply that gives that voltage. In addition, you can configure the transmission speed between 250 Kbps, 1Mbps and up to 2Mbps.

The chip in the emission and reception can work simultaneously with up to 6 connections of various devices. With that you can be transmitting or receiving from different points without any problem. And if you are worried about the robustness or reliability of the communication, the chip itself has a logical circuitry to correct data errors and resend information if necessary. Therefore, it frees the processor from this task.

The SPI bus can be used to control it, making it very easy to control with Arduino. In addition, the data pins of the NRF24L01 support up to 5v without problems. The power consumption in Stand By is quite low, so it will not be an element to worry about, and when it is in operation it is not one of the most expensive either, since it only needs 15mA to send and receive data.

On the market you will find several different modules that mount the NRF24L01 chip, they change only in the auxiliary elements they have or in some details. For example in the type of antenna. Some have an antenna printed on the PCB in a zig-zag pattern with a range of about 20-30 meters. Others have a slightly more powerful external antenna with an amplifier to reach from 700 meters up to 1 km.

However, the actual range is limited by some factors, such as obstacles in the way, noise or interference from other elements or signals present, transmission speed, supply voltage (the higher the voltage, the greater the distance), etc. For example, if you want to transmit at the maximum speed of 2Mbps that will have a big penalty on the distance, which will be only 2 or 3 meters maximum. At lower speeds you may be able to scale that distance.

What do you need to know before you buy?

Antenna of the NRF40L01

Pinout y montaje del NRF24L01

The NRF24L01 is a very cheap chip that can be used in many projects. For example, if it doesn’t have an external antenna, you can buy it for up to about 0.65 ?, being the external antenna model the one that is a bit more expensive than this one but it is still very cheap and usually doesn’t exceed 1.7 ?.

If you do not have another transmitting or receiving element, you know that you must buy two NRF24L01 modules, one to use on one side and the other on the other side of where you want to transmit. Both will act as a ‘transmitter’ or ‘receiver’ as you wish.
pinout NRF40L01

As for the assembly, it’s quite simple. The NRF24L01 has 8 pins, so its pinout is very easy to understand as you can see in this picture I leave you. On the right you can see the pin diagram of an Arduino UNO board and how each pin of the module would be connected to it.

As you can tell, the NRF24L01 board is powered using Arduino’s GND and 3.3v pins. Remember not to do it with the 5v signal or you will damage the module.

Integration with Arduino

2 NRF24L01 with Arduino (circuit)

Once you know what the NRF24L01 is and how it can be connected and powered, as well as the amount of projects you can do with a couple of these cheap devices, the next thing to do is to show a programming example so you can start experimenting with your Arduino IDE. Remember that the data format you can transmit can be modified in the source code.

You can choose to send and receive a string, integer, floating point data, etc. I recommend our Arduino programming guide if you are just starting out. With it you can create your first projects. And as a concrete example for the NRF24L01, here I leave you the necessary codes for a string.

Code that you must write in Arduino IDE and program the Arduino board connected to the NRF24L01 that you are going to use as a emitter:

#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
 
const int pinCE = 9;
const int pinCSN = 10;
RF24 radio(pinCE, pinCSN);
 
// Single radio pipe address for the 2 nodes to communicate.
const uint64_t pipe = 0xE8E8F0F0E1LL;
 
char data[16]="Here your message" ;
 
void setup(void)
{
   radio.begin();
   radio.openWritingPipe(pipe);
}
 
void loop(void)
{
   radio.write(data, sizeof data);
   delay(1000);
}

Here is the code that you have to enter in Arduino IDE and engrave on the board that you have connected to the dedicated NRF24L01 as ‘string>receiver’:

#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>

const int pinCE = 9;
const int pinCSN = 10;
RF24 radio(pinCE, pinCSN);

// Single radio pipe address for the 2 nodes to communicate.
const uint64_t pipe = 0xE8E8F0F0E1LL;

char data [16];

void setup(void)
{
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
}

void loop(void)
{
if (radio.available())
{
int done = radio.read(data, sizeof data);
Serial.println(data);
}
}

With that you will have everything you need and you can try to send words or text strings from one and see how the other receives them. Use two computers connected by USB to the Arduino board to use the console as a means to view the data. Separate them a prudent distance according to the module you have or the configuration you have given it and you will start to see on the other computer’s screen the characters you have entered in the first code .

Leave a Comment

*

*