Simplest Way To Wirelessly Communicate Between Arduinos | nRF24L01+ Modules

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we are going to look at something a simple yet useful I am going to show you how you can send data wirelessly from one hundred winner board to another using some very common wireless modules I will be using these for the home automation project but I decided to make a separate video for future reference these modules are by far the simplest ones you could use to add wireless capability to all your projects the modules themselves are extremely cost effective and not available for much less than a dollar the older version of this was called the NRF 24 l01 and it only supported data rates of one or two megabits per second the newer version is called the NRF 24 l01 plus and it can support an additional lower data rate of 250 kilobits per second the lower data rate does consume slightly less current and I also think that it will be less susceptible to interference compared to the higher data rates as it will not use as much bandwidth the model I will be using has a PCB antenna which makes it compact but you also get a variant that supports an external antenna as seen here this allows a much higher range of about 1,000 meters in line of sight these are best-case values so take them with a pinch of salt the powered on current consumption is 900 nano amps which makes this suitable for battery-operated nodes in order to get this working we need to such RF modules we will also need to arduino boards and i will be using two arduino nanos the Nano every and the old one which is simply called nano the RF module needs to be powered with 3.3 volts and it uses SPI for communication this means that we need four additional pins for communication finally we have the sieep in which is used to activate the transmitting or receiving mode bringing the total to seven pins on the transmitter side I'm going to add a switch to pin two such that it will be pulled low when the switch is pressed on the receiver I will connect an LED to pin two you could also select any other pin that you like and this is a reference wiring that you can use the models cannot be used with a breadboard because the pin spacing is not enough to place it in the middle and if you place it anywhere else then you will end up shorting the Pens this means that you either have to solder wires directly to it or use some jumper cables I decided to go with the latter and here's an example of how I've connected the Arduino Nano every board to the radio module now that we have a goal in mind along with the circuit and it's time to work on the sketch so that we can test it out for this we will need to install a library so use the tools menu to open up the library manager and then type in n RF 24 select this library shown here and install it give it a minute to complete and close the window you will now be able to access the example sketches but these are a little complicated so download the sketches from the github repository and open them up in the arduino ide let's start with the transmitter sketch all we are doing here is assigning an address to the module and we will have to use the same address for the receiver this is how the RF modules know who they have to communicate with we then initiate the module and get it ready for transmission if the switch is pressed then the pin will go low and we then send a message 1 1 1 or else we send a message 0 0 0 you can also change the value that is being sent to suit your requirements you will then need to select the correct board settings along with the comport and upload it to the transmitter board once that is done open up the receiver sketch make sure that you use the exact same address that you used in the transmitter sketch all we are doing here is getting the module ready to receive data and we then start listening to the data that is being sent to it if we receive the number 1 1 1 then we know that the switch was being pressed and so we switch on the LED in all of the cases we switch the LED off you will then to select the correct both settings along with the comport and upload the sketch to the receiver board it is now time to test it out I have the transmitter on one side with the receiver on the other when I press the switch you will notice that the LED will light up instantly and this is exactly what we want that is the quickest way to get started using these modules you can extend this principle to do just about anything that you want you can read through the ping pass DP example to get an idea of how you can use a sleep mode to conserve battery a single node can act as both the transmitter and the receiver though you cannot send and receive data at the same time that is the reason why you have the stop listening and start listening functions which allow you to take control for example if you want to send data then you will first have to call the stop listening function once you are done sending data you can then start listening again what we have here is a one-to-one communication between two nodes we have given the nodes the same address which allows them to communicate with each other theoretically we could add another node with the same address and communicate between all three and this can then be extended as needed however only one node should be sending data at any given time or else there will be collisions if you want to send data between multiple nodes then it would be advisable to create a mesh network this will get rid of the collisions as the communication between the nodes will be automatically handled in the mesh network the second benefit is that you can extend the range between the nodes as an example let's say that we have two nodes in the one-to-one communication mode and that the maximum distance between any given nodes is D this means that all the nodes will have to be located within this distance or else they will not be able to communicate with each other in the mesh network each node can act as a repeater which means that as long as the distance between any two nodes is within D we can still communicate between all of them this means that the nodes can be located much further away there is an R 24 mesh library from the same developer that can be used for this and that is it for this video hopefully this will make it easy for you to add wireless communication to your projects I will be indicating this with the home automation project next so stay tuned for that thank you for watching and I will see you in the next one
Info
Channel: bitsNblobs Electronics
Views: 39,370
Rating: undefined out of 5
Keywords: nrf24l01+, adding wireless radio modules to arduino, rf module arduino, wireless data communication, nrf24l01, nrf24 getting started, using rf modules, sending data wirelessly using arduino, arduino tutorial, arduino nano + nrf24, arduino nano every, beginner arduino tutorial
Id: Zd3h6SrsGZM
Channel Id: undefined
Length: 7min 5sec (425 seconds)
Published: Sat May 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.