NRF24L01 with Arduino

The NRF24L01 module is a powerful and inexpensive wireless radio frequency (RF) communication circuit that operates in 2.4GHz band the low-energy and has been gaining space in several industrial applications, best of all is that it can be used on Arduino.

The Module
Figure 1 - Example of the NRF24L01 Module

The circuit is based on Nordic Semiconductor 's nRF24L01+ chip that integrates a 2.4 GHz RF transceiver (Transmitter and Receiver), an RF synthesizer, and also includes the ShockBurst hardware accelerator protocol supporting an advanced SPI interface (Serial Peripheral Interface) for the application controller.

Features

Because it is based on a low cost (but remember, powerful) chip, there are several implementations of this hardware on the market, but they all have the same functionality. I strongly recommend that you download and read the nRF24L01+ DATASHEET for a complete understanding of the equipment.
  • 2.4GHz wireless RF communication. (Note: This module operates on the same frequency as the IEEE 802.11 standard [b|g|n] "wireless internet networks" which is a free frequency range "There is no need to pay fees for applications operating in that range, as long as they respect the bandwidth and power limits in force in each country "but it does not cause significant interference in the wireless network signal, however in order to better perform in this way an analysis among the 128 possible working channels must be done to keep it completely outside of external interference)
  • It allows communication between several access points.
  • Data speed [256kbps|1Mbps|2Mbps]
  • Operating distance between 70m to 100m for 256kbps (600m to 1Km on modules that come with antenna)
  • Operating modes [Low power mode|Standby mode|RX mode| TX mode]
  • Operating sensitivity of -85dBm at 1Mbps.
  • Operating voltage between 1.9V and 3.6V.
  • Operating current at 13.2 (RX) and 13.5mA (TX) for 2Mbps. (1uA if in low power mode)
  • Dimensions are on average 20mm x 29mm x 0.8mm
Connection

To connect the NRF24L01 module with the Arduino (Because we will use the RF24 library) just follow the one specified in Table 1, it is important to note that some module boards come with 8 pins and others with 10 (These have 2 pins for the VCC and GND ) but the connection is made in the same way.

Module Pins
Arduino pinsArduino Mega Pinsdescription
GND
GNDGNDNegative feeding
VCC3.3V3.3VPositive power (Attention, be careful not to connect to 5V)
THIS949Enabler that activates the RX or TX mode
CSN1053SPI chip selector
SCK1352SPI Clock
MOSI1151SPI (Slave) Input Data
MISO1250SPI (Slave) Output Data
IRQ22Interrupt pin (Not required) (Serves to alert you when data is coming or the maximum number of retransmissions has been reached)
Table 1 - Pinout to connect with Arduino

Figura 2 - NRF24L01 Pinout

Library The RF24 is a library specially designed to work with the NRF24L01 Module and the Arduino (There is also the intention to expand to other hardware platforms) that supports all the functionality of the chip and is also very simple to use. For a complete evaluation of the library nothing better than the official page of the LINK developer there you will find complete documentation as well as information about the chip and news in the code.

You can now install a library in [Add Library -> Manage Libraries], search for nRF24L01 and install the RF24 provided by TMRh20.

Programming Step 1 - Installation

To install the library just go to official LINK developer hosted on GitHub, download or download a git clone of the code and save everything in the / libraries folder in the Arduino IDE folder, ready, just restart the IDE.

Step 2 - Choosing an operating channel

Choosing an operating channel is very important to work with this module. As previously mentioned, it operates in the 2.4GHz frequency range, the range is free of charge and therefore has several devices operating on it (wireless internet network, bluetooth, wireless home phone and many others), for this the library RF24 has a code ready to do this task, to access it just open the Arduino IDE then in the Main Menu choose FILE -> Examples -> RF24 -> scanner

There is no need to change anything in the code, just connect the module to the Arduino as previously described and UPLOAD the code, when opening the Serial Monitor (Note that the code is set to 57600 baundrate) you will see a similar output the one shown in Figure 2, this sketch (Code) monitors the 128 channels of the 2.4GHz band possible to work with the module and shows the activity on them periodically.

Figure 2 - Serial output generated by "scanner" sketch

To understand Figure 2, observe the second and third lines as columns, they indicate 128 channels in hexadecimal (From 0 to 127), the other lines are generated according to the second indicating the activity in each channel, the idea is to select some channel that only have 0 (zeros) in the output (In my case, there are many free ones).

Step 3 - Test

To test the module, all you need are two Arduinos and two RF24L01 Modules. Make the connection as described above, upload Code 1 on the first Arduino, this will be the transmission station:


On the other Arduino upload Code 2, this will be the receiving station:


See the final result in the serial output.
NRF24L01 with Arduino NRF24L01 with Arduino Reviewed by AJ Alves on sexta-feira, fevereiro 15, 2013 Rating: 5

Nenhum comentário:

Tecnologia do Blogger.