Professional Documents
Culture Documents
NRF24L01 Arduino Interfacing - Wireless Communication1 PDF
NRF24L01 Arduino Interfacing - Wireless Communication1 PDF
NRF24L01 Arduino Interfacing - Wireless Communication1 PDF
(https://electronicshobbyists.com)
Google+
(https://plus.google.com/110431300036945931834)
Twitter (https://twitter.com/ElectronicsHoby)
Facebook (https://www.facebook.com/ElectronicsHobbyists-565164177019817/)
Home (https://electronicshobbyists.com) Arduino (https://electronicshobbyists.com/category/arduino/)
NRF24L01 Module
The NFR24L01 is a transceiver module which means that it can both send and receive the data.
These modules are very cheap, smaller in size and has a lot of speci cations. Some of the speci cations of these
modules are as follows
· Power consumption is around 12mA during transmission which is even lesser than the led.
· Its range can reach up to 100 meters if used in open space and with antenna.
· It can send 1 to 25 bytes of raw data at the transmission rate of 1 MB.
Pin out
The NRF24L01 module works with the Arduino through the SPI communication. The pinout of the module is as
follows
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 2/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
(https://i0.wp.com/electronicshobbyists.com/wp-content/uploads/2017/08/word-image-10.png)
The operating voltage of this module is from 1.9 to 3.6V but the other pins are 5V tolerant which means that the
other pins can be directly connected to the Arduino.
The MOSI, MISO and the SCK are the SPI pins and these needs to be connected to the SPI pins of Arduino. Di erent
Arduino’s have di erent SPI pins.
The CSN and CE are for setting the module in active mode and for switching between command and transmit mode.
These can be connected to any digital pins of Arduino.
The IRQ pin is the interrupt pin and you don’t have to connect it.
102
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 3/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
(https://i0.wp.com/electronicshobbyists.com/wp-content/uploads/2017/08/NRF24L01-Arduino_bb.png)
For Transmitter
CE Pin 9 Pin 9
Make the connections for the Button as shown in the Circuit Diagram
For Receiver
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 4/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
CSN Pin 10 Pin 10
CE Pin 9 Pin 9
LED Negative GND through 220 ohm resistor GND through 220 ohm resistor
1. #include <SPI.h>
2. #include <nRF24L01.h>
3. #include <RF24.h>
4.
5. RF24 radio(9, 10); // CE, CSN
6. const byte address[6] = "00001"; //Byte of array representing the address. This is the
address where we will send the data. This should be same on the receiving side.
7.
8. int button_pin = 2;
9. boolean button_state = 0;
10.
11. void setup() {
12. pinMode(button_pin, INPUT);
13. radio.begin(); //Starting the Wireless communication
14. radio.openWritingPipe(address); //Setting the address where we will send the data
15. radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on the distance
between the transmitter and receiver.
16. radio.stopListening(); //This sets the module as transmitter
17. }
18.
19. void loop()
20. {
21. button_state = digitalRead(button_pin);
22. if(button_state == HIGH)
23. {
24. const char text[] = "Your Button State is HIGH";
25. radio.write(&text, sizeof(text)); //Sending the message to receiver
26. }
27. else
28. {
29. const char text[] = "Your Button State is LOW";
30. radio.write(&text, sizeof(text)); //Sending the message to receiver
31. }
32. radio.write(&button_state, sizeof(button_state)); //Sending the message to receiver
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 5/24
3/22/2020
33. delay(1000); NRF24L01 Arduino Interfacing | Wireless Communication
34. }
1. #include <SPI.h>
2. #include <nRF24L01.h>
3. #include <RF24.h>
4.
5. RF24 radio(9, 10); // CE, CSN
6. const byte address[6] = "00001";
7.
8. boolean button_state = 0;
9. int led_pin = 3;
10.
11. void setup() {
12. pinMode(led_pin , OUTPUT);
13. Serial.begin(9600);
14. radio.begin();
15. radio.openReadingPipe(0, address); //Setting the address at which we will receive the data
16. radio.setPALevel(RF24_PA_MIN); //You can set this as minimum or maximum depending on the
distance between the transmitter and receiver.
17. radio.startListening(); //This sets the module as receiver
18. }
19.
20. void loop()
21. {
22. if (radio.available()) //Looking for the data.
23. {
24. char text[32] = ""; //Saving the incoming data
25. radio.read(&text, sizeof(text)); //Reading the data
26. radio.read(&button_state, sizeof(button_state)); //Reading the data
27. if(button_state == HIGH)
28. {
29. digitalWrite(led_pin , HIGH);
30. Serial.println(text);
31. }
32. else
33. {
34. digitalWrite(led_pin , LOW);
35. Serial.println(text);}
36. }
37. delay(5);
38. }
Video
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 6/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
(https://i0.wp.com/electronicshobbyists.com/wp-content/uploads/2017/08/NRF24L01-Arduino-bidirectional_bb.png)
CE Pin 9 Pin 9
LED Negative GND through 220 ohm resistor GND through 220 ohm resistor
1. #include <SPI.h>
2. #include <nRF24L01.h>
3. #include <RF24.h>
4. RF24 radio(9, 10); // CE, CSN
5. const byte addresses [][6] = {"00001", "00002"}; //Setting the two addresses. One for
transmitting and one for receiving
6. int button_pin = 2;
7. int led_pin = 3;
8. boolean button_state = 0;
9. boolean button_state1 = 0;
10.
11. void setup() {
12. pinMode(button_pin, INPUT);
13. pinMode(led_pin, OUTPUT);
14. radio.begin(); //Starting the radio communication
15. radio.openWritingPipe(addresses[1]); //Setting the address at which we will send the data
16. radio.openReadingPipe(1, addresses[0]); //Setting the address at which we will receive the
data
17. radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on the
distance between the transmitter and receiver.
18. }
19.
20. void loop()
21. {
22. delay(5);
23. radio.stopListening(); //This sets the module as transmitter
24. button_state = digitalRead(button_pin);
25. radio.write(&button_state, sizeof(button_state)); //Sending the data
26. delay(5);
27.
28. radio.startListening(); //This sets the module as receiver
29. while(!radio.available()); //Looking for incoming data
30. radio.read(&button_state1, sizeof(button_state1)); //Reading the data
31. if (button_state1 == HIGH)
32. {
33. digitalWrite(led_pin, HIGH);
34. }
35. else
36. {
37. digitalWrite(led_pin, LOW);
38. }
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 8/24
3/22/2020
39. } NRF24L01 Arduino Interfacing | Wireless Communication
1. #include <SPI.h>
2. #include <nRF24L01.h>
3. #include <RF24.h>
4.
5. RF24 radio(9, 10); // CE, CSN
6. const byte addresses [][6] = {"00001", "00002"}; //Setting the two addresses. One for
transmitting and one for receiving
7. int button_pin = 2;
8.
9. boolean button_state = 0;
10. boolean button_state1 = 0;
11. int led_pin = 3;
12.
13. void setup() {
14. pinMode(led_pin, OUTPUT);
15. Serial.begin(9600);
16. radio.begin(); //Starting the radio communication
17. radio.openWritingPipe(addresses[0]); //Setting the address at which we will send the data
18. radio.openReadingPipe(1, addresses[1]); //Setting the address at which we will receive the
data
19. radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on
the distance between the transmitter and receiver.
20. }
21.
22. void loop()
23. {
24. delay(5);
25. radio.startListening(); //This sets the module as receiver
26. if (radio.available()) //Looking for incoming data
27. {
28. radio.read(&button_state, sizeof(button_state));
29. if(button_state == HIGH)
30. {
31. digitalWrite(led_pin, HIGH);
32. }
33. else
34. {
35. digitalWrite(led_pin, LOW);
36. }
37. delay(5);
38.
39. radio.stopListening(); //This sets the module as transmitter
40. button_state1 = digitalRead(button_pin);
41. radio.write(&button_state1, sizeof(button_state1)); //Sending the data
42. }
43. }
Video
Aqib (https://electronicshobbyists.com/author/admin/)
For Custom Projects, hire me at https://www.freelancer.pk/u/Muhammadaqibdutt
27 RESPONSES
gor an
Dece m b e r 12, 2018 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-2605)
REPLY
To send data for controlling more than one led using nrf24l01, you can send an array containing multiple
values.
Receive this array on the receiver side, get value for each pin from this array and control the LED’s.
REPLY
Thank you for the nice tutorial, I tried the rst set up with 2 Arduino uno and it worked for the serialprint when it
is high or low but the digital output (led) did not work, I tried di erent pins but it was the same! any idea?
Thanks in advance
Hatem
REPLY
j im gar b e
Febr u a r y 12, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-3732)
I looked at the code and the output in the setup was Pin6 instead of Pin3, although the declaration of Pin3 was
made earlier in the program.
REPLY
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 11/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
SACHIN T HA
Janu a r y 1 7, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-3590)
REPLY
Rock
Febr u a r y 17, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-3753)
Hi, you attached NRF24 library and this library working, but how can I get nRF24L01 library?
REPLY
Hi, if you are talking about nrf24l01.h le then this comes with the RF24 library.
REPLY
Pr i t h vir aj
Apri l 2 4 , 2 019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-4269)
REPLY
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 12/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
Aqib (h tt ps ://e le ctr on i cs h obbyis ts .com / m e m be r s / adm in /)
Augu s t 2 5 , 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-5820)
Hi!
You are welcome. Glad to hear it.
REPLY
M u h am m ad Sh ah zaib
Augu s t 8 , 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-5511)
Hello brother
i am working on nrf24l01
i have an issue
i have a sensor on transmitter it print 2 button state ONN & OFF
in receiver i have connected relay as output which is HIGH at ONN and LOW at OFF
this is working correctly but if i have lost my transmitter signal
relay will be in last condition till new signal not come
i want to make such coding that if signal not come from transmitter due to some reasons
relay should be o automatically it cannot be in his last condition
REPLY
Hi, you can make a counter and set a value after which the relay will be o .
REPLY
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 13/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
Az iz
Augu s t 2 2 , 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-5794)
REPLY
Walikumusalam,
Can you please tell where are you having the problem?
REPLY
Se r tac
Sept e m b er 2, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-5878)
Hi Muhammad,
The code is working perfectly ne.Thank you very much for your help.
REPLY
REPLY
Ak bar
Sept e m b er 12, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-5973)
Hei bro, the program working so ne for me, thanks for this easy to understand code.
I want to make 4 pins, and controlling 4 leds, but I ended stuck, I have already read your comment, but I still not
understand how to send a multiple array to the receiver, and how to parsing the incoming data in receiver so that
we can use it to which pin I want to turn it on.
Any idea?
Greatest thanks from me
REPLY
Hi,
The code is very helpful but for bidirectional setting I am just able to get one way working. The other way is never
working. Can you please help with your thoughts on it. What do you think am doing wrong?? Thanks in advance
REPLY
N abam i ta Pal
Sept e m b er 13, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-5985)
I just checked that my button_state variable is still 0, even when I am pressing it. I have no idea what’s wrong.
REPLY
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 15/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
Je s s e
Sept e m b er 21, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-6053)
REPLY
i am interfaced NRF sensor to Arduino to recieve the audio signals to the lowest radio frequency 250KBPS and the
sample rate of 16 KHz ,but i can’t understand speech clearly so how to reduce the extrenal destroction
REPLY
C.He m alath a
Octo b e r 8 , 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-6206)
Thanks
REPLY
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 16/24
s r avya (h tt p://bigbe l e ctr on ics .in /pr odu ct.ph p?
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
I interface the NRF module to Arduino to control wireless light intensity control for cluster control led light i
connected only one light but i don’t know how to control heavy load (16 Amps) lights through arduino and NRF
module please give some idea to implement this project Thank you
REPLY
M i ch e lle
Octo b e r 3 1, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-6659)
Hello. I can’t get this to work. I don’t receive text on the receiver side nor can I get it to toggle the led. Do you
know what I might have done wrong? (I’ve used the exact same code and built both schematics twice)
REPLY
Sh akir Ali
Nove m b e r 18, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-7032)
please dear send me code for controlling motor speed and direction using NRF24L01 and n298 driver
REPLY
T im W
Nove m b e r 24, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-7142)
#include
#include
#include
#include
REPLY
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 18/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
M ar e
Nove m b e r 24, 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2 4 l 0 1 - i n t e r f a c i n g - w i t h - a r d u i n o - w i r e l e s s-
comm u n i cation/#co mment-7144)
REPLY
L E AV E A R E P LY
Comment
Name* Email*
Website
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 19/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
S U B MIT
RECENT POSTS
(https://electronicshobbyists.com/arduino-r d-projects/)
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 20/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
(https://electronicshobbyists.com/wireless-video-surveillance-robot-using-raspberry-pi/)
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 21/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
(https://electronicshobbyists.com/raspberry-pi-dc-motor-control-with-custom-board/)
Raspberry Pi Pan
Tilt Object
Tracker using
OpenCV
(https://electroni
pi-pan-tilt-
object-tracker-
using-opencv/)
(https://electronicshobbyists.com/raspberry-pi-pan-tilt-object-tracker-using-opencv/)
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 22/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication Raspberry Pi Pan
Tilt Face Tracker
Using OpenCV
(https://electronicsh
pi-pan-tilt-face-
tracker-using-
opencv/)
(https://electronicshobbyists.com/raspberry-pi-pan-tilt-face-tracker-using-opencv/)
(https://www.pcbway.com/?from=electronicshobbyists)
SEARCH
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 23/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
Email Address
Subscribe
I agree to have my personal information transfered to MailChimp ( more information (https://mailchimp.com/legal/privacy/)
)
ABOUT US
Contact (https://electronicshobbyists.com/contact-us/)
Copyright ©2016-2019
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 24/24