NRF24L01 with Arduino, NRF24L01 Pinout, and Example Codes

(Last Updated On: July 7, 2020)

NRF24LO1 with Arduino

NRF24L01 with Arduino Introduction:

NRF24L01 with Arduino, NRF24L01 Pinout, and Example Codes– the NRF24L01 Wireless transceiver modules are quite famous among the RC planes and RC cars builders. In my last tutorial, I designed a low-cost multi-channel transmitter and receiver for the RC plane using Arduino and a pair of NRF24L01 Transceiver Modules. These NRF24LO1 transceiver modules when in line of sight give you about 1km range. The wireless transmitter and receiver I designed in my previous tutorial can be used for controlling the UP-Down, Left-Right, and Brushless DC Motor speed control.

About the Sponsor:

NRF24LO1 with Arduino
Sponsor

This article is sponsored by Wellpcb. Wellpcb is one of the top PCB’s manufacturing companies; they offer great quality and service. You can test their PCB quality only at 5 dollars for 5 PCBs. You can ask for the price details by simply clicking on the PCB online quote, enter your PCB specifications, and click price. Once you are satisfied with their pricing then you can upload your Gerber files. You can also visit there another website, ourPCB.

The purpose of writing this article is to explain the most basic things which I didn’t explain in my previous tutorial. In this article, we will cover

  1. The NRF24L01 Transceiver Module Technical Specifications
  2. The NRF24L01 Pinout
  3. It’s interfacing with Arduino and
  4. Some basic examples to explain how data can be wirelessly sent from the transmitter to the receiver side.

Note: For the step by step explanation watch video tutorial given at the end of this article.

Without any further delay let’s get started!!!


The components and tools used in this project can be purchased from Amazon and Banggood, the components Purchase links are given below:

NRF24L01 Transceiver Modules:

Arduino Uno

Arduino Nano

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



2.4G NRF24LO1 Transceiver Module:

NRF24LO1 with Arduino

These are the 2.4GHz NRF24L01 Transceiver modules. These transceiver modules operate in the 2.4GHz band and have many new features including extra pipelines, buffers, and an auto-retransmit feature.

This board features a reverse polarized SMA connector for maximum RF range; and there is the PA and LNA circuit on board, with the external antenna it can reach long distance than the one without these parts.

This module comes with the 2.4G antenna, with a 250Kbps transmission rate, on open-air it can reach the 800 to 1K meters communication distance.

NRF24L01 features:

Voltage: 3-3.6V (recommended 3.3V) V

Maximum output power: +20dBm

Emission mode current(peak): 115mA

Receive Mode Current(peak): 45mA

Power-down mode current: 4.2uA

Sensitivity 2Mbps mode in received: -92dBm

Sensitivity 1Mbps mode in received: -95dBm

Sensitivity 250kbps mode in received: -104dBm

PA gain: 20DbLNA gain: 10Db

LNA Noise figure: 2.6Db

Antenna Gain (peak): 2Dbi

2MB rate (Open area): 520m

1MB rate (Open area): 750m

250Kb rate (Open area): 1000m

NRF24L01 Specification:

Module Type: Wireless

Weight: 25.00g

Board Size: 4.6 x 1.7 x 1.2cm

Version: 1

Operation Level: Digital 5V

Power Supply: External 5V


NRF24LO1 Pinout:

NRF24LO1 with Arduino

The NRF24LO1 Transceiver module has a total of 8 pins.

Pin number 1 is the GND

Pin number 2 is the VCC or 3.3V pin

Pin number 3 is the CE

Pin number 4 is the CSN

Pin number 5 is the SCK

Pin number 6 is the MOSI

Pin number 7 is the MISO and

Pin number 8 is the IRQ

  1. GND– Ground
  2. Vcc   – Supply Voltage (1.9 V – 3.6 V)
  3. CEpin is always input with respect to the 24L01. It is used to control data transmission
    and reception when in TX and RX modes, respectively.
  4. CSNstands for chip select not. This is the enable pin for the SPI bus, and it is active low (hence the “not” in the name). You always want to keep this pin high except when you are sending the device an SPI command or getting data on the SPI bus from the chip. When this pin goes low, the 24L01 begins listening on its SPI port for data and processes it accordingly.
  5. SCKis the serial clock for the SPI bus. When you configure your SPI bus, SCK should stay low normally (rising edges are active), and the clock samples data in the middle of data bits.
  6. MOSIstands for “master out, slave in,” and from both the microcontroller’s and the 24L01’s perspectives, the master is the microcontroller and the slave is the 24L01. This is because the 24L01 never sends data without first being requested by the microcontroller. Essentially, this pin is the side of the bus on which the master (the microcontroller) sends data to the slave (the 24L01). It is also connected to the MOSI pin on your microcontroller’s SPI interface.
  7. MISOpin is like the MOSI pin, but backwards. This pin is the side of the bus on which the slave (the 24L01) sends data to the master (the microcontroller).
  8. IRQis the interrupt pin and is active-low. There are three internal interrupts that can cause this pin to go low when they are active.


NRF24L01 with Arduino Circuit Diagram:

NRF24LO1 with Arduino

This is the most basic circuit diagram that we are going to start with. We will be using the same connections on the Transmitter side and on the Receiver Side. The VCC and GND pins of the NRF24L01 Transceiver module are connected with the Arduino’s 3.3V and Ground pins. A decoupling capacitor of 10uf is connected between the power supply pins to keep the voltage stable. For the best performance, you can use a dedicated 3.3V power supply.

The CE pin is connected with the Arduino’s pin number 9, the CSN pin is connected with pin 10, SCK is connected with Pin 13, MOSI is connected with Pin 11, and finally, the MISO pin of the NRF24L01 is connected with the Arduino’s pin number 12.

NRF24L01 Soldering:

After completing the soldering, my transmitter and receiver circuit was ready. These are the same circuits that I used for controlling the RC Plane.

NRF24LO1 with Arduino

This is the Receiver side circuit and

NRF24LO1 with Arduino

This is the Transmitter side circuit. On the Transmitter Side, for now, forget about these potentiometers and the pushbutton.


NRF24L01 Hello World Arduino Programming:

The NRF24L01 Hello World example project depends on two programs. One program is written for the transmitter side which sends the Hello World message. While the other program is written for the Receiver side which receives the Hello World message. So, first, let’s start with the transmitter side program.

NRF24L01 Hello World Transmitter Side Programming:

As usual, I started off by adding the libraries.

Next, I defined pins for the CE and CSN.

const uint64_t pipe = 0xE8E8F0F0E1LL;

This is a unique pipe address; this should be the same on the Transmitter and Receiver side.

char data[] = “Hello World, Electronic Clinic”;

I defined an array of the type character which is used to store the message. In my case, I want to send the “Hello World, Electronic Clinic” message.

Inside the void setup() function, I activated the Serial communication and selected 9600 as the baud rate and finally, activated the radio communication.

radio.write( data, sizeof(data) );

Inside the void loop function, we have only one instruction, which is used to send the message.

Now, let’s have a look at the receiver side programming.



NRF24L01 Hello World Receiver Side Programming:

On the receiver side programming, the maximum things remain the same, I am using the same libraries, same pins, this time I defined an array of the type char which can store 50 characters. You can increase or decrease this number as per your requirement.

The void setup() function consists of almost the same instructions.

Inside the void loop() function, if the NRF24L01 module has received the data then simply print it on the serial monitor. And if the communication has lost then print the message “No radio available”.

NRF24L01 Hello World Project Testing:

While the NRF24L01 Transceiver module is connected with the Laptop through a USB cable. Open the Serial monitor.

NRF24LO1 with Arduino

You can see “no radio available” as the transmitter is not powered up. Now if I go ahead and power up the transmitter side, the receiver will start receiving the data.

NRF24LO1 with Arduino

Now let’s take a look at the second example NRF24L01 and Arduino based Sensor monitoring.


NRF24L01 and Arduino based Sensor Monitoring:

The NRF24L01 PA + LNA transceiver modules can be used with different types of analog and digital sensors for monitoring different parameters.

NRF24L01 and Arduino Based Sensor Monitoring Transmitter Circuit Diagram:

NRF24LO1 with Arduino

This time I modified the circuit diagram. A pushbutton is connected between the ground and pin number 2 of the Arduino.

The left and right legs of all the three potentiometers are connected with the Arduino’s 5 volts and ground, while the middle legs are connected with the Arduino’s analog pins A0, A1, and A2. For the demonstration purposes, I will be using these potentiometers as the sensors. So, that’s all about the Transmitter circuit diagram.

NRF24L01 and Arduino based Sensor Monitoring Receiver Circuit Diagram:

NRF24LO1 with Arduino

The connections on the receiver side will remain the same.


NRF24LO1 and Arduino based Sensor Monitoring Transmitter programming:

This time I made a few changes, I defined pins for the potentiometers and a pushbutton.

I Defined an array data of the type byte.

Inside the void setup() function, I set the potentiometers and the pushbutton as the input.

Inside the void loop() function, we simply read the potentiometers and store the mapped values in the array at different locations.

if(digitalRead(Pushbutton) == LOW)

{

data[3] = 1;

}

if(digitalRead(Pushbutton) == HIGH)

{

data[3] = 0;

}

radio.write( data, sizeof(data) );

}

These two conditions are used if the pushbutton is pressed or not. If the pushbutton is pressed then a value of 1 is stored in the array at location 3, and if the pushbutton is not pressed then a value of 0 is stored.

Now, let’s have a look at the receiver programming.


NRF24LO1 and Arduino based Sensor Monitoring Receiver Programming:

On the receiver side I defined some variables to keep track of time when the communication is lost. The receiver programming is almost the same. Inside the void loop() function we simply print the received data on the serial monitor.

If the communication is lost for 1 second then a message “Connection Lost” will be printed on the Serial Monitor.

I uploaded the above two programs and opened the Serial Monitor.

NRF24LO1 with Arduino

I was able to monitor all the three potentiometers in real-time. I also checked the Pushbutton. These potentiometers can be replaced with different analog sensors. Digital Sensors can be added with the other I/O pins of the Arduino Uno.



NRF24LO1 and Arduino based two-way communication:

There are situations when you need to monitor and control both at the same time. Complex and advanced level two way communication systems can be designed using the NRF24L01 Transceiver modules. Below is the program used to control LEDs connected with two Arduino boards. Each Arduino board is provided with two pushbuttons and an LED. The following program is used on both the side “Transmitter and Receiver”.

NRF24L01 and Arduino Based RC Plane:

NRF24LO1 with Arduino

This is an amazing DIY RC plane Project based on the Arduino and a pair of NRF24L01 Transceiver modules.

Watch Video Tutorial:

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

2 Comments

  1. I tried with a sketch to send 5 buttons inputs to 5 led outputs in nrf24l01 receiver and vice versa. But is working fine upto 2 inputs and beyond that it is not working. Can you suggested.

Leave a Reply