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 » Thu Feb 08, 2018 5:21 am

LoRaTracker wrote:
Sat Jan 27, 2018 11:59 am

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 ?
Ha, I could probably do it. I would get a couple of the Pycom LoPy boards to use as reference devices I suppose, and spend the time to gather up sources and testcases, and port to generic Micropython as required. Definitely would implement it as a Python library that could be incorporated into frozen firmware or as code imported from the filesystem, open source if possible.

But it would take a few dedicated weeks of effort I think, and no clear reason to do it. Personally I am not sold on the LoRaWan model, which seems to picture far-reaching gateway-to-the-internet devices that a great many subordinate devices talk through at very constrained intervals and with tiny data payloads.

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

Re: ESP32 and LoRa

Post by philwilkinson40 » Sat Mar 03, 2018 6:21 am

Roberthh wrote:
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.
Hi Roberthh, i finally managed to find time with some ESP32s to try and load up your repo. However I get this error on initial boot following flashing the firmware. I have tried this on a couple of cheap end ESP32s; Heltec and Lolin both running Rev1 chips. Do you have any idea what may need adjusting?

Code: Select all

Can't autodetect firmware, because proper answer not received (may be unknown firmware). 
Please, reset module or continue.
57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3f400020,len:188048
ets Jun  8 2016 00:22:57

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

Re: ESP32 and LoRa

Post by Roberthh » Sat Mar 03, 2018 7:41 am

To be honest, I did not try to load that on an empty ESP32. What might be missing is the bootloader. So one trial would be to flash the device first with the standard WiPy firmware, which installs the partitions, the bootloader and a non-working wipy.bin, and than install the modified images on top of that. The original flashing command is:
<your_path_to_esptool.py>/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 build/ESP32/release/bootloader/bootloader.bin 0x8000 build/ESP32/release/lib/partitions.bin 0x10000 build/ESP32/release/wipy.bin
So the binary of the application is to be loaded at address 0x10000, the command then looks like:
<your_path_to_esptool.py>/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x10000 wipy_pycom_1.15.0.b1.bin

Again: This is not comfortable. It is easier either to use a rev1 device with PSRAM, or a rev0 device w/o PSRAM, or use a genuine pycom device. Then you can use the pycom firmware as it is.

r.groesbeek
Posts: 1
Joined: Tue Jul 03, 2018 12:36 pm

Re: ESP32 and LoRa

Post by r.groesbeek » Tue Jul 03, 2018 1:50 pm

[quote=Roberthh post_id=25921 time=1520062877 user_id=601]
To be honest, I did not try to load that on an empty ESP32. What might be missing is the bootloader. So one trial would be to flash the device first with the standard WiPy firmware, which installs the partitions, the bootloader and a non-working wipy.bin, and than install the modified images on top of that. The original flashing command is:
<your_path_to_esptool.py>/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 build/ESP32/release/bootloader/bootloader.bin 0x8000 build/ESP32/release/lib/partitions.bin 0x10000 build/ESP32/release/wipy.bin
So the binary of the application is to be loaded at address 0x10000, the command then looks like:
<your_path_to_esptool.py>/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x10000 wipy_pycom_1.15.0.b1.bin

Again: This is not comfortable. It is easier either to use a rev1 device with PSRAM, or a rev0 device w/o PSRAM, or use a genuine pycom device. Then you can use the pycom firmware as it is.
[/quote]

Hi Robert,

The above procedure works perfectly for WiPy images burned to a TTGO-LORA32-V2.0.
But shouldn't we build a LoPy image then, with this hack as well?
First check if the LoPy lora is compatible with the TTGO Lora?
Then built the same hack into the LoPy firmware?

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

Re: ESP32 and LoRa

Post by Roberthh » Tue Jul 03, 2018 8:09 pm

Building the image is one thing, but for the image to work also the GPIO pins must match which are used to connect the SX127x chip. But the do not. Sop you have to adapt the LoPy sources to the other connections. CLK, MOSI and MISO see to match, but CS, Reset and Lora Interrupt do not. The LoPy sources are well organized. So the re should be a header file defining these (like <your path to the repository>/pycom-micropython-sigfox/esp32/lora/board.h). But the question is, whether it's worth the effort.

Lennyz1988
Posts: 2
Joined: Thu Aug 02, 2018 6:22 am

Re: ESP32 and LoRa

Post by Lennyz1988 » Thu Aug 02, 2018 6:25 am

[quote=Roberthh post_id=28487 time=1530648550 user_id=601]
Building the image is one thing, but for the image to work also the GPIO pins must match which are used to connect the SX127x chip. But the do not. Sop you have to adapt the LoPy sources to the other connections. CLK, MOSI and MISO see to match, but CS, Reset and Lora Interrupt do not. The LoPy sources are well organized. So the re should be a header file defining these (like <your path to the repository>/pycom-micropython-sigfox/esp32/lora/board.h). But the question is, whether it's worth the effort.
[/quote]

It could have some befinits since there is not yet a SX127x micropython library. The Lopy is also better documented then other ESP32 boards out here. There is extensive documentation about the Lopy.

I see you updated the files in your github. Did you only upload the new files or did you also made changes to the GPIO pins?

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

Re: ESP32 and LoRa

Post by Roberthh » Thu Aug 02, 2018 3:39 pm

The files which I recently placed in the repository are meant for Pycom devices. The change is adding region IN865.
I would not publish code for other device with sx127x chips w/o testing that before. But I do not have such devices available, and I am not going to purchase one of these.

Lennyz1988
Posts: 2
Joined: Thu Aug 02, 2018 6:22 am

Re: ESP32 and LoRa

Post by Lennyz1988 » Sat Aug 11, 2018 1:14 pm

[quote=Roberthh post_id=29090 time=1533224374 user_id=601]
The files which I recently placed in the repository are meant for Pycom devices. The change is adding region IN865.
I would not publish code for other device with sx127x chips w/o testing that before. But I do not have such devices available, and I am not going to purchase one of these.
[/quote]

aah my mistake. I thought it was somesort of port from a lopy device to a "normal" esp32.

Is there any way to connect to the TTN using Micropython with an ESP32 + SX127x? I can only find C libraries but no Micropython. With my Lopy4 it's really easy to connect to the TTN. But with a for example TTGO or Heltec version of the ESP32 I have not found a way to do so (besides using the Arduino IDE).

(

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

Re: ESP32 and LoRa

Post by Roberthh » Sat Aug 11, 2018 4:44 pm

As said, you can port the Pycom software to another ESP32 board. You have to adapt:
- the memory configuration (The Pycom software expects 4 MByte SPRAM and 8 MByte flash with a rev 1 chip)
- the GPIO ports for the SC1272 chip
All of the is not too complicated, but I do not think it's worth the effort. You may save 20 $ and invest hours and hours.

Post Reply