Sunteți pe pagina 1din 24

3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication

(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 Interfacing with Arduino | Wireless Communication


In this tutorial, you will learn about NRF24L01 Arduino interfacing with the help of two examples. In the rst
example, we will send “Hello world” and a command to blink the LED connected to the other Arduino. In the second
example, we will do the bidirectional control and will send the command from First Arduino to blink the LED on the
second and then we will send the command from second Arduino to blink the LED on the rst.
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 1/24
Before going in detail, rst have a look at theNRF24L01
3/22/2020 speci cation
Arduinoof this module
Interfacing | Wireless Communication

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

Speci cations of NRF24L01 Module

·         Power consumption is around 12mA during transmission which is even lesser than the led.

·         It can operate with baud rates from 250Kbps up to 2 Mbps.

·         Its range can reach up to 100 meters if used in open space and with antenna.

·         It can both send and receive the data simultaneously.

·         Each module can communicate with up to 6 other modules.

·         It uses the 2.4 GHz band.

·         It can send 1 to 25 bytes of raw data at the transmission rate of 1 MB.

·         It has 125 di erent channels.

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.

Example 1 for Nrf24l01 Arduino Interfacing


In the rst example for nrf24l01 arduino interfacing, we are going to simply send the data from one Arduino to other
Arduino. When we will press the button connected to the rst Arduino, LED connected to the second Arduino will
light up.
102
Shares
The circuit diagram for the rst example is shown below and the connections are shown below that.

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

NRF24L01 Arduino UNO/Nano Arduino Mega 2560

VCC 3.3V 3.3V

GND GND GND

CSN Pin 10 Pin 10

CE Pin 9 Pin 9

SCK Pin 13 Pin 52

MOSI Pin 11 Pin 51

MISO Pin 12 Pin 50

Make the connections for the Button as shown in the Circuit Diagram

For Receiver

NRF24L01 Arduino UNO/Nano Arduino Mega 2560

VCC 3.3V 3.3V

GND GND GND

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

SCK Pin 13 Pin 52

MOSI Pin 11 Pin 51

MISO Pin 12 Pin 50

LED Positive Pin 3 Pin 3

LED Negative GND through 220 ohm resistor GND through 220 ohm resistor

Code for Transmitter


Download the library from here. (https://github.com/nRF24/RF24.git)

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. }

Code for Receiver

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

Arduino Wireless Communicatin

https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 6/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication

Example 2 for Nrf24l01 Arduino Interfacing


In the second example for Nrf24l01 Arduino interfacing, we are going to do the bidirectional communication. First,
we will send the command from the rst Arduino to light up the LED connected to the second Arduino and then we
will send the command from the second Arduino to light up the LED connected to the rst Arduino.

(https://i0.wp.com/electronicshobbyists.com/wp-content/uploads/2017/08/NRF24L01-Arduino-bidirectional_bb.png)

Connections for Both the Arduino’s are same

NRF24L01 Arduino UNO/Nano Arduino Mega 2560

VCC 3.3V 3.3V

GND GND GND

CSN Pin 10 Pin 10

CE Pin 9 Pin 9

SCK Pin 13 Pin 52


https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 7/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication
MOSI Pin 11 Pin 51

MISO Pin 12 Pin 50

LED Positive Pin 3 Pin 3

LED Negative GND through 220 ohm resistor GND through 220 ohm resistor

Make the connections for Button as shown in the circuit diagram

Code for First Arduino

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

Code for Second Arduino

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

Arduino bidirectional communication


https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 9/24
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication

ABOUT THE AUTHOR

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)

How write this code for 4 button and 4 led?

REPLY

Aqib (h tt ps ://e le ctr on i cs h obbyis ts .com / m e m be r s / adm in /)


https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 10/24
Augu s t 2 5 , 2019 (htt p s : / / e l ectronics hobbyists.com/nrf2
3/22/2020 4 l 0 1 - i| nWireless
NRF24L01 Arduino Interfacing t e r f a cCommunication
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-5822)

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

Hate m Ab ou d (h ttp://w w w .e n v.dtu .dk)


Janu a r y 1 0, 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-3535)

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

Aqib (h ttps ://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-5823)

Thanks for pointing it out. I have updated the post.

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)

WOW WOW WOW

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

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-5821)

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)

Hey ! Thanks for uploading this man ! This helped me a lot

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

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-5824)

Hi, you can make a counter and set a value after which the relay will be o .

if (counter > 1000){


digitalWrite(relayPin, LOW);
counter = 0
}
else{
counter ++;
}

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)

Br. Mohhammad Salamonalikum


This dose not work for me .Not the rst example nor the second.
Why I don,t know.Is there a way to talk to you?

REPLY

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-5819)

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

Aqib (h tt ps ://e le ctr on i cs h obbyis ts .com / m e m be r s / adm in /)


https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 14/24
Sept e m b er 2, 2019 (htt p s : / / e l ectronics NRF24L01
3/22/2020 hobbyists.com/nrf2 4 l 0| 1Wireless
Arduino Interfacing - i n t e r Communication
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-5881)

Hi, You are Welcome.

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

N abam ita 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-5984)

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)

Can i have 2 transmitter and 1 receiver simultaneously?

REPLY

T ar u n (h tt p://u i te ch i e s .co.in /BBBcir cu its / pr odu ct.ph p?


pr od u ct=n r f2 401 - w i r e le s s - tr an s ce ive r - m odu le - ar du in o)
Sept e m b er 27, 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-6112)

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)

Hey, Muhammad! I have a doubt.


Can i have arduino and nrf24l01 on transmitter side and nrf24l01 interfaced to PC with modem on the receiver
side? Can i directly interface nrf24l01 to the PC?
Please reply as soon as possible.

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

pr od u ct=n r f2 401 - w i r e le s s - tr an s ce ive r - m odu le - ar du in o)


Octo b e r 3 0, 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-6626)

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)

Thank You Muhammad!!


I added a piezo buzzer with a frequency of 750 Hz, pos side of piezo to Pin 6 and neg side thru a 100 ohm resistor
to any ground terminal, and I also increased delay at the bottom of the loop to 15. Everything works great. Here is
the expanded Rx code. * Note: No changes were made to Tx code.
https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 17/24
#include
3/22/2020 NRF24L01 Arduino Interfacing | Wireless Communication

#include
#include
#include
#include

// Receiver (Pushbutton LED)

RF24 radio(9, 10); // CE, CSN


const byte address[6] = “00001”;
boolean button_state = 0;
int led_pin = 3;
int piezo_pin = 6;
void setup() {
pinMode(led_pin , OUTPUT);
pinMode(piezo_pin , OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address); //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_MIN); //MIN,LOW,HIGH,MAX
radio.startListening(); //This sets the module as receiver
}
void loop()
{
if (radio.available()) //Looking for the data.
{
char text[32] = “”; //Saving the incoming data
radio.read(&text, sizeof(text)); //Reading the data
radio.read(&button_state, sizeof(button_state)); //Reading the data
if(button_state == HIGH)
{
digitalWrite(led_pin , HIGH);
digitalWrite(piezo_pin , HIGH );
tone(piezo_pin, 750);
Serial.println(text);
}
else
{
digitalWrite(led_pin , LOW);
digitalWrite(piezo_pin , LOW);
noTone(piezo_pin);
Serial.println(text);}
}
delay(15);
}

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)

Can you make example for 4ch version?

REPLY

L E AV E A R E P LY

Your email address will not be published.

Comment

Name* Email*

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

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

Arduino RFID Projects


(https://electronicshobbyists.com/arduino-r d-
projects/)

(https://electronicshobbyists.com/arduino-r d-projects/)

Wireless Video Surveillance Robot using Raspberry Pi (https://electronicshobbyists.com/wireless-video-surveillance-robot-using-raspberry-pi/)

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/)

Raspberry Pi DC Motor Control with Custom Board (https://electronicshobbyists.com/raspberry-pi-dc-motor-control-with-custom-board/)

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

Subscribe to Blog via Email


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Email Address

Subscribe
I agree to have my personal information transfered to MailChimp ( more information (https://mailchimp.com/legal/privacy/)
)

We respect your privacy

ABOUT US

Terms and Conditions (https://electronicshobbyists.com/terms-and-conditions/)

Privacy Policy (https://electronicshobbyists.com/privacy-policy/)

Contact (https://electronicshobbyists.com/contact-us/)

Copyright ©2016-2019

https://electronicshobbyists.com/nrf24l01-interfacing-with-arduino-wireless-communication/ 24/24

S-ar putea să vă placă și