Arduino meets RYLR998: A Comprehensive Guide to LoRa Module Integration

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a couple of months ago rayax electronic parts manufacturer from taiwan contacted me and asked me if i could review some of their products naturally i said okay we decided which products they want me to review and they confirmed that they are on their way i said okay to that as well so lo and behold few days ago a fedex parcel has arrived and after i open it among other things i found those two beautiful lora modules this is uncharted territory for me as i have never used laura or any other radio transmitters for that matter so if you stick around and watch this video we can go through this learning curve together [Music] [Applause] right from the start everything about these lora modules i received and also other components from reacts indicate good quality from the way they were packaged each one inside separate small plastic container quite different to aliexpress parcels i'm used to to the quality of the board itself i know this incorporated shape of the dove does not make this board work any different but i thought it was a nice touch and finally the data specs that you can download from their website they really make it easy to configure and use these lora modules apart from the tooler modules i also received this usb to uart converter i'll use it to connect the lora modules to the pc and through serial interface program them assigning address network id frequency etc i'll discuss this in detail later in that video let's now look at our lora module it has five pins vdd and ground to power the module then serial communication pins txd and rxd through which will transmit or receive information and then the last pin is the reset pin so how does the lora communication works each lora module has some basic parameters configured first one is the address it can range from 0 to over 65000 the address needs to be unique second is the frequency next is the network id it can be anything from 3 to 15 and also 18 which is the default value all loras with the same network id belong to the same network when all those parameters are set in this way those two lora modules can send and received information in both directions using the same defined frequency if we introduce one more module with unique address same frequency but a different network id then despite transmitting with the same frequency we would not be able to communicate with the other two modules there are more parameters that can be assigned to those modules and we'll talk about them later how do we connect the lora module to the microcontroller and which arduino microcontroller should we use lora is working with three volt logic so without tweaks you cannot connect it to the most popular uno and nanoboards as they work with five volts higher voltage could destroy lora modules i chose to use arduino pro mini 3 volt edition if you are not familiar with that board my next video would be a tutorial on how to use it so to radio transmit data we would need the second microcontroller we've connected lora so the first mc with lora would be a transmitter and the second one would be a receiver so first we need to connect lora vdd to arduino vcc and lower ground to arduino ground then we connect serial communication pins on both modules rx of lora goes to tx of arduino and on a receiver tx of lora goes to rx of arduino and finally we are connecting lora reset pin to digital pin 4 of arduino if you are not planning to do hardware reset of lora module you can leave it unconnected you can always reset the module from within arduino code in this video i'll try to control the status of led connected to the receiver in this video i will try to control led connected to digital pin 6 on the receiver we'll control led by sending capital h through lora to the receiver and when this is detected led on the receiver would turn on to turn led off we would be sending capital l we can program lora module in two ways first is to connect it via usb to uart converter to the pc and execute configuration commands in the serial monitor when connecting lora to uart converter we connect ground to ground vdd of lora to 3.3 volts pin on the converter then connects serial communication pins rx of lora goes to tx of converter and tx of lora goes to rx of the converter when this is done we connect converter to the usb port of the pc after starting arduino ide on the pc we can open serial monitor and test if we can communicate with laura two important things you have to change the bout rate as the default baud rate of lora is different to the standard baud rate that you'd use with arduino ide and then you also have to make sure that after each command the new line and carriage return are added at the end otherwise you would receive errors to test if the connection is established you can type add command and if everything is fine you should receive ok message add command is used to program laura you can send three types of commands with it commands checking the value of any parameter here is the syntax so for instance if you want to check the address of the module we would type the following command and here is the sample response from lora module here is the list of the most important lora parameters the mode where zero indicates the module is ready to transmit and receive the address and network id are the parameters i have already covered bend which indicates frequency with which modules communicate ipr indicates serial communication bowed rate there are some additional parameters for the transfer which should be adjusted depending on what is the distance between transmitter and receiver i am sticking to factory defaults here the other type of commands are the ones that set the value of the parameter so if you want to change the address of the board from the previous example you'd type this command lora confirms successful execution of such commands with ok message we can repeat the initial query to see that address has in fact been changed the last group of commands change the status of lora module or initiate transmission so we have reset command reverting back to factory defaults commands and finally send command to initiate the transfer to send data we have to provide the address of the target lora module data length and then the actual data we want to send in this example we are sending text hello consisting of five characters to the lora module that has the address 50. let's connect the lora module to the converter done now we can connect converter to usb port of the pc everything should be in place now let's run at command to see if we can talk to laura and we can let's check the active mode it is zero so the lora is ready to transmit and receive next let's check what is the current address of the module it is 18 and we want it to be two let's run command to change it and the command to check if the change was successful now let's check the network id it is 18 the factory default value let's change it to 3. let's also check the frequency and change it to a different value i am changing those parameters for the purpose of this video normally i would stick to the default values unless they could not be used for whatever reason let's check the bowed rate with which the serial communication is established here i will stick to factory defaults also transfer parameters will remain unchanged so we configured lora connected to the receiver now we need to repeat similar actions for the other lora that will be connected to the transmitter let's start building our prototype for now we will build just a receiver circuit as we would use lora connected to the pc with serial monitor as a transmitter for now i would use this dc power module to power the circuit i have to make sure that those jumpers are properly positioned to choose 3.3 volts as an input voltage it's important because you can damage microcontroller and the lora module as well then we plug in arduino pro mini microcontroller to power the arduino we connect microcontrollers vcc and ground pins to vcc and ground rails of the breadboard now comes the lora module here we also connect vcc and ground pins to vcc and ground rails of the breadboard and then with the jumper wire we connect txd of lora to rxd of arduino as this is meant to be just a receiver we do not have to connect rxd of lora and finally we need led i use this little part led with already built in current limiting resistor this goes to digital pin 6. now let's create the code for the receiver we declare led pin first then we have incoming string variable to which we would save incoming data received by laura in setup we declare led pin so digital pin 6 as output we also open serial communication to lora with the standard baud rate of lora in loop we check if there is incoming data on the serial port if there is we save it to incoming string variable and then with index off function we check if that string contains capital letter h when it does then we send the high signal to digital pin 6 to turn the led on if we detect capital letter l then we send the low signal to led pin and the led turns off fairly simple right i have to load the code to microcontroller there is more hassle with this than in case of arduino nano so i'm not going to show how this is done please check my arduino pro mini tutorial if you are not sure how to do it the code is loaded and the circuit should be ready to receive data now i need to open the serial monitor establish connectivity with lora that is connected to the pc and run the send command to transmit capital h to the lora connected to arduino so we send the message of one byte in length to the lora with the address two led unfortunately did not let let's try it few more times nothing it is difficult to troubleshoot i would have to connect microcontroller to pc via uart interface to open serial monitor but the only uart converter i own is used to connect the lora to the pc i ultimately used oled display to investigate what kind of data i was receiving through lora i connected it to vcc and ground rails of the breadboard and since this is i2c device i connected clock and data pins to arduino analog pins a4 and a5 i'm not showing all that related stuff not to merk the code but if you want to see how i did it there will be a link to the code in the description of this video let's reload the code and try to send capital h through laura again and see what the heck is wrong and you can see that we are receiving complete gibberish no wonder the led did not react and the solution was that the 3 volt arduino pro mini has a 8 hertz system clock that cannot handle the default baud rate of lora module so it was microcontroller problem not the problem with laura let's see if after applying the fix the transfer would work fine we have to change the default baud rate on both loras to a smaller one eg 57600 and also make sure that when loading the code to arduino we compile it for arduino pro mini board with 3 volts and 8 megahertz don't forget to change the baud rate in the code alright the code is loaded let's connect the arduino and see if the problem is resolved let's try to send capital h again a moment of anticipation and it works not only led turned on but also oled displays the exact data received from laura let's decipher it rcv indicates that this is the received data and then we have address from which the data was transferred from data length received data in ascii formats then additional information less important to us now received signal strength indicator and signal to noise ratio let's change the status of led few more times and observe received data on the oled screen let's now create transmitter circuit this is the diagram and here's the breadboard prototype i built for it you have your arduino pro mini here and lora connected to it i have also added led here which would be in sync with the one on the receiver and the button that would be used to control both leds working like an on off switch i used the code from one of my videos you can check it out here we read the state of the button and check if it has changed from low to high in this case if the state of the led was low we change it to high and send high signal to led pin to light up the led and if it was high we change it to low and send low signal to led pin at the end we save current button state so it can be used to compare against state that will be read in the next run of the loop function so in this code we'll add just two lines when we change the status of led to high we also send capital h through lora to receiver and when we change the status of led to low we send capital l through lora to receiver i loaded the code to the transmitter now let's put the transmitter and receiver side by side power them on and let's see if we can turn led on and off by pressing the button it works great capital h received led is on now l turns it off mission accomplished this is all as far as this video is concerned i did not manage to squeeze all the information i wanted into it so most likely i will be creating the second one where now squeeze topics like laura's range using 5 volts and microcontrollers like uno and nano with this 3 volts lora module and also i'll configure arduino with lora as a transceiver capable of both transmitting and receiving hope you enjoyed this tutorial the video like this takes ages to create so if you find it useful please consider supporting me by becoming my patron for as little as one euro per month you will find the links to my patreon website below i will see you in my next video [Music] [Applause]
Info
Channel: Mario's Ideas
Views: 19,595
Rating: undefined out of 5
Keywords: arduino, Arduino PRO mini, PRO, mini, LORA, REYAX, Serial, RYLR998, Transmiter, receiver, Radio, Tutorial, how to, instructable
Id: LiWlPERp1ec
Channel Id: undefined
Length: 16min 58sec (1018 seconds)
Published: Sat May 28 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.