Peer-to-Peer LoRa Test: Reyax RYLR998 - ESP32 - MicroPython

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right here i am walking down the highway risking my life to bring you good youtube content all right guys check these out these are kind of neat little toys here these are some let me get in close here where you can see it there's some laura modules that were sent to me by the reacts company okay and they're made for peer-to-peer so let's have let's look at the back of one of these so what that means is that you can create a little network of these things and this one can talk to this one can talk to another one whatever you want to do you create a little network and they can communicate back and forth but what these can't do is communicate with a lower gateway okay so they're just set up for peer-to-peer one to the other but you know the idea with laura is that if you're sending a small amount of data like maybe we got something set up with these and we're doing a little iot thing we're sending a small amount of data then we can use laura to send it instead of using the wi-fi that's on the esp32 and there's two reasons for that one the wi-fi on the esp32 can use up to 300 milliamps of power while it's transmitting which is a lot this maxes out i think at 140 milliamps so it's half the amount of power when you're transmitting also the transmit time can be a lot smaller because you're just sending a tiny amounts of data here you don't have all the overhead here that you would have with this you know making a a wi-fi connection you know using you know udp or tcp all right so that's one thing and then the other thing is distance that laura is supposed to go further so it gives you a bigger range of things so what i'm gonna do is get get one of these minis here's a new mini you guys haven't even seen yet this is the three model i'm gonna get one some of these minis and we're gonna set these two things up and get them talking to each other they just use the at commands over serial so if we look at the let me get this on the camera maybe you guys can see this yep ground uh there's a uart transmit you are receive a reset pin and a vdd all right which is 3.3 volts on this so this is going to communicate serially using the uart port on the sp32 so we'll get these things set up i wrote some software for you and we'll get them communicating with each other and then we'll see how much distance we can get just do a little test of these things so let me get these let me get them set up all right let me show you my test rig so i went down and i cut these two sticks here so i've got the ray x chips i can't remember what they are rylar998s okay so i got the rayx chips on the top and to maximize transmission i put the you know the antenna where it's above any of the stuff it's the highest up piece okay and then we move on down and we've got our wires connected so red is three volts the brown is the ground the orange is the reset the yellow is going to be the uh receiving data on the uart the the tx the green is the no i got those backwards because it's the other way on the usp32 okay so the yellow is uh okay starting over on the wires the red is the 3.3 the brown is ground the orange is the reset the reset is held low so we just have to give a positive pulse for 100 milliseconds to reset this is the receive this is the rx for this and this is the tx for this okay and then uh when we go down to the esp-32 i got these marked as this is the bounce and this is the send bs don't read that the wrong way okay so so this one this one is gonna this one's gonna send a signal this one's gonna pick it up and bounce it back send it back to this one the same same signal back and then this one checks to make sure it's getting the right signal and then it will flash when it gets the right signal so actually they're running right now okay so this one sends this one gets it it flashes when it balances this one gets it it flashes when it checks and knows that it's correct same signal back all right so this is the esp-32 so up there we're just bringing this down and we're picking up a ground here and a 3.3 volt right there and then uh we're coming down here and our this is our reset uh pin 19 our 18 17 is the transmit and 16 is the receive on the uart here and then this is the programming uart which is not going anywhere okay and then we got a ground coming off down here and then so these are our programming uarts which we're not using at the moment and then here's uh this is actually 4.2 in down from this lithium come on focus from this lithium battery okay so that's our test setup sent from here bounces from here flashes when it sends it back and then this flashes when it's verified that it got back the same message all right so this this is a mini esp32 mini v1 this is the v2 i didn't use the v3 okay so that's our setup and that's what we're going to test and see how far apart we can get with these things sending sending data all right um let's see i think we'll look at the software now and see what it actually looks like sending back and forth okay as with all the software everything's up here on clayton's pcb shop on gitlab so there's the address right there duder1966 okay so if you go down to micropython and there it is right there the rly now r-y-l-r-998 that's very difficult for me to say all right so whatever you see here is exactly what we're going over right here okay so the place we want to start is with the docks so let me get this where you can see it and this is the info or the i don't know i guess it's the data sheet gives you some basic stuff about it here's your pin outs okay a little timing stuff and here's the important thing specs so 3.3 volts don't over voltage it like people tend to do with 5 volts it's 3.3 all right that's important and then here's the other interesting three thing is 140 milliamps at 22 decibels so that is when it's at maximum transmission power it will it can pull 140. so i've seen the esp32 wi-fi go as high as 400 spiking up to 400 on kevin durant's channel and then you know three to 200 milliamps kind of at a steady rate while it's transmitting so this is a lot less and may up you know up to 50 percent less i would say uh when it's transmitting and then here is the you know receiving mode is is pretty low okay so those those are the important things right there are the things that i'm interested in but that's the data sheet i did notice you know that this antenna there's a lot of leverage on that little solder joint right there and mine was actually broken when i received it and i had to resolder it and get that back on there because something had just pushed on this and it snapped it off there okay so that's the data sheet and the more interesting one is this which is the at command guide so here's this is for our our device we're using it uses these at commands and you'll see this a lot with cell modules and that sort of stuff it's just a it's a you are you know serial uh way to communicate with modules so you give it an a t comma the a t and then some kind of command like address and then you usually find follow it with a with a 1013 you know a new la uh r in uh so a return and a new line uh and that indicates that a command has been sent and then you'll get some data back and it'll be followed by 1013 new line or you know what is it d a x d a anyway um so that's your how it works and they give you this nice little rundown of of how to do it and then here's where they're telling you to you know always follow it with that uh here's all the commands that they have in there uh so basic at resets set in the mode where you can put in sleep mode here's your baud rates we're just using the default that's for the serial communication there's parameters for the laura transmission there's bandwidth of course we're using this bandwidth because we're in the united states uh you have to set your own there now each each device has to have an address on the local network that it's creating and then there also has to be a network id so you're creating this is a peer-to-peer setup so you're creating uh this little network of lower devices you give your network an id and then you set each module with an address and then everybody can communicate and talk back and forth to any module that that is in the same network okay we're using network 18 as the default we're using all defaults for this testing here's your power you can go up to 22 as the maximum which is twice as much as 11. these go to 11. yeah here's the send command um it's a little you gotta you know put an address where is it going to on the network you got to put a payload length and the data has to be in bytes and all that sort of stuff guess what i got software for that here's the receive thing i got software parsing that out here's the you know queries that you can make you can do a factory reset okay so that's all the stuff that you oh and then here's a bunch of error codes but i implemented that in software too so you need to look through this so you know what it does right but because it's what i do i made code for it so here's the device hold on let me get this visible for you guys right there right there okay so uh basically here here's the class for this for this module uh here's the here are the important variables what address is it uh what is the network id and then how much power are you transmitting and then these other uh oh here's the pins we're using here's uh pin 18's our reset pin that we're using on the esp32 and 16 and 17 are uart pins and these are the your pins that are actually assigned in the esp32 for the hardware uart uh there's our frequency and these are the parameters these are all defaults okay those that's the way it comes set up but when you instantiate it right here when it admits you you can give it your network id your address and your power value right there and it'll set those up so basically oh i also encoded these all these are all your errors so anyway basically when you instantiate this it's going to fix these variables for you do a hard reset of the device using the pen 18 or whatever you assign and then it sets up your port your uart port flushes the ur port asks if the device is okay over the ur and then it goes through the device setup process uh using these variables up up here or the ones that you put in when you instantiated it there now if you instantiate it and then change these variables then you need to call this just call update and it will redo the init set everything back up again all right flush this is this is all uart stuff you know the buffer and all that read line read lines this is this parses the plus rcv command it's one of the at at receive commands it parses that for you and gives you a little dictionary of all the stuff address that sent it the data length the data and these are power factors of how good the signal was uh here's your send command so instead of you having to calculate the length and convert everything to bytes and all that sort of stuff this dust does it for you all right so it just works it out for you this is a nice command sent it the device is storing the last sent data so you can use this command and get back the address the length and the data that you sent the last time and we're using that in the code you'll see for comparing wait for it is uh when you send a t command you're going to get a command back so this just helps you wait for command that starts with whatever you tell it there's a timeout and then it when it gets that command starts with that it'll give it back to you all right here's hard reset that's using the pin i i told you wrong earlier that the reset happens at low so that pin has to be pulled low right there for 100 milliseconds and that will cause the reset and then you got to pull it back high and then you can disengage it because it has a it has a pull up on it okay so that's what that is there's also a software reset so you send this reset command it's a dt command and then you wait for it to tell you that it's ready um ask if it's okay put it to sleep okay you can go into sleep mode and so that saves power so let's say you send a message you get some stuff back you're good to go you're gonna wait for a while before you send a message again and you can put it into sleep mode but you can't when you put it into sleep mode it ignores everything right so you have to wake it back up before you can get data or send data on the network and then here's the whole setup deal and then this is a nice one that you can call and it just goes through all of the commands and parameters and all that it it queries the device gets it all back for you and returns it to you in a dictionary or it'll print it out for you just so you know what's going on um anyway so that's just a little nice nice things or they're nice for me you might care less all right so let's look at main and i'll show you basically how we're running these two things so remember we have one that is a sender and it's sending a message i can't get this thing to what the heck there we go okay so we have one that's a sender it's sending a message and then we have one that is the bouncer and it's just waiting to get a message when it gets the message it sends it back all right so the last time i loaded this as main.py i was using the send option okay so if you you know if i commented this out and uncommented that out then it would be using the bounce option for for the other one okay all right so here's a class for the bouncer and then here is actually a function that you can call that sets it up for you so it just instantiates the bouncer and tells it to balance and i have the bouncer by default using address one on network 18 full power and so down here the sender i have by default the sender's on two full power on network 18. you know just for ease ease of doing it so let's look at what the balancer is doing so when you init you can give it all this other stuff but i'm just using the way i set it up as default so it's instantiating the device as self.laura and then what it's doing is just going into a loop it's reading a line using this read line function excuse me if there's not a line or if the line is you know an empty string then it's going to wait a tenth of a second and do it again okay but if the line is not then it's going to turn on the led so the led is on pen two so i'm just setting pin too high it is going to print a space print a line and then it's going to tell you what it read and if the line is a receive message that's the a t indicator a received message then it's going to parse that receive message right here so it's using the the laura class we instantiated it's parsing that it's getting a little dictionary back of all the pieces and then it just prints what it sent uh so here's the parse data so the address the data and then it's sending that data back address and data sending it right back okay so that's really all it's do oh and then it turns the here's where it turns the led off all right so when you call that on the the one esp32 the bouncers uh one it's just waiting for a message if it gets a message it prints it out and it sends it back if if it's a receive message so it sends it always sends it back to the same address that it got it from and it sends back exactly the same data okay so that's what the bouncer's doing so one of these esp32s is loaded with this bouncer software and it's set up to run see the run is down here so once it loads it runs the run and it's running bounce okay the other one is set up like this so when run runs it runs send instead of bounce so let's look at what sending is doing uh okay so same thing instantiates it um using address two is the default and then it's just looping okay so it does a loop um what it prints out um how many what loop it's on and then the first thing it does is it reads all of the messages that it's received and it prints line in what the message was and if it was a received message then it's parsing it right here parses that receive message and then it's asking what was the last message that i sent right here so it's getting that last message sent back and that that's a list and so i'll go ahead and put the receive into a list of address data length data that's going to be the same thing that comes back in this one so if these two are the same well i'm printing them right here and then i'm saying if those two are the same meaning the last message that i got matches the last message message that i sent then i'm saying matt printing match equals true and i'm turning led on for a tenth of a second right so that's just saying okay so oh okay and then the last thing that it does is it sends a new message okay so it says hello from loops or hello from loop whatever the loop count is and it prints that is sent a message so this message will get sent then it will wait for a second 100 milliseconds a second and then our thousand milliseconds no mil yeah uh milla thousand milliseconds is a second it so sends this message it waits and then it looks for what it received back and it tries to match the one that last sent with the one that it got and if it's good it blinks the light so that verifies that the message went out and that it came back and that it was the same and it's good okay and this is just the function that calls it so let's look at what this looks like so over here on this side is the bouncer so you can see it's let me scroll this up i don't know if that'll stop yeah okay so the line in so in this case a line in it received from address 2 21 bytes of data hello from loop 2085 and then it's just saying i'm sending back to address two hello for loop 2085 and it's sent true okay so that's all that it's doing it's getting a message in sending it out these other things are uh you know the strength of the signal and that sort of thing so that's the bouncer that's what it's doing and then here is the uh here's the sender so in this case so here's the loop number i got a line in it from address one uh 21 bytes of data hello from luke 21 26 so here and then this was the last thing that i sent and it matches what i received it says match okay matches and then it's sending a new one 2127 okay so that's what it looks like if you're actually hooked up to the uart of the esp32 so that's what's happening back and forth this light on this side the light is coming on while it's sending or while it's reading the line and sending and then on this side the light comes on when everything is okay okay so the only thing we got to do now is go outside somewhere and see how far these things will transmit so i've got my batteries charged to a hundred percent right now and we'll go find a place to test this out all right here i am walking down the highway risking my life to bring you good youtube content all right so back there behind me is my truck with the bouncer and right here is the sender i've got a glove over because it's raining so i'm giving the finger to everyone anyway so do you see it let me see if you can i don't know if you can see that yep it's flashing okay so it's flashing so here we are so behind me is the bouncer going this way is certain death no it's uh two miles of uh straight open road all right so let's just walk down here and i'm still getting the signal here i'll put this where you guys can see it and we'll just see how far we can go with this thing all right i've lost the signal oh nope nope it's far and few between though see if you guys can even see it let's see if i can get one i'm looking no let me put it up higher [Applause] [Laughter] nope all right so now i'm gonna walk back to the truck so i'd say we're probably 500 meters away oh wait i'm getting it again all right there it is so i'm getting it pretty strong right now so let's see how far i can go okay i'm getting close to calling it i'm getting a signal now but it's only every you know i get a few flashes solid flashes so it would be usable in a way without getting a few solid flashes then it's like right now it's not doing anything if i put it up really high no i'm not getting anything oh now i'm getting something okay i got it solid right there raising it up really high nope yep okay maybe we can go further all right i don't know if you can see that flashing but i got it up oh now it stopped anyway this is i think this is the extent of it right here so i'm going to i think i'm going to call it right here so it's getting dark anyway i don't know how far i am i i'm guessing i'm 400 meters away which is pretty good i mean that's that's past what wi-fi is going to do easily so uh let's see i'm going to get out my phone and mark my position yeah even just this much more i haven't got i'm i'm out of the signal range so i'm going to get out my phone mark my position and then we're going to call it right here all right now we're we're back to about half the distance and we're getting it pretty cons it's really consistent now when i was further out or 500 meters i would get it but i had to be in just the right place you know so there were a lot of a lot of things that might affect it road signs in the way i don't know terrain magnetism of the earth other mystical powers seem to be affecting it so um all right well this is pretty good let's go back i'm gonna look on google and get the exact distances that i went all right back at the truck i'm not sure you can see it well yeah you probably can okay so there was the that's the bouncer sitting on this tripod so it was pretty elevated up there and look at that that's a full moon we're supposed to have a lunar eclipse later tonight i think it starts about 10 o'clock all right my truck was parked about well it was just right on this corner so we'll go right there then i walked to about where this was i was hadn't gotten to the end of that rail yet so this is where i recorded on my phone so to right there so that gives us 594 meters so 600 meters so this was where i got my last signal was 600 meters away from where the truck was so all things considered that's way further than wi-fi is going to go and you were using those little tiny antennas so if you had a better you know like a high gain antenna even better now it was a bit temperamental so it was about here so maybe about 300 well halfway would be 300 meters i know i was getting good reception at the halfway point so 300 meters that's not bad for those little devices so all in all i'm pretty pleased with it i mean you would have to make sure you know you had your antennas in the right place there wasn't too many obstructions in the middle and that sort of thing but overall that's that's a lot farther than i thought it was going to go with those tiny antennas so very cool all right i'm done [Music]
Info
Channel: Clayton Darwin
Views: 6,107
Rating: undefined out of 5
Keywords: DIY, Homemade, lora, esp32, microplython, wifi, arduino, iot
Id: J0J_CSmiqwk
Channel Id: undefined
Length: 31min 25sec (1885 seconds)
Published: Mon May 16 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.