Difference between revisions of "LoRa-E5-mini"

From RevSpace
Jump to navigation Jump to search
(Development environment)
(The plan)
(12 intermediate revisions by the same user not shown)
Line 8: Line 8:
  
 
=== The plan ===
 
=== The plan ===
This page is about the LoRa-E5 module and getting it to work as a LoRaWAN node with Arduino and the BasicMac stack.
+
This page is about the Seeed Studios LoRa-E5 mini development board and getting it to work as a LoRaWAN node with Arduino and the BasicMac stack.
* replace the original "AT" firmware with Arduino based firmware
+
* Replace the original "AT" firmware with Arduino based firmware
* use the BasicMac library for LoRaWAN
+
* Use the BasicMac library for LoRaWAN
* use platformio as the build system
+
* Use platformio as the build system
* create some basic examples for use as a LoRaWAN node on TheThingsNetwork
+
* Create some basic examples for use as a LoRaWAN node on TheThingsNetwork
 +
* Use this chip/module for transmitting high-altitude balloon telemetry, possibly using 4FSK modulation (not using LoRa)
  
 
Interesting post about this module:
 
Interesting post about this module:
Line 18: Line 19:
  
 
What currently works:
 
What currently works:
* can run an Arduino program, compiling from the Arduino IDE
+
* Can run an Arduino program, compiling from the Arduino IDE
* blinking the LED works
+
* Blinking the LED works
* output over serial works
+
* Output over serial works
 +
* Reading the button works
 +
* Basic communication with the built-in SX1262 LoRa transceiver
  
 
TODO, yet to figure out:
 
TODO, yet to figure out:
* add support for the Seeed LoRa E5 mini in the stm32 package
+
* Get basicmac stack working with the "subghz" SPI port (it appears communication in the Arduino version of BasicMac is done using just "SPI", see https://github.com/LacunaSpace/basicmac/blob/master/target/arduino/hal/hal.cpp#L193). The problem is that the basicmac LoRaWAN stack expects to talk to a SPI port, while the STM32WL HAL provides higher-level functions to write commands and data, see https://github.com/bertrik/Arduino_Core_STM32/blob/seeed_lora_e5_mini/system/Drivers/STM32WLxx_HAL_Driver/Inc/stm32wlxx_hal_subghz.h#L355 . Internally the STM32 SUBGHZ HAL uses functions like [https://github.com/bertrik/Arduino_Core_STM32/blob/seeed_lora_e5_mini/system/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c#L1573 SUBGHZSPI_Transmit] that would be a much better fit to the interface expected by the BasicMac stack.
* get communication going using the internal "subghz" SPI port
+
* Get compilation and upload working with platformio
** do I need to enable the APB3 clock domain?
 
** be careful about the SUBGHZ SPI clock in combination with SMPS mode
 
** get a simple transfer going that proves that meaningful data is exchanged (e.g. default sync word magic number)
 
* get basicmac stack working with the "subghz" SPI port (it appears communication in the Arduino version of BasicMac is done using just "SPI", see https://github.com/LacunaSpace/basicmac/blob/master/target/arduino/hal/hal.cpp#L193)
 
* get compilation and upload working with platformio
 
  
 
=== Hardware ===
 
=== Hardware ===
The hardware is the LoRa-E5 mini from seeed studio, contains the STM32WLE5JC:
+
The hardware is the LoRa-E5 mini from seeed studio, contains the [https://www.st.com/en/microcontrollers-microprocessors/stm32wle5jc.html STM32WLE5JC]:
 
* LoRa E5 Seeed studio module (just the chip): https://www.seeedstudio.com/LoRa-E5-Wireless-Module-p-4745.html
 
* LoRa E5 Seeed studio module (just the chip): https://www.seeedstudio.com/LoRa-E5-Wireless-Module-p-4745.html
 
* LoRa E5 Seeed studio LoRa-E5 mini dev board: https://www.seeedstudio.com/LoRa-E5-mini-STM32WLE5JC-p-4869.html
 
* LoRa E5 Seeed studio LoRa-E5 mini dev board: https://www.seeedstudio.com/LoRa-E5-mini-STM32WLE5JC-p-4869.html
Line 42: Line 40:
  
 
Pins:
 
Pins:
* PA4/PA5: radio rx/tx?
+
* PA4/PA5: radio rx/tx switch (internal, not available on the footprint of the E5 module)
 
* PB6/PB7: serial port
 
* PB6/PB7: serial port
 
* PB5: onboard LED
 
* PB5: onboard LED
 
* PB13: onboard button ("BOOT")
 
* PB13: onboard button ("BOOT")
* PA4: internal SUBGHZ SPI NSS, conflicts with RX/TX switch?
 
* PA5: internal SUBGHZ SPI SCK, conflicts with RX/TX switch?
 
* PA6: internal SUBGHZ SPI MISO
 
* PA7: internal SUBGHZ SPI MOSI
 
  
 
==== LoRa modem ====
 
==== LoRa modem ====
Line 65: Line 59:
  
 
=== Software ===
 
=== Software ===
Initial experimental firmware can be found at:
+
The software consists of an STM32 Arduino development environment with support for the Seeed LoRa E5 mini
https://github.com/bertrik/lora-e5
+
plus a demonstration sketch.
* blinky example, the most basic of all sketches which makes a LED blink demonstration of successful download of an Arduino program
 
* helloworld example, sends a text over the serial port
 
  
Updated STM32 support package:
+
==== Development environment ====
 +
This uses my own fork of the STM32 packages, which will include support for the Seeed LoRa E5 mini:
 
https://github.com/bertrik/Arduino_Core_STM32/tree/seeed_lora_e5_mini
 
https://github.com/bertrik/Arduino_Core_STM32/tree/seeed_lora_e5_mini
 
These examples still uses the Arduino IDE.
 
 
==== Development environment ====
 
This uses my own fork of the STM32 packages, which will include support for the Seeed LoRa E5 mini.
 
  
 
* Install Arduino IDE 1.8.16, from https://www.arduino.cc/en/software
 
* Install Arduino IDE 1.8.16, from https://www.arduino.cc/en/software
Line 98: Line 86:
 
** Under menu Tools/Board part number, choose 'Seeed Studios LoRa E5 mini'
 
** Under menu Tools/Board part number, choose 'Seeed Studios LoRa E5 mini'
  
Now you can:
+
==== Demonstration sketch ====
 +
A demonstration sketch is at https://github.com/bertrik/lora-e5 :
 +
* blinky example, the most basic of all sketches which makes a LED blink demonstration of successful download of an Arduino program
 +
* helloworld example, sends a text over the serial port
 +
 
 +
Try the helloworld example:
 
* Load the helloworld.ino file into the Arduino IDE:
 
* Load the helloworld.ino file into the Arduino IDE:
 
** Compile and upload with ctrl-U
 
** Compile and upload with ctrl-U

Revision as of 17:37, 26 October 2021

Project LoRa E5
Arduino on the LoRa-E5-mini devboard
Status In progress
Contact bertrik
Last Update 2021-10-26

The plan

This page is about the Seeed Studios LoRa-E5 mini development board and getting it to work as a LoRaWAN node with Arduino and the BasicMac stack.

  • Replace the original "AT" firmware with Arduino based firmware
  • Use the BasicMac library for LoRaWAN
  • Use platformio as the build system
  • Create some basic examples for use as a LoRaWAN node on TheThingsNetwork
  • Use this chip/module for transmitting high-altitude balloon telemetry, possibly using 4FSK modulation (not using LoRa)

Interesting post about this module: https://www.disk91.com/2021/technology/lora/lora-e5-the-seeed-studio-stm32-wl-module/

What currently works:

  • Can run an Arduino program, compiling from the Arduino IDE
  • Blinking the LED works
  • Output over serial works
  • Reading the button works
  • Basic communication with the built-in SX1262 LoRa transceiver

TODO, yet to figure out:

Hardware

The hardware is the LoRa-E5 mini from seeed studio, contains the STM32WLE5JC:

Overview of pins used on this board (not completely standard): https://wiki.seeedstudio.com/LoRa_E5_mini/#22-gpio-configuration-overview

Pins:

  • PA4/PA5: radio rx/tx switch (internal, not available on the footprint of the E5 module)
  • PB6/PB7: serial port
  • PB5: onboard LED
  • PB13: onboard button ("BOOT")

LoRa modem

It appears the LoRa functionality is exposed through an internal SPI bus, called SUBGHZSPI in the datasheet.

Also, there are some pins to control the radio path.

Programming over SWD

Connect an ST-LINKv2 as follows:

  • SWDIO to PA13
  • SWCLK to PA14
  • GND to GND

You may need to upgrade the firmware of your STLINKv2, mine is currently at V2J38S7.

Software

The software consists of an STM32 Arduino development environment with support for the Seeed LoRa E5 mini plus a demonstration sketch.

Development environment

This uses my own fork of the STM32 packages, which will include support for the Seeed LoRa E5 mini: https://github.com/bertrik/Arduino_Core_STM32/tree/seeed_lora_e5_mini

  • Install Arduino IDE 1.8.16, from https://www.arduino.cc/en/software
  • Configure Arduino STM32 support:
    • Add the following board URL (under File / Preferences / Additional board URLs):
 https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
    • Under menu Tools/Board/Boards manager, search for STM32 and install 'STM32 MCU based boards'
  • Install STM Cube for the upload tools:
    • Download and install package en.stm32cubeprg-lin_v2-8-0_v2.8.0.zip
  • Run STM Cube to remove read protection (and erase the device) from the STM32
    • attach the STLink V2 and connect it to the STM32
    • TODO: document, or see the Seeed page
  • Clone my Arduino_Core_STM32 repo into ~/Arduino/hardware
 cd ~/Arduino/hardware
 mkdir -f stm32
 cd stm32
 git clone https://github.com/bertrik/Arduino_Core_STM32
 git checkout seeed_lora_e5_mini
  • Restart the Arduino IDE and select the correct board:
    • Under menu Tools/Board/STM32 boards .... (sketchbook), choose 'Generic STM32WL series' from 'Generic STM32WL series'
    • Under menu Tools/Board part number, choose 'Seeed Studios LoRa E5 mini'

Demonstration sketch

A demonstration sketch is at https://github.com/bertrik/lora-e5 :

  • blinky example, the most basic of all sketches which makes a LED blink demonstration of successful download of an Arduino program
  • helloworld example, sends a text over the serial port

Try the helloworld example:

  • Load the helloworld.ino file into the Arduino IDE:
    • Compile and upload with ctrl-U
    • See the LED flash
    • Open serial port with ctrl-shift-M and see that serial messages are coming in
    • Press the BOOT button and see the result on the serial console

Node configuration in TheThingsNetwork

The information on the website of Seeed studios is outdated. It refers to the "v2" version of TheThingsNetwork, which is being phased out. It is already impossible to add new nodes on TTNv2, since it was set to read-only.

Nodes should be configured for TheThingsNetwork v3 instead.