ESP32 and LoRa

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Capstan
Posts: 104
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 and LoRa

Post by Capstan » Fri Jan 12, 2018 9:25 pm

Experimenting with 1/4 wavelength dipoles on both sending and receiving ends gets about one extra block of range for me, disappointing. Things work pretty well until the RSSI drops past -120db.

I tried changing the spreading factor to 12 and it is even worse, the range is less than a block and reception quits at about -90db. Also the transmission data rate at SF12 seems to be very slow indeed, though I don't yet have a way to measure it directly.

Maybe the driver isn't setting these transceivers up properly, or it could be that they are just not very good. I have a couple of other standalone LoRa modules on order and they have a SPI interface. They should arrive next week, I should be able to use the same driver code, will see how they compare.

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 10:23 pm

LoRaTracker wrote:
Fri Jan 12, 2018 9:24 pm
But they have less flash and the same RAM as the micro:bit ?
Oops, I also noticed after posting. I made an edit. Thanks.
Serge

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

Re: ESP32 and LoRa

Post by LoRaTracker » Sat Jan 13, 2018 8:15 am

Experimenting with 1/4 wavelength dipoles on both sending and receiving ends gets about one extra block of range for me, disappointing.
1/4 wave dipoles are difficult to match correctly, 1/2 wave dipoles are what you would normally use.

Whats a block, 10m, 100m, 1Km ?
Maybe the driver isn't setting these transceivers up properly
Quite possible, I have seen a few LoRa libraries that do not setup the device correctly for high spreading factors, maybe these libraries are not tested fully.
Also the transmission data rate at SF12 seems to be very slow indeed, though I don't yet have a way to measure it directly.
No need to measure it, Semtech have a tool called the 'LoRa Calculator' which will do it for you.

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

Re: ESP32 and LoRa

Post by Capstan » Sat Jan 13, 2018 5:10 pm

I can try 1/2 wavelength, but I am skeptical that it will make a lot of difference. A discussion of LoRa antenna length is here; https://www.thethingsnetwork.org/forum/ ... 3-mhz/5378

The uppermost mostly unobstructed range I am getting is about 700 feet or 215 meters (from interior of my suburban house to an exterior line-of-sight spot). With some intervening houses this drops to about 500 feet.

My existing test case is a series of 'ping' packets of about 200 total bytes being sent from a 'transmitting' unit at 5 second intervals. The packet contains a sequence number and a timestamp. A 'receiving' unit retransmits the ping as a 'pong' which the transmitter looks for. RSSI and dropped packet count are printed to the OLED display on each unit, elapsed time as well on the transmit unit.

With SF8 the round trip time is about 1.8 seconds - woefully slow. With SF12 the transmit time alone is apparently longer than 5 seconds.

I am working up some code that will break up a large block of data into a series of packets that are less than the max transmission size (appears to be 255 bytes), hoping to more directly evaluate the point-to-point data rate in one direction.

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

Re: ESP32 and LoRa

Post by LoRaTracker » Sat Jan 13, 2018 6:15 pm

Capstan wrote:
Sat Jan 13, 2018 5:10 pm
I can try 1/2 wavelength, but I am skeptical that it will make a lot of difference. A discussion of LoRa antenna length is here; https://www.thethingsnetwork.org/forum/ ... 3-mhz/5378
Unfortunately there are quite a few comments in that thread that are misleading at best.

LoRa is a radio device, there is nothing special about antennas for LoRa.

A 1/4 wave dipole is a bad antenna, 1/2 wave dipole is good.
With SF8 the round trip time is about 1.8 seconds - woefully slow. With SF12 the transmit time alone is apparently longer than 5 seconds.
LoRa is capable of between 37500bps and 18bps at the extremes, slower data rates give longer range. At the fastest rate a 256byte packet will take 57mS, at the slowest rate 120secs. You get to choose the best balance for your application.

Round trip time is more than likely governed by software issues and not a problem with the LoRa device.

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

Re: ESP32 and LoRa

Post by LoRaTracker » Sat Jan 13, 2018 6:16 pm

Capstan wrote:
Sat Jan 13, 2018 5:10 pm
I can try 1/2 wavelength, but I am skeptical that it will make a lot of difference. A discussion of LoRa antenna length is here; https://www.thethingsnetwork.org/forum/ ... 3-mhz/5378
Unfortunately there are quite a few comments in that thread that are misleading at best.

LoRa is a radio device and there is nothing special about antennas for LoRa.

A 1/4 wave dipole is a bad antenna, 1/2 wave dipole is good.
With SF8 the round trip time is about 1.8 seconds - woefully slow. With SF12 the transmit time alone is apparently longer than 5 seconds.
LoRa is capable of between 37500bps and 18bps at the extremes, slower data rates give longer range. At the fastest rate a 256byte packet will take 57mS, at the slowest rate 120secs. You get to choose the best balance for your application.

Round trip time is more than likely governed by software issues and not a problem with the LoRa device.

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

Re: ESP32 and LoRa

Post by Capstan » Sat Jan 13, 2018 7:28 pm

LoRaTracker wrote:
Sat Jan 13, 2018 6:16 pm

LoRa is a radio device and there is nothing special about antennas for LoRa.

A 1/4 wave dipole is a bad antenna, 1/2 wave dipole is good.
I was mostly interested in the discussion of recommended antenna length for LoRa frequencies. Shorter is better from a practicality standpoint, and this is particularly the case with small IoT devices. If you have to attach a 13" dipole antenna to a 1x2" device the entire package becomes more fragile, unwieldy, and conspicuous. Now, it may be that only one gateway node requires the large antenna, and nodes out on the periphery can get by with a small coil stub out to some worthwhile distance.
LoRaTracker wrote:
Sat Jan 13, 2018 6:16 pm
LoRa is capable of between 37500bps and 18bps at the extremes, slower data rates give longer range. At the fastest rate a 256byte packet will take 57mS, at the slowest rate 120secs. You get to choose the best balance for your application.
So far that's not what I am seeing in practice for whatever reason. WiFi data rates with the ESP32 seem pretty respectable, but admittedly the driver software for the WiFi component is probably compiled down to native machine code and closely coupled rather than being interpreted Python and going over SPI as with this particular LoRa implementation. At any rate, what matters to me is how LoRa behaves as embodied in tiny, very cheap devices. It could be that there is a significant performance hit.

User avatar
Wei Lin
Posts: 10
Joined: Sat Jan 21, 2017 1:07 pm

Re: ESP32 and LoRa

Post by Wei Lin » Sun Jan 14, 2018 2:10 am

You may also be interested in:

viewtopic.php?f=18&t=3906

It's my way to balance range and data rate, not following LoRaWAN though.

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

Re: ESP32 and LoRa

Post by LoRaTracker » Sun Jan 14, 2018 10:05 am

In the US you should be using 915Mhz for ISM band stuff, so antennas are shorter than the are for 434mhz. You might just try coiling a simple wire up inside the case.

WiFi does offer far higher data rates than LoRa can offer, but you wont get the range of LoRa even if your small 'device' could supply the high battery power required.

If 10mW was enough to cover 1km at UHF ISM band frequencies, then (assuming equal receivers and antennas) the 2.4Ghz device would need 160mW for the same distance and a consequent large increase in battery power.

User avatar
pythoncoder
Posts: 3060
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: ESP32 and LoRa

Post by pythoncoder » Sun Jan 14, 2018 12:21 pm

Capstan wrote:
Sat Jan 13, 2018 7:28 pm
I was mostly interested in the discussion of recommended antenna length for LoRa frequencies. Shorter is better from a practicality standpoint, and this is particularly the case with small IoT devices. If you have to attach a 13" dipole antenna to a 1x2" device the entire package becomes more fragile, unwieldy, and conspicuous. Now, it may be that only one gateway node requires the large antenna, and nodes out on the periphery can get by with a small coil stub out to some worthwhile distance.
Antenna design is a specialist subject and the rules are (for practical purposes) independent of the modulation scheme. For an efficient transfer of RF power to the antenna, the latter needs to be impedance matched to the transmitter. In the case of a half-wave dipole the impedance is a good match to that of the cable and the transmitter output (~75Ω). As you reduce the length the impedance increases and power gets reflected back to the transmitter rather than being radiated.

It is possible to impedance match a short antenna to a transmitter using a carefully designed electrical network but you need to understand the theory and it won't work as effectively as an antenna which is inherently matched. A better approach to making short, impedance matched antennas is to coil them or have inductors interposed along their length. In practice unless you want to make a serious study of antenna design I'd stick with commercial solutions.

The loss in the link depends equally on the effectiveness of the antenna at each end. You can calculate a "link budget" which is the sum of the losses at each point in the link (including the inverse square law loss caused by distance). If the sum of the losses (in dB) exceeds the difference between transmitter output and receiver sensitivity then the link will fail.

This broad summary holds for all radio links. That said I find the ranges being quoted here disappointing. I used to achieve a range of 300ft or so with FM and AM devices in the 433MHz ISM band using 1/4 wave "length of wire" monopoles. LoRa is supposed to provide a 20dB link budget improvement. This should increase the range by a factor of ten. Theoretically. I'd expect much better than 500ft with half-wave dipole antennas at each end.
Peter Hinch

Post Reply