LoRa Module with Arduino- REYAX RYLR998 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's learn how to use lora module ry lr998 from reacts technologies we will explore how to configure lora module to be used as a transmitter and receiver using at command mode later on we will write an arduino program to wirelessly control the led using long range lower communication between two arduino uno board this video is sponsored by altium software rtm is the piece of a design tool i used in my very first job when i was working for a company in germany using rtm give it two advantages in my opinion one is that you can really build a professional skills and the second one is you can not only build a simple small circuit but you can build a really complex high speed electronic circuit using altium visible design so claim your free trial today with the link in the video description or somewhere in the comment section and i'm sure you will enjoy working with rtm so here we have a lora radio module from reacts technologies the part number is rylr 998 now one thing i love about this radio module communicate with other microcontroller over uh serial ui protocol so you can see there is a ground txt or xd and vdd pin so it's very easy to connect this loader module we cannot use this lora model straight away unless we configure the frequency and baud rate and the other parameters like address and network id and all other things into this video i'm going to show you how we can configure this lura radio module before we can use in our iot project using 80 command mode so we have to connect this loader module to our laptop and then through serial terminal we will going to configure this lower module as a transmitter and receiver so to connect this to the laptop we need something like this this is if you look at this it says usb to dtl converter and it has this txt rxd 3.3 volt and 5 volt in ground pins now here in this video i'm only going to show you how to connect the one lura module but the same way you have to connect the another loader module and we will going to connect this pins hard for this so let me plug in so now i have this four cables coming out from and you can see the red color is 3.3 volt the brown queen is txt the black is rxd and the white one is ground and i'm going to use this lora module and look at the back side of the lora module it's written like the first pin is vdd so i'm going to take this red one and i'm going to connect to the vdd because uh the pin of the module ry lr998 will be um you know 3.3 volt tolerance so make sure when you power it up uh your vcc pin means brilliant will be 3.3 volt and then we have to look for the brown one which is the txt so it will connect to the rxd pin so you know the transceiver communication the tx connects to rx and rx connects to tx we have this black wire which is rxt black that will connect to the txt and then the white one ground and this will be ground so that's how we will connect the lura radio module now i'm going to connect to the laptop something like this okay now we can find this luda module which is connected to the laptop so similarly we take this another lura module and we need one more usb to ddl converter to connect this another lora module to the laptop okay and we will going to transmit wirelessly a data from the transmitter to the receiver now to setup configure and test the lura module we have to connect the first lora module to the laptop we just have to open a device manager and under device manager we can able to see if we expand the ports section you can see the com4 is assigned to the first loader module that we connected to the laptop now we will be using the at command mode to configure the lura modules before we use the slora modules we have to use the 80 command mode reacts company have a very high quality documentation you can easily download this 80 commands user guide you can see lora 80 commands guide i have given the link in the video description so you can just quickly go to product page and you can download it we have to open the arduino ide so let's open the arduino software and we don't need to write any arduino program or something like that we just have to open the blank arduino project okay whatever we have and then we go to tools and make sure the com port is selected properly so if you remember our luda module is connected to com4 to our laptop so we select the com4 and we should open the serial monitor now when the serial monitor opens up then you can able to see baud rate that is selected here is 11 5200 because by default this lura module ry lr998 from reacts these lora modules have the default baud rate 11 5200 that's why we have to make sure the baud rate is properly selected that's one one five two zero zero and if we go here and if we type the 80 command that's basically just to type 80 and hit enter you can see it returns okay now we are setting up the parameters for the first lora module and 80 commands when we pass and when we receive okay that means the slower module is working fine now we have to set up the address type 80 plus address and we have to say address is equals to one so we will set the address to be one for both lora modules and you see even passing after this ad plus address is equals to one we get ok that means the address is set now we have to set the network id and we have to type 80 plus network id that's basically the 80 command type the command 80 plus network id is equals to 5 that means we are setting up the network id to become a 5 you can put any number just make sure the address and the network id should be same for both lura modules so let me hit enter and it returns us okay that means the network id is set now you probably know the lora radio module has a specific frequency in a different different countries and continents so you have to make sure you set the frequency band based on the location so i live in india and for india frequency band for lura is 865 megahertz to 867 megahertz so the next step is to set up the frequency band so we have to type 80 plus band and then say is equals to 865 so i would set 865 megahertz and 865 and then hit enter and this basically sets up the frequency band to be 865 megahertz and now it's good to uh set a baud rate to be 9600 because that what we will be writing an arduino program in the future so i want to change the default baud rate which is 11 5200 so i want to make it as a 9600 so i would going to change the baud rate by typing a command 80 plus ipr is equals to and then 9600 okay and i hit enter and it returns ipr is equals to 9600 that means the baud rate is set for 9600. now if i type 80 command again and hit enter you see i don't receive okay back that means the baud rate that is set into the serial monitor is not correct so look at this it says 11 5200 so i have to select the baud rate to be 9600 because i just changed the baud rate to be 9600 so i select 9600 baud rate here and now i test the 80 command so i type 80 and hit enter now you see it returns us ok that means this lower module the first lura module is set for the baud rate 9600 and its network id is five and the address is one now let's connect the second lora module and i will show you the device manager and you see the second lura module has assigned com5 so i'm going to open uh just a random arduino program just because otherwise it would not let me open another serial monitor right so i have this another arduino sketch just a new arduino project and then i go to tools and i select this time com port to become a 5 because the 4 is busy with the first luda module so i select com port 5 and i open a serial monitor now i have a two serial monitor side by side if you can able to see clearly so the first serial monitor which is on the left is com4 which is the first lora module and the second serial monitor is connected to com5 that is the second loadout module and if i type at command on the second serial terminal that is for second loader module if i type 80 you see i get ok back now let me set the address and make sure the right side of the serial monitor for second loader module is basically set the baud rate to be 11 5200 because that's what the default baud rate is so 80 plus address and we have to set the address to become a one for the second loader module because the first lora module is also set for the address one now we have to say 80 plus network id and we set the network id for the first lura module to become 5 so we make sure that we make the same network id that's 5 and you see it returns us ok back again and now we have to set the frequency band for the second luda module and that would be 80 plus band and this will be the same frequency band which is 865 megahertz so eight six five one two three one two three so it's like almost like a six zero you have to put in so it's like 865 megahertz and now we set the baud rate to be uh 9600 because the first lora module has a baud rate 9600 that's why we have to change now the baud rate for the second lura module as well so we have to say 80 plus ipr is equals to 9600 and hit enter and then you see now the border has changed to 9600 it returns ipr9600 i would select now on a second serial nine six zero zero because that's the baud rate for second lower module now you can see the first lora module has a baud rate 9600 as we have changed for the second loader module it's again 9600 so make sure the baud rate is selected properly otherwise the commands may not work and now if i uh type 80 command here on a second serial terminal i get ok back so this means the both lora module has been configured properly with 9600 port rate so what i'm gonna do is i would go to my first lora module and i would going to type 80 plus send because i want to send a string from the first lora module to the second lora module wirelessly so i would type 80 plus send is equals to then one which is an address of the luda module and then comma then i would type six like how many bytes so i'm going to send binary which is a six characters that's why i said comma six here comma six comma binary because six bytes are there so if i hit enter here you see i sent from the com4 from the first lura module and i received the binary text string on the second lora module wirelessly now i'm going to send a message from the second lora module to the first loader module so i'm going to type ad plus send which is an 80 command to send the text 1 comma 7 comma updates for binary updates so if i hit enter you see on the first lura serial terminal i get updates that means we are sending messages back and forth now what i'm gonna do is we will going to remove this uh lora radio modules from our laptop and we will connect to two different arduinos and we will going to connect and send the data back and forth so we have the arduino uno along with the switch a tactile switch you can see and we will interface this lora module with arduino uno and also attack light switch so together this will gonna build the transmitter lura node for us and then we will going to upload the code on this arduino uno so we need uh quite a few male 2 male jumper wires and i think you can see as i have placed the lura module here you can clearly see the names on the luda modules so there is a vdd rxd txt and the ground pin so let's take the jumper wire so the first pin is vdd so make sure they are plugged in properly so the first pin is the vdd that's going to connect to 3.3 volt on arduino uno and the second pin is basically an rx so one after it so there's an rxd so the rxt on the luda module will connect to pin number three on arduino uno so zero one two three make sure the connection should be right otherwise uh this communication may not work and then we have to take another jumper wire and we'll connect to the txt that will going to connect to the pin number two on arduino uno so basically this is a transceiver communication so the lora tx will connect to the rx of the arduino and lora rx will connect to the tx of the arduino so that's that's basically a transceiver and then we have to connect the ground pin so the last pin on the lower module will be ground so finally i take this ground and i connect on the other end just a ground so that's basically just this this all together basically form the lura module connection with arduino uno all right now what left is the switch and the switch this tactile switch i hope you know how the tactile switch works right so one end of the tactile switch so one end of the tactile switch this will gonna connect to let's say a pin number five because in our transmitter lura code we have used just pin number five and the other end of the switch tactile switch will connect to the ground and here on the other side we have the ground pin okay so this together form the transmitter uh lura node so here we have another arduino and we have the lura module you can see i just flip it around and now you can clearly see the names on the lura module and here we have connected an led on pin number 13. there's a built-in led but i prefer to connect external led to pin number 13 so when we press the button a switch on from the transmitter uh arduino then the led which is connected to pin number 13 will light up so we don't have to connect uh any led on the breadboard rather i would prefer to connect it like this even if it's not a good practice but it's still be okay so let's hook up the lora module with arduino uno so first pin as always the first pin is vdd that's going to connect to 3.3 volt and here is 3.3 volt and then we have to take another jumper wire and that gonna connect to this rx pin on the lura module and that would going to connect to [Music] the rx of the lura module will connect to pin number three on arduino uno and then we'll take another jumper wire and this is the txt that would connect to pin number two on arduino uno and finally we need one more jumper wire so that's gonna connect to the ground on load our module and it would connect to the other end of the arduino that's basically a ground so this is how we will set up the receiving circuit of an arduino with the lura module for this uh receiving end of the lora so we will connect it and upload the lora receiver code you can see on my screen we have a load of transmitter project and we have a load of receiver project you can easily able to download this code from the github repository the link is given in the video description so you can easily download this code and then make use of for your project i can just minimize this and just open the lora transmitter code so you can see here we have a code that is for the transmitter end of the arduino and the transmitter luda module so what you see is we are using the software serial library because we are not we don't want to use this tx and rx pin on arduino uno because they will be busy when we upload the code on arduino on the transmitter side of the node and then we have connected a button switch which is basically a tactile switch that's connected to pin number five on arduino so when we press the button switch connected to pin number five it will generate a logic low and that will send it to the other end of the arduino that's where we have receiver lura module is connected then you see we have a software serial instance lora created and then we said okay uh pin number two will be rx and three pin number three on arduino will be a tx so we are basically translating the p number two and three as a rx and tx so we can connect the lower module there and then we have this string which is uh lora rx address that's one because when we set up the luda module into the 80 command mode then we set the loader address to be uh one okay receiver address to be one so then you see uh the setup function we says okay we want to set the pin that's basically the button pin number five on arduino which we want to configure into the input pull up mode and then we set the baud rate for the transmitter arduino to be 9600 because the loader module that also set up for the baud rate 9600 and then in a loop function you can see we have the if statement and in this if statement when we press the button so it's basically if the digital read that's basically the button so when the button is pressed then the logic low will happen and when the logic load detects then basically we want to send the string and look at this lora dot print ln that's where we are sending 80 plus send is equals to one and then comma two comma low so that's basically what's happening is when we press the button that is connected to pin number five the logic low event will occur and it will send the lo so it's basically not only sending lo but this will send the complete string okay else if we don't press the button connected to pin number five then this piece of code will execute and basically what happens is this lineup code will send 80 percent is equals to one two comma high so basically what i'm trying to say is when we press the button then the lo this message will be sent and when we release the button that means when we don't press the button then continuously every one second it will send high message hi hi and that's how we're gonna detect the button press event as a lo low and when we don't press the button by default it will be a logic high so h i high so that's basically the transmitter end of the arduino code so what i'm gonna do is i would go to tools and make sure your arduino which is the transmitter end of the arduino where the transmitter loader module is connected so as i have connected and the com port is seven so i'm going to select the com port and upload the code and that's basically complete the transmitter end of the loader node right so the code is uploaded you can see in lower left corner it says done uploading now let's connect the receiver the arduino uno and here i have a code already written you can download it's a low receiver code and you can see here again we are using the software serial library and we have defined here a macro as led and that's basically we are defining pin number 13. so on arduino uno you know that we have a built-in led which is connected to pin number 13 if you want you can connect external led i have connected external led which makes it more readable for people to see and then we have created here a string variable incoming string because from the other end of the loader transmitter means the arduino and the loader transmitter is sending us a string you remember i said 80 plus sent is equals to one comma two comma high h i or l o low so basically to receive the string coming from the transmitter end of the luda module we want to define this incoming string on in which we will going to store this incoming string and then you see software serial instance we have created lura and then again we are using pin number two and three as rx and tx that's where we connected our lura module and then you you see that we have the pin mode means led connected to pin number 13 as an output and then we have defined here the portrait which is a 9600 portrait because in 80 command mode when we set up the lura module we set the baud rate for the lura button to be 9600 that's why we have defined it here now you can see that we we have used one function that's called set timeout and the set timeout function is a set of maximum milliseconds to wait for stream data this function is a part of stream class because the data coming from the transmitter loader is coming as a string set timeout function which is basically the maximum milliseconds that we have to wait when we are reading the stream data by default it this set timeout function has by default take one second that means a thousand milliseconds so i have set up this set timeout means i want to wait for 500 milliseconds because we are sending from the transmitter end of the lura module and arduino uh one second delay right so at least we have to wait for 500 milliseconds so 1000 milliseconds will be 500 milliseconds after that there will be a thousand milliseconds so it's this decent amount of weight will help us to read the lora data to be received at the receiving end of the lora module so that's why we have given this 500 milliseconds as to wait before we read on the receiver end of the low round module okay otherwise what happens is data comes so fast and then it creates a trouble for us and ultimately we don't read any data so if we scroll down here okay and you see in a loop function here in a loop function which says if lora dot available so basically we are reading the serial data uh if the data comes then in incoming string we are reading lora dot read string so the data coming the string coming from the transmitter end of the low drama tool we want to read it and store it into the incoming string variable then we print it on a serial monitor just to see what's coming and then we have this data array defined as a size of 30 characters we are not sending 30 characters i think it's hardly maybe i think nine or ten characters that we are sending all together i think i have given 30 that's fine and then incoming string dot 2 card array so basically we have to convert the string into the characters and then we store into the data array and then we are using this very interesting function called strtok so this is this this function strtok is a function which is basically allow us to tokenization of a string so it passes uh the string up to the first instance of first deliminator character and what what basically we are doing is into the data array when we store all um the characters then we want to separate them and pass them and then differentiate them by comma because if you remember the string that we are sending from the transmitter and we are separating by comma and that's why we want to detect the comma and then you see here we are detecting this comma and that's why we put into the data character pointer we are just scanning this this comma into the string so what's basically we are doing is we are separating every uh you know single uh character byte that is coming from the transmitter end and the reason for that is because later if you look here we have defined this as a character pointer you can see there's a character pointer data and into this character pointer data we are scanning and comparing this high hi because when we when we don't press the button on the transmitter end of the loader module then it will by default send us message high okay and that's basically results in to make the led on the receiver end to be a logic low that means by default the led stays off and we have given here a delay of 50 milliseconds now this other if statement is where we compare this if in case we press the button on the transmitter end of the arduino or the loader module then lo will be sent then lo will be compared with this data array and then if it there then basically it will turn on the led which is connected to pin number 13 and that would basically generate the logic high on pin number 13 which in results will turn on the led and then we have given a decent amount of delay which is 50 milliseconds otherwise it will be too fast for us to recognize whether to make it high or low based on whether we are receiving this whether we are checking for high or low because this will run very very fast this loop function and we couldn't able to recognize the event so once we are done so let's upload the code so we go to tools for the transmitter we have the com7 and for the receiver we have the com6 so we select the com6 on the receiving end of the loader module ready so as we have uploaded the code we can open a serial monitor here on a com6 so you can see now the data is coming as a high because i have not pressed the button as i said you know look at this i can just put it here for you to see let me just take this okay so by default the message high is what we are receiving okay look at this high is coming so when i press the switch on the other arduino so which is basically is connected to com7 that's a transmitter now if you see hello event is detecting and led is on so you can see there are two arduino one arduino is a transmitter arduino with transmitter lura module and there is a load of transmitter code running on one arduino and the other arduino is running lower receiver code we have this button a tactile switch so when we press the switch here on the transmitter uh lower module which is connected to arduino transmitter so when we press the button you see the led on the receiving end will light up as i release the switch you can see the led goes off so what happens is basically when we press the switch then it will send the message uh to turn on the led and when we release the it will send the message and it turn off the led so this is how the wireless radio communication is working using lowdown module if you are looking for high quality courses to learn embedded systems in iot then check out the link in the video description i hope you have found this video educational and entertaining we'll see us into the next video bye bye for now
Info
Channel: BINARYUPDATES
Views: 19,240
Rating: undefined out of 5
Keywords: LoRa, RYLR998, Arduino, Wireless
Id: vgYVVC6Lvl8
Channel Id: undefined
Length: 26min 49sec (1609 seconds)
Published: Sun Jun 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.