ESP32 and LoRa

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

Re: ESP32 and LoRa

Post by LoRaTracker » Fri Jan 12, 2018 3:34 pm

Capstan wrote:
Fri Jan 12, 2018 6:10 am
I'll try both dipoles shortly, but I am thinking that while line-of-sight distances might be as reported, the typical suburban range won't be but a few hundred meters at best. And that would be with at least one antenna up high in the attic.
It all depends on the LoRa setting you are using.

I was doing some testing just yesterday and the situation was similar to above, a 5dB receiver antenna at about 5M above ground, the transmitter 1km away (urban area) had a 1/4 wire at shoulder height.

I was covering that 1km with -15.5dBm power, thats about 28uW.

So if I had been using the full 10dBm I am allowed in the UK, you could expect it to go 20 times further ...............................

In general LoRa will reach 10 times further than most FSK systems and 30 times further than some.

LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

Re: ESP32 and LoRa

Post by LoRaTracker » Fri Jan 12, 2018 3:40 pm

on4aa wrote:
Wed Jan 10, 2018 11:17 am
Here is a nice project employing the Microchip RN2483 on the Micro:Bit using MicroPython.
You might be interested in this;

http://www.loratracker.uk/?p=589

The RTC board operates as a shutdown timer, in sleep mode the battery current is less than 0.001uA !

I have just been testing my own RN2484 Mikrobus board to plug into that shield, it appears to be working.

I have been thinking of doing a similar shield board for ESP32, but I have a few concerns as the amount of EMI these boards put out versus the humble ATmega, the EMI can reduce LoRa sensitivity.

Capstan
Posts: 99
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 and LoRa

Post by Capstan » Fri Jan 12, 2018 4:53 pm

LoRaTracker wrote:
Fri Jan 12, 2018 3:34 pm

It all depends on the LoRa setting you are using.

I was doing some testing just yesterday and the situation was similar to above, a 5dB receiver antenna at about 5M above ground, the transmitter 1km away (urban area) had a 1/4 wire at shoulder height.
What 'setting' are you referring to? In the driver I am using it looks like the TX power level is 2, I think this is the max. The spreading factor is 8.

Are you testing with unobstructed line-of-sight? I'm getting some pretty significant RSSI variations just walking around the block near my house with a 1/4 wire transmitting antenna at shoulder height and a short helical coil receiving antenna.

LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

Re: ESP32 and LoRa

Post by LoRaTracker » Fri Jan 12, 2018 5:10 pm

Capstan wrote:
Fri Jan 12, 2018 4:53 pm
What 'setting' are you referring to? In the driver I am using it looks like the TX power level is 2, I think this is the max. The spreading factor is 8.

Are you testing with unobstructed line-of-sight? I'm getting some pretty significant RSSI variations just walking around the block near my house with a 1/4 wire transmitting antenna at shoulder height and a short helical coil receiving antenna.
In the case I just mentioned, SF12, BW125000, CR 45, across a typical urban area, definitely not line of sight.

I did also test at SF7, that needed more power to cover the 1km distance as you would expect, about 1mW as I recall.

The SF7 data rate was 5500bps, SF12 data 300bps.

Full write up is here;

http://www.loratracker.uk/?p=591

I was actually measuring for the effect of LNAs and filters on LoRa, mainly for long distance stuff, balloons and satellites etc.

Capstan
Posts: 99
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 and LoRa

Post by Capstan » Fri Jan 12, 2018 6:03 pm

You seem to be getting much better results than I am. Here are the default settings in the SX127x driver code I have. I guess the 'signal_bandwidth' value corresponds to your 'BW' value? If so, 125E3 hex is 75235 decimal, far less than your 125000. Also the 'coding_rate' of 5 (may be your 'CR'?) is much less than 45.

Code: Select all

{'frequency': 433E6, 'tx_power_level': 2, 'signal_bandwidth': 125E3, 
             'spreading_factor': 8, 'coding_rate': 5, 'preamble_length': 8, 
              'implicitHeader': False, 'sync_word': 0x12, 'enable_CRC': False}
I'll see what happens when I use your values. Also on your blog I noticed that you mention "I have one of the ESP32 modules with built in LoRa and OLED display on order and will be checking its performance versus a standard ATMega set-up". Presumably you will be getting a device very similar to what I have, so it will be interesting to compare results. The code I am using is derived from this github repository; https://github.com/Wei1234c/SX127x_driv ... on_ESP8266

LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

Re: ESP32 and LoRa

Post by LoRaTracker » Fri Jan 12, 2018 6:23 pm

Capstan wrote:
Fri Jan 12, 2018 6:03 pm
You seem to be getting much better results than I am. Here are the default settings in the SX127x driver code I have. I guess the 'signal_bandwidth' value corresponds to your 'BW' value? If so, 125E3 hex is 75235 decimal, far less than your 125000. Also the 'coding_rate' of 5 (may be your 'CR'?) is much less than 45.

Code: Select all

{'frequency': 433E6, 'tx_power_level': 2, 'signal_bandwidth': 125E3, 
             'spreading_factor': 8, 'coding_rate': 5, 'preamble_length': 8, 
              'implicitHeader': False, 'sync_word': 0x12, 'enable_CRC': False}
I'll see what happens when I use your values. Also on your blog I noticed that you mention "I have one of the ESP32 modules with built in LoRa and OLED display on order and will be checking its performance versus a standard ATMega set-up". Presumably you will be getting a device very similar to what I have, so it will be interesting to compare results. The code I am using is derived from this github repository; https://github.com/Wei1234c/SX127x_driv ... on_ESP8266
The bandwidths are not set as numbers, I just use symbols so its easier to understand the code, BW125000 is actually number 112, which is the value you write to the lora modem registers to set the bandwidth to 125khz.

CR45, is my shorthand for a coding rate of 4:5.

SF12 is shorthand for spreading factor 12.

You can only use specific bandwidths, coding rates and spreading factors.

The numbers I use apply to my own code only they may not make sense to whatever code library you are using. I wrote my own LoRa libraries (for PICAXE, Micromite and Arduino) back in early 2015, there were no suitable code libraries available then.

I have the Heltec Wifi LoRa OLED working under Arduino, and an initial look suggests it does not perform so well as an ATMega, but I need to test the Heltec as a handheld receiver in a large field to be sure the results I am getting are accurate. I spend a lot of time 'testing' in large open fields.

LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

Re: ESP32 and LoRa

Post by LoRaTracker » Fri Jan 12, 2018 6:30 pm

Capstan wrote:
Fri Jan 12, 2018 6:03 pm
The code I am using is derived from this github repository; https://github.com/Wei1234c/SX127x_driv ... on_ESP8266
I have a suspicion that MicroPython library was created form an existing Arduino library. I dont see the LoRa device being setup correctly for high spreading factors. I have raised an issue against the original Arduino library (its not mine!) and will see what happens.

Capstan
Posts: 99
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 and LoRa

Post by Capstan » Fri Jan 12, 2018 7:33 pm

Would not surprise me if the Python sx127x driver was derived from an Arduino version.

Looking at the python driver it appears that the 'signal_bandwidth' parameter (shown here as sbw) is used to get an index into a list of values, and then that index is shifted left and written to a register. A strange way to do things. 125E3 would give an index of 7, and shifted left by 4 gives 112 which matches your value. The 'CR' (coding rate) value of 5 in this driver winds up being written to a register as a 2. So maybe the only thing I really could experiment with to match your values is the spreading factor.

Code: Select all

    def setSignalBandwidth(self, sbw):        
        bins = (7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3, 41.7E3, 62.5E3, 125E3, 250E3)
        
        bw = 9        
        for i in range(len(bins)):
            if sbw <= bins[i]:
                bw = i
                break
        
        self.writeRegister(REG_MODEM_CONFIG_1, (self.readRegister(REG_MODEM_CONFIG_1) & 0x0f) | (bw << 4))

User avatar
on4aa
Posts: 70
Joined: Sat Nov 11, 2017 8:41 pm
Location: Europe
Contact:

Re: ESP32 and LoRa

Post by on4aa » Fri Jan 12, 2018 9:16 pm

LoRaTracker wrote:
Fri Jan 12, 2018 3:40 pm
I have been thinking of doing a similar shield board for ESP32, but I have a few concerns as the amount of EMI these boards put out versus the humble ATmega, the EMI can reduce LoRa sensitivity.
That is probably why the LoPy has two separate shields.

Perhaps the really cheap RAK811 module would be a worthy alternative. It contains apart from the SX1276, also an STM32L151. The latter contains LoRa(WAN) firmware but, contrary to a Microchip RN2483, also allows for internal programming.

The restricted memory size only allows for Arduino code and the like.

Image
Last edited by on4aa on Fri Jan 12, 2018 10:21 pm, edited 2 times in total.
Serge

LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

Re: ESP32 and LoRa

Post by LoRaTracker » Fri Jan 12, 2018 9:24 pm

on4aa wrote:
Fri Jan 12, 2018 9:16 pm
the really cheap RAK811 module would be a worthy alternative. It contains apart from the SX1276, also an STM32L151. The latter contains LoRa(WAN) firmware but, contrary to a Microchip RN2483, also allows for internal programming.

Currently I have seen only Arduino code, but it would be a nice compilation target for standard MicroPython with LoRa(WAN) support. Let us hope someone would like to take this up this compilation challenge.
But they have less flash and the same RAM as the micro:bit ?

Post Reply