Getting started with nRF24L01+

nRF24L01+ 2.4 GHz wireless chip from Nordic Semiconductor is the successor to the popular nRF2401 series of chips. The 24L01+ takes all of the good features of the 2401 and adds a true SPI interface, hardware link layer, multiple pipelines, and more…

They are transceivers which means that each module can transmit and receive data. You can use these modules with any microcontroller (MCU) .

Pin Description

  1. GND – Ground
  2. Vcc   – Supply Voltage (1.9 V – 3.6 V)
  3. CE pin is always an input with respect to the 24L01. It is used to control data transmission
    and reception when in TX and RX modes, respectively. 

  4. CSN stands 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. SCK is 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. MOSI stands 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. MISO pin 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. IRQ is the interrupt pin, and is active-low. There are three internal interrupts that can cause this pin to go low when they are active.

Even though the modem operates in 3.3V level, the six pins namely CE, CSN, MOSI, MISO, SCK and IRQ are 5V tolerant.

Interfacing With Arduino

In this tutorial, we demonstrate simple client – server communication between two nRF24L01 modules interfaced with Arduino. The connections between Arduino and RF modem is illustrated below. Wire up one more pair following the same connections.

Since the modem works in 3.3V level and Arduino in 5V level, it is recommended to use a 5V – 3.3V level converter while interfacing them. But for the sake of simplicity, we have not discussed about the level converter here.

  • CE       → Pin 8
  • CS(N)  → Pin 10
  • MOSI  → Pin 11
  • MISO  → Pin 12
  • SCK    → Pin 13
  • Vcc     → 3.3v
  • GND   → GND

Note that CE and CSN pins should be connected to the digital pins as defined in the library.

On Arduino UNO boards SPI pins are connected with some digital pins. While using modem you must remember that these digital pins won’t be available.

  •     MOSI is connected to digital pin 11
  •     MISO is connected to digital pin 12
  •     SCK is connected to digital pin 13
  •     SS (not used, but also blocks) is connected to digital pin 10

The Arduino MEGA 1280 and 2560 have a similar situation.

  •     MOSI is connected to digital pin 51
  •     MISO is connected to digital pin 50
  •     SCK is connected to digital pin 52
  •     SS is connected to digital pin 53

On the Arduino DUE, Yun and Leonardo SPI pins are on ICSP connector, and are independent of the digital pins.

In this project we used RadioHead library. You only need to click on “Download ZIP” button and it’ll start downloading all necessary things.  You can install the library in Arduino IDE using Sketch-> Import library-> Add library. Another way is to extract the zip file to your Arduino home directory: Arduino/libraries on Linux or Documents/ Arduino/libraries in Windows. 

With the library, you will get sample codes for nRF24 in examples > nrf24. We used the client, server examples to establish communication between the modules. Here the client sends some data to the server for which it responds with an acknowledgement

But when we tried with the codes as they are issued, we had to gaze at the terminal for long time to see some data on it. So we decided to set one module as transmitter and the other as receiver with little editing in the code

Client

Server

 

Hurray it worked !!!

Output – Client

Output – Server

References

Shop With Us

 

Leave a Reply