|
Forum Index : Microcontroller and PC projects : Reyax Lora Modules - data takes a while
| Author | Message | ||||
| viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
Picked up a couple of the Reyax Lora modules that work on 915Mhz for a project that would ideally get me 1.5 miles of distance between two warehouses at work. Set them up on two different breadboards with micromites controlling them. They conveniently work on 3.3v and use a simple AT command set. At full transmit power they use 43ma. After a bit of playing, I got them to play Ping Pong with each other and was able to use Geoffs brilliant RX serial interrupt on character function. (WORKS GREAT, Thanks!) They seem to take a bit of time to communicate with each other which I find strange, but this is probably how they work to get the crazy distances??? I have one unit (base) that sends out "HELLO" and when the other unit (remote) receives that successfully, it sends back "ACK". If the base unit receives that successfully it starts the process over again. If the base doesn't receive the ACK within 3 seconds, it tries again. Without using any delays, the complete round trip takes about 1800 ms. I have only done a quick walk around the neighborhood with the remote unit on a usb battery bank and am TOTALLY amazed at how far these go. This is not line if site, but through houses, trees, etc. Once I get a bit of time, I will add a gps unit on the remote and do some real distance testing, but so far so good. I have not gotten a great handle on these yet, but for sending packets of data to control things or receiving data from remote sensors, this might be a great way to do this. ![]() Here is the simple code for ping pong between the units. If anyone has a suggestion on better ways to do this, I would be very receptive. BASE UNIT - Address 0 CPU 48 Option AUTORUN ON SetPin 2, DOUT 'Trans Led - Red Setpin 4, Dout 'Recv Led - Green Open "COM1:115200, 256, HearLora, =13" As #1 'Interrupt when CR on serial RX TransLED = 2 'Transmit Indicator LED RecvLED = 4 'Receive Indicator LED Pin(TransLED) = 0 Pin(RecvLED) = 1 '******** Show I'm Alive - Flash LEDS ************* For Xx = 1 to 10 Pin(TransLED) = Not Pin(TransLED) Pin(RecvLEd) = Not Pin(RecvLED) pause 80 Next Xx Pin(RecvLED) = 0 Pause 1000 'Just because '********** Clear Buffer & Set Address of LORA ********** Print "Initializing" ClearBuffer Print #1, "AT+ADDRESS=0" 'Set first unit to address 0 Pause 200 LoraRec = 0 NumOfTrans = 0 ACKfails = 0 Do NumOfTrans = NumOfTrans + 1 'Count number of transmissions print #1, "AT+SEND=1,5,HELLO" 'Send HELLO to unit 1 Pulse TransLED, 50 'Show data sent Tt = Timer 'Set timer var Do If LoraRec = 1 then 'Data Received If Instr(Reply$,"ACK") <> 0 then 'If ACK received Pulse RecvLED, 50 'Show data received LoraRec = 0 'Reset data received flag Exit Do 'Get out and do it again End If LoraRec = 0 'Reset data received flag End If If Timer - Tt > 3000 then 'If no ACK back within 3 seconds add fail ACKfails = ACKfails + 1 Exit Do End If Loop Print "Time for cycle =";Timer - Tt Print "Number of Transmissions =";NumOfTrans Print "Number of ACK Failures =";ACKfails Print "" Loop '********** Received data Sub ********** SUB HearLora Reply$ = Input$(Loc(#1), #1) LoraRec = 1 End Sub '********** Received data Sub ********** SUB ClearBuffer Pause 200 Do : Loop Until Input$(255, #1) = "" PRINT "Buffer Cleared" End Sub REMOTE UNIT - Address 1 CPU 48 Option AUTORUN ON SetPin 2, DOUT 'Trans Led - Red Setpin 4, Dout 'Recv Led - Green Open "COM1:115200, 256, HearLora, =13" As #1 'Interrupt when CR on serial RX TransLED = 2 RecvLED = 4 Pin(TransLED) = 0 Pin(RecvLED) = 1 '******** Show I'm Alive - Flash LEDS ************* For Xx = 1 to 10 Pin(TransLED) = Not Pin(TransLED) Pin(RecvLEd) = Not Pin(RecvLED) Pause 80 Next Xx Pin(RecvLED) = 0 Pause 1000 'Just because '********** Clear Buffer & Set Address of LORA ********** Print "Initializing" ClearBuffer Print #1, "AT+ADDRESS=1" 'Set second unit to address 1 Pause 200 'Takes about 180ms for reply LoraRec = 0 '********** Main Loop ********** Do If LoraRec = 1 then 'Data Received If Instr(Reply$, "HELLO") <> 0 Then 'If HELLO received Pulse RecvLED, 50 'Show data received LoraRec = 0 'Reset data received flag print #1, "AT+SEND=0,3,ACK" 'Send ACK back to unit 0 Pulse TransLED, 50 'Show data sent back End If LoraRec = 0 'Reset data received flag End If Loop '********** Received data Sub ********** SUB HearLora Reply$ = Input$(Loc(#1), #1) LoraRec = 1 End Sub '********** Clear Serial Rx Buffer Sub ********** SUB ClearBuffer Pause 200 Do : Loop Until Input$(255, #1) = "" PRINT "Buffer Cleared" End Sub I hope everyone has a great holiday season, and a big thanks to Geoff and Matherp and ALL the members of TBS that keep me off the streets with all the micromite goodies that consume my time. |
||||
| srnet Senior Member Joined: 08/08/2014 Location: United KingdomPosts: 164 |
LoRa devices have a range of settings, bandwidth, spreading factor and coding rate. All of these settings affect the data rate and in essense the slower tha data rate the longer the range. The datasheet for the Reyax tells you how to change the LoRa settings, it maybe even says what the defaults are. $50SAT is Silent but probably still working. For information on LoRa visit http://www.loratracker.uk/ |
||||
| viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
@srnet, I found the AT commands manual HERE and will play around with the settings, especially the AT+PARAMETER setting where you can change the settings you mention. This unit uses the SX1276 which is an spi device. Have you ever been able to control this directly with the micromite? Those modules are a lot cheaper without having an extra mcu to convert to uart, but that mcu does make it a bit easier to deal with. Also have you ever used the E32 type modules? These are available in 1w version and that should allow for some crazy distances. |
||||
| srnet Senior Member Joined: 08/08/2014 Location: United KingdomPosts: 164 |
Yes I wrote some basic Micromite routines for the SPI LoRa devices back in early 2015, but there was little interest in LoRa then, people seemed happy with the much lower distances the HC12 and similar modules are capabable off. Maybe the distances reported at the time were not believable as even Semtech were (very) surprised. The E32 modules (1W) are illegal to use license excempt in most places in the world, so I have no interest in using them. They are used in some illegal to use long distance RC stuff. Read about the first of the LoRa long distance testing here; Here Of course since then LoRa has indeed taken off and now in very wide worldwide use for Internet of Things applications, justifiably so. $50SAT is Silent but probably still working. For information on LoRa visit http://www.loratracker.uk/ |
||||
| viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
Wow, that is a very interesting read! Makes me want to do some serious range testing. I ordered a few different antennas to try including a couple of the magnetic mount units and rubber ducks of varying sizes. They all claim to be for use on 915Mhz. I don't have any RF test equimpment, or any practical experience for that matter, but a fun way to start learning, and bonus being able to use the MM to do these things. The low data rate is very acceptable to me in trade for distance. Sending data from sensors or switching things remotely in my case won't require super fast response. I will have to check the web to see what the legalities are around my part of the planet. I don't need the FCC knocking on my door any time soon. I searched to forum and could not find any code examples for the lora units using SPI. Could you point me in the right direction? I did find the arduino radiohead library, but makes my head spin a bit. Even the E32 units seem to use uart, which isn't a bad thing, but the SX1276 is much more affordable on its own. The combination of Matherps STM32L4 and an SX1276 could make a very nice battery powered device also. |
||||
| srnet Senior Member Joined: 08/08/2014 Location: United KingdomPosts: 164 |
The RadioHead is typical of a lot of Arduino libraries, not the easiest to understand. This Arduino LoRa library is a lot easier to understand in my opinion; https://github.com/sandeepmistry/arduino-LoRa There is some Micromite code here; https://goo.gl/t4UkoN Although its not been updated in a while, there is more up to date stuff reports and code for Arduino to be found here; https://github.com/LoRaTracker $50SAT is Silent but probably still working. For information on LoRa visit http://www.loratracker.uk/ |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |