ESP32 and LoRa

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

Re: ESP32 and LoRa

Post by Capstan » Mon Jan 22, 2018 9:03 pm

LoRaWAN is interesting to me. The Things Network appears to be all Arduino-oriented, but probably their implementation could be ported over to run on the ESP32 if someone were sufficiently motivated. I get the impression they envision LoRa gateways sited in many places in urban areas that could be reached by leaf nodes so they could communicate with each other.

I think you would need the gateways to be high up on a tall building, a tower, or up on a hillside if they are going to be effective, not much different from cellphone towers. In my experience with LoRa the range is not huge between points at ground level unless they have line-of-sight, and this will frequently not be the case. Without such gateways I'm not sure LoRaWAN is worth the trouble, and they seem to be pretty rare in the USA.

That being said, I received a couple of cheap standalone LoRa modules from China yesterday and wired up power and SPI to one of them today using a generic ESP32 development board. Was able to send/receive data between it and a TTGO board (heltec) using the same Python driver software. Encouraging! No LoRaWAN required.
Last edited by Capstan on Tue Jan 23, 2018 3:22 pm, edited 1 time in total.

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

Re: ESP32 and LoRa

Post by LoRaTracker » Tue Jan 23, 2018 8:14 am

Capstan wrote:
Mon Jan 22, 2018 9:03 pm
Without such gateways I'm not sure LoRaWAN is worth the trouble, and they seem to be pretty rare in the USA.
The US does not seem keen on the technology, but its clearly an effective technology if the number of Gateways in more enlightened parts of the World is an indication, see the map;

https://www.thethingsnetwork.org/map

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

Re: ESP32 and LoRa

Post by Capstan » Tue Jan 23, 2018 4:47 pm

It looks like someone implemented or imported a driver for the sx1276 LoRa module in a fork of PyCom's Micropython? All written in C of course.

https://github.com/aizukanne/ESP32-micr ... esp32/lora

Also I am seeing what looks like some LoRaWAN-related code in the PyCom repository;
https://github.com/pycom/pycom-librarie ... no-gateway

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

Re: ESP32 and LoRa

Post by LoRaTracker » Tue Jan 23, 2018 8:19 pm

Well its MicroPython where my interest really lies, so whilst its been handy to test these ESP32\LoRa things with my own Arduino LoRa code, I see the future as MicroPython.

I think the Pyboard is a better development environment than the ESP32, but with shift of Pyboard from pyb to machine I\O then you ought to be able to develop on the Pyboard and run the same MicroPython code on the ESP32.

I am at The Things Network conference next week in Amsterdam, so there will be lots of people around to ask these sort of questions.

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

Re: ESP32 and LoRa

Post by Capstan » Tue Jan 23, 2018 9:36 pm

LoRaTracker wrote:
Tue Jan 23, 2018 8:19 pm
I am at The Things Network conference next week in Amsterdam, so there will be lots of people around to ask these sort of questions.
Would love to attend that, please tell us about any highlights. I signed up on the TTN site earlier today and spent some time looking through their forum. They discuss Arduino implementations of LoRaWAN with the ESP32. TTN recently started shipping a gateway hardware device; http://www.newark.com/the-things-networ ... p/05AC1807. Seems expensive relative to now-available LoRa hardware nodes that cost under USD $20.

PyCom LoRa is implemented using the socket API, it is just another socket type. This makes sense if the LoRa hardware is integrated such as in the products they sell and therefore set in stone, but not sure how it would work when you need to be able to specify the set of specific pins you want to use for SPI, DIO, reset, etc for some ad hoc external transceiver module.

The one I hooked up recently required 8 wires (the antenna is a $2 sticker). For modules with all the DIO signals exposed it would be several more wires. The all-Python driver I am using allows for all of the pin numbers to be specified as desired.

Image

User avatar
philwilkinson40
Posts: 63
Joined: Tue Nov 14, 2017 3:11 am
Location: Perth, Australia

Re: ESP32 and LoRa

Post by philwilkinson40 » Wed Jan 24, 2018 2:47 am

Capstan wrote:
Tue Jan 23, 2018 4:47 pm
It looks like someone implemented or imported a driver for the sx1276 LoRa module in a fork of PyCom's Micropython? All written in C of course.

https://github.com/aizukanne/ESP32-micr ... esp32/lora

Also I am seeing what looks like some LoRaWAN-related code in the PyCom repository;
https://github.com/pycom/pycom-librarie ... no-gateway
I have a LoPy from PYCOM and it runs really well as a node, allowing me to code in Micropython to interface with sensors, then publish to TTN. The flexibility that Micropython offers me is light years ahead of fumbling around with Arduino code.
However, I have no idea if it is possible to use their fork on other ESP32 boards (or even how to start doing that, given the very large number of files in their GitHub repo!). Has anyone been successful in doing that?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 and LoRa

Post by Roberthh » Wed Jan 24, 2018 2:14 pm

You can run the code for Pycom's WiPy on any ESP32 board with a Rev 0 chip. It will also run on Rev 1 chip boards with external psRAM like the Wemos Lolin32 Pro. The Pycom software assumes, that all Rev 1 boards have that additional RAM. I hacked a version which also runs on Boards with a ESP32 Rev 1. To be found here: https://github.com/robert-hh/Shared-Stuff
It simply lets the firmware believe that it runs on a Rev 0 device. The Pycom firmware uses that information only for RAM setup. I have no idea what the espressif RTOS doing with it, or whether it's using that interface too.
The LoPy firmware may run, if you use the same Lora controller and connect it the same way, using GPIO 5(CLK), 27 (MOSI) and 19 (MISO).
But anyhow, even on short run you have less pain if you use the orginal devices, unless you're out for the learning experience.

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

Re: ESP32 and LoRa

Post by Capstan » Wed Jan 24, 2018 9:52 pm

It would be very nice if generic ESP32 devices running Loboris firmware or the 'official' build could have an all-Python implementation of LoRaWAN coupled with a Python sx127x driver, and be able to communicate with The Things Network through one of their gateways. Or even be able to serve as a TTN gateway for that matter. Were that to happen, and with ESP32 LoRa hardware nodes now costing USD $10-$12, I think it would be a lot easier to imagine a proliferation of TTN similar to what was originally envisioned. The PyCom "LoPy" device is great but it costs x3 that amount, plus an expansion board if you want to connect to it with USB.

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

Re: ESP32 and LoRa

Post by Capstan » Wed Jan 24, 2018 11:36 pm

A friend came over today with a software-defined radio device (SDR). It is a USB dongle that plugs in to your laptop, includes some antennas;
https://www.amazon.com/gp/product/B01GD ... 7YP9I9Y3D6

Software for it is free, and I was impressed with what it could do. You could see large swaths of the radio spectrum, and listen to radio broadcasts having a variety of modulation types. He demonstrated that we could see the radio emissions from the keyfobs for our cars when we pressed the lock buttons, ha.

Most pertinent to this thread, it was able to show LoRa signals from the devices I have been working with. We could clearly see the amplitude, bandwidth, and duration of the transmissions from two devices that were performing a ping-pong. One of the devices had a somewhat higher amplitude than the other, not sure if it was due to different antenna or just a stronger transmitter.

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

Re: ESP32 and LoRa

Post by LoRaTracker » Sat Jan 27, 2018 11:59 am

Capstan wrote:
Wed Jan 24, 2018 9:52 pm
It would be very nice if generic ESP32 devices running Loboris firmware or the 'official' build could have an all-Python implementation of LoRaWAN coupled with a Python sx127x driver, and be able to communicate with The Things Network through one of their gateways. Or even be able to serve as a TTN gateway for that matter.
Well volunteered !

Be sure to make the code open sourced.

Not sure why you would want to build it into the firmware though, surely if it was in a separate library, it could be used on any MicroPython setup that used the machine I\O and had a LoRa device attached ?

Post Reply