Video: Arduino Tutorial: Arduino NRF24L01 Wireless Tutorial with Arduino Uno
Dear friends welcome to another video! This is Nick from educ8s.tv and today we are going to take a look at the impressive NRF24L01 wireless transceiver module. We are going to learn how to add wireless capability to our Arduino Projects! Without any further delay let’s get started! In this video we are going to build a simple project just to demonstrate how easy it is to add wireless capability to our Arduino Projects. I have two Arduinos here. This one is sending some data every second, and the other one is receiving the data and displaying it at the serial monitor.
As you can see this one way communication is working fine and the range is very good, I can easily get more than 10 meters! The theoretical range that we can achieve is about 100 meters. The NRF24L01 module is a low cost bi-directional transceiver module. The cost of it is less than 3$! You can find a link for it in the description of the video. It operates at the 2.4GHz band and it can achieve at a data rate of 2Mbits! Impressive isn’t it? It uses the SPI interface in order to communicate with Arduino, so it is very easy to use with it. We have to connect 7 of the 8 pins of the module in order to make it work with Arduino. Let’s see how to do it. Unfortunately we can’t plug the module in the breadboard so we are going to use male to female wires in order to connect the module to Arduino. Pin number 1 of the module is GND.
You have to connect it to Arduino Ground. The next pin is Vcc. You have to connect it to the 3.3V output of the Arduino Uno. Be careful! Do not connect it to 5V or you will destroy your module! The third pin is named CE and you can connect it to any digital pin you like. In this example I am going to connect it to digital pin 7. Pin 4 is CS and you can connect to any digital pin as well. I am going to connect to digital pin 8. The next pin is SCK which goes to digital pin 13 of the Arduino Uno. The next pin is MOSI which goes to digital pin 11 and the last pin in MISO which goes to digital pin 12. That’s it! Now let’s power up the project and see if we can receive the data that the other module is sending! Great! As you can see, we receive the data packages that the other module sends. Now let’s see the code of the code for both the receiver and transmitter.
First of all, we have to download the RF24 library in order to make our life easier when we work with the NRF24L01 wireless modules. You can find the link for the library in the description of the video. Let’s first see the Transmitter code. It sends out a simple data structure which contains an Integer, a Float, and a character array. In order to establish a communication link we have to create a “pipe” between the two modules. That pipe needs to have an address. Both modules have to write and read from the same pipe in order to communicate. That’s the first thing we define in our code, we set the pipe address to “0”. Next we define the channel at which we want to communicate with the other module. The NRF24L01 chip supports 126 different channels. Both modules need to use the same channel in order to communicate with each other. In this example I am using channel 115. Next, I define that I want to use the maximum transmitting power that the module offers. It uses more power but extends the range of the communication. Next we define the data rate of the transmission.
I set it to 250Kbs which is the lowest possible data rate in order to achieve better range. The next step is to open the pipe in order to write to it later. In the loop function, we send the data structure we have defined by writing the data structure to the pipe, we change the values of the data structure in order to send different packages at every loop and wait for a second. That’s a basic sender program. Let’s now see the receiver program. At first we define the same data structure that is going to receive the data. Next, we define the same pipe address that we used in the transmitter program as well. We initialize the module with the same parameters that we used in the transmitter and we open the pipe. In the loop function we wait for data, and when there is data available in the pipe we save that data in the data structure and print them in the serial monitor. That’s it. You can find the code of this project in link in the description of the video.
As you can see we the code of the project is very easy! We send data from one Arduino to the other. It is a simple one way communication, we don’t know if the second Arduino receives the data, we send new data all the time. In a future video, I am going to show you how to achieve bi-directional communication with these modules in order to have a more reliable communication. This video is intended to be simple project in order to demonstrate that these modules are a great easy way to start with wireless projects. Many of my future projects will use these modules! I would like to know your experiences with the NRF24L01 modules. Do you use them in your projects? If so, do you have any advice to share with us? Please post your comments or ideas in the comments section below. Also, if you want to see the latest channel news, like what project I am currently working on, you can follow the Facebook page of the channel at https://www.facebook.
com/educ8stv . If this is your first time here, I would love to have you subscribed. In this channel I post videos about DIY projects every Saturday. I build projects with Arduino, Raspberry Pi, I build robots and simple electronic circuits. I hope you will join our community. I love making things and helping people doing the same. I hope that you will join our community. Until next Saturday, Watch, Learn, Build!.