How to use the NRF24L01 Wireless Tranceiver with Arduino
INTRODUCTION
The NRF24L01 is a single-chip radio transceiver for the worldwide 2.4 - 2.5 GHz ISM band. The transceiver consists of a fully integrated frequency synthesizer, a power amplifier, a crystal oscillator, a demodulator, modulator and Enhanced ShockBurst™ protocol engine. Its data transmission speed is Up to 2Mbps. It uses the SPI interface to communicate with Arduino. It has the capability of transferring and receiving data and has a range of communication up to 100 meters.
APPLICATIONS
- NETWORKING: NRF24L01 can be used for networking and communication between multiple devices. The module can use up to 125 unique addresses and usually this type of communication is required in robotics.
- WIRELESS CONTROLLED APPLICATIONS: One can control and automate a house with the use of this very simple but productive module. For example we can control the garage door wirelessly.
- REMOTE CONTROLS: Change the color of lights in your car via a NRF24L01 remote or changing the volume or channel on a car radio. We can also control a TV and switch between channels without your parents knowing.
- AUTOMATION INDUSTRY: In the automation industry, these wireless modules can be used to improve communication between multiple machines. One can control machines from the comfort of the chair and can send commands to the controller or receiver of the machine via the NRF24L01 module.
- GAMING INDUSTRY: NRF24L01 is widely used in the gaming industry like a PlayStation or Xbox controller.
WIRING DIAGRAM
Please follow the excellent tutorial below. No need to reinvent the wheel!
https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/
PIN CONNECTIONS
There are a total of 8 pins of the NRF24L01 Module. Some of the modules don’t come with pin numbers on the module so it is necessary to check out pin configuration before interfacing it with Arduino.
Arduino.
(Note: Download the required library from link below.)
NRF Transmitter Code:
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(7, 8); const byte address[6] = "00001"; void setup() { radio.begin(); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MIN); radio.stopListening(); } void loop() { const char text[] = "Hello World"; radio.write(&text, sizeof(text)); Serial.println("Sending"); Serial.println(text); delay(1000); }
NRF Receiver Code:
#include <SPI.h>
#include <nRF24L01.h> #include <RF24.h> RF24 radio(7, 8); const byte address[6] = "00001"; void setup() { Serial.begin(9600); radio.begin(); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_MIN); radio.startListening(); } void loop() { if (radio.available()) { char text[32] = ""; radio.read(&text, sizeof(text)); Serial.println("Recieving"); Serial.println(text); delay(1000); } }
END RESULT
There are two main functions of the code. One code is for receiving the transmission from the NRF24L01 and the second one is for transmitting the data to the other NRF24L01 module. The code will work on the technique of Radio Signals. The library is used for making our code easy to understand and easily workable. The code is sending a set of data Containing the words “ Hello World” and on the other hand it is also receiving the same set of Data “ Hello World “. One can easily transmit data from one NRF to another NRF using this technique.
ADDITIONAL RESOURCES
https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/
https://www.brainy-bits.com/how-to-use-the-nrf24l01-2-4ghz-wireless-module/
Please reach out to us if you are encountering issues with the information in this tutorial. We want to help you learn quickly and get you moving forward. Thank you!