Use STMCubeIDE to Develop LoRa-E5 mini as End Node for Private LoRaWAN Network / JEDI IoT Platform

Description

This project is a “primer/getting started” demo for setting up Seeed’s LoRa-E5 mini evaluation board as a LoRaWAN end node on a private LoRaWAN network. It sets up the STM32WLE5JC module based LoRa-E5 mini board as a LoRa sensor development node using ST’s STMCube IDE and the ST-Link/v2 programmer to program the demo firmware onto the board. The demo code used is Seeed’s port of ST’s STM32Cube MCU Package for STM32WL series(SDK) to Seeed’s STM32WLE5JC module based LoRa-E5 mini board. Once programmed, the sensor node is added to a ChirpStack based private LoRaWAN network where HTTP integration and a custom data collector are used to pass sensor data into Machinechat’s JEDI Pro IoT platform. Seeed’s IP67 rated industrial LoRaWAN gateway is used to forward the LoRa sensor packets to a private ChirpStack LoRaWAN network server running on a Seeed Odyssey Blue mini PC (with Ubuntu linux installed). Machinechat’s JEDI Pro IoT platform runs on the same Odyssey Blue mini PC.

Hardware

  • Seeed Odyssey Blue x86 Mini PC
    Quad Core Celeron J4105 Mini PC with 128GB external SSD note: this needs to be updated with new part number that is available
  • Seeed SenseCAP Outdoor Gateway - LoRaWAN US915MHz
    SenseCAP LoRaWAN Gateway is based on LoRaWAN® protocol, applicable for low-power, long-distance environmental data collection and monitoring.
  • Seeed LoRa-E5 mini
    LoRa-E5 mini is a LoRa® (LoRaWAN™) evaluation board embedded with Seeed’s LoRa-E5 STM32WLE5JC Module
  • ST-LINK/V2
    STM8, STM32 series Debugger, Programmer (In-Circuit/In-System)

Software

  • JEDI Pro or JEDI Pro SSE
    Adaptable software for IoT data collection, visualization, monitoring and data storage that can be integrated into IoT solutions. Capabilities include: collect data from sensors, devices and machines; build intuitive real-time and historical data and system view dashboards; create rules to monitor and respond to data conditions automatically; receive alert notifications by email and SMS. JEDI Pro SSE is the Seeed Studio Edition version of JEDI Pro that adds a Data Collector for Seeed’s line of SenseCAP LoRaWAN sensors
  • ChirpStack
    The ChirpStack open-source LoRaWAN Network Server stack provides open-source components for LoRaWAN networks. The modular architecture makes it possible to integrate within existing infrastructures.
  • ST Tools & Software
    ST tools STM32CubeProgrammer and STM32CubeIDE need to be installed for this project.
  • Tera Term
    Tera Term is open source free software terminal emulator supporting UTF-8 protocol.

Background

This post is a follow-on project that builds on the related TechForum post Set up a private LoRaWAN Sensor Network with Machinechat and Seeed SenseCAP which details setting up a private LoRaWAN IoT sensor network using off the shelf hardware and software available at Digi-Key. Software used in the related project included Machinechat’s JEDI Pro applications software and ChirpStack’s LoRaWAN network server application. Hardware used in the project included a Seeed Odyssey x86 Mini PC and SenseCAP outdoor LoRaWAN gateway. For this post a LoRa-E5 mini is programmed as a LoRa sensor and added to the existing private LoRaWAN network.

Implementation

The demo is based on Seeed’s “Develop with STM32Cube MCU Package” documentation in the Seeed Wiki LoRa-E5 mini. The “LoRaWAN End Node” STMCubeIDE project is used for the demo where LoRa frequency, device EUI, and device AppKey are modified in the code, compiled and programmed into the LoRa-E5 mini. Note: in order to implement the demo firmware the factory loaded AT command software needs to be re-programmed and the factory AT firmware is NOT recoverable.

Setting up the ST-Link/v2 programmer connection to LoRa-E5 mini board

St’s ST-Link/v2 is used to program the compiled hex file into the LoRa-E5 mini board. Connect a USB cable from the computer to the Type-C USB port of the board for power and serial communication. The ST-Link/v2 needs to be connected to the LoRa-E5 mini board as shown in below diagram (see Scheme-it LoRaE5mini_STlinkV2 Project). A USB cable from the computer running the ST tools also needs to be connected to the ST-Link/v2.

Electrical connections are shown below:

ST-Link/v2 JTAG connector Function LoRa-E5 mini pin
pin 1 VCC 3V3
pin 4 GND GND
pin 7 SWDIO DIO
Pin 9 SWCLK CLK

Set up the LoRa-E5 mini sensor node firmware

The LoRa-E5 mini LoRaWAN sensor node code used in this project comes from Seeed’s port of ST’s STM32Cube MCU Package for STM32WL series(SDK) and closely follows related steps in the Seeed Wiki LoRa-E5 mini. The Seeed code utilized “The Things Network (TTN)” for the LoRaWAN network server but the code is also compatible with the ChirpStack LoRaWAN network server used in this project. The Things Network is not used in this project but the LoRaWAN concepts are very similar.

1 - Go to Seeed’s GitHub - Seeed-Studio/LoRaWan-E5-Node at qian repository and download as a zip file. Extract the zip file and go to directory C:\STMicro\LoRaE5project\LoRaWan-E5-Node-qian\LoRaWan-E5-Node-qian\Projects\Applications\LoRaWAN\LoRaWAN_End_Node\STM32CubeIDE .

2 - Double-click on the .project file

3 - Once STMCubeIDE is open, right-click on file and select Properties.

4 - In Properties navigate to C/C++ Build then Settings and then MCU Post build outputs. Select checkbox for Convert to Intel hex file(-O ihex) and click Apply and Close.

5 - Select Build Debug to run

image

6 - It should compile without any errors

7 - The parameters for LoRaWAN Device EUI, Application KEY will be modified in the LoRaWAN end node code. The #define statements in the se-identity.h and lora_app.h STMCubeIDE project include files will be modified.

Modify #define LORAWAN_DEVICE_EUI and #define LORAWAN_APP_KEY in se-identity.h

Modify #define ACTIVE_REGION to US915 in lora_app.h

8 - After the se-identity.h and lora-app.h files have been modified, rebuild the project and program to the LoRa-E5 mini board. Open STMCubeProgammer, connect the ST-Link/v2 to your computer, hold RESET button of the LoRa-E5 mini, select CONNECT on the programmer and release RESET button (note make sure ST-LINK is selected in upper right hand corner of programmer.

Select OB (Option bytes). check to make sure Read Out Protection is set to value AA

Go to Erasing and Programming page and select your hex file (in my example it is C:\STMicro\LoRaE5project\LoRaWan-E5-Node-qian\LoRaWan-E5-Node-qian\Projects\Applications\LoRaWAN\LoRaWAN_End_Node\STM32CubeIDE\Debug\LoRaWAN_End_NodeSTM32E5.hex). Select programming options as shown and select Start Programming

Check LoRa-E5 mini debug serial output for LoRaWAN network status

Once programmed, the board will attempt to join a LoRaWAN network. Since it has not been added to any network yet, the serial output should indicate "NETWORK JOIN Fail. TeraTerm can be used to connect to the USB serial output of the LoRa-E5 mini.

1 - Start up TeraTerm and connect serial port to USB serial port for the LoRa-E5 mini. Set baud rate to 115200, data bits to 8 and parity to none

image

Add the LoRa-E5 mini sensor node to the ChirpStack LoRaWAN network server

(note: this project and below steps assume that a ChirpStack based private LoRaWAN network is active and in range of the LoRa-E5 mini LoRaWAN sensor node, if not refer to TechForum post Set up a private LoRaWAN Sensor Network with Machinechat and Seeed SenseCAP)

1 - In ChirpStack, select Service-profiles and Create. Name Service-profile “STM32WL”, select Network-server “Chirpstack Network Server” and check Add gateway meta-data box.

2 - In ChirpStack, select Device-profile and Create. Name Device-profile “Seeed LoRaE5”, Select “1.0.2” for LoRaWAN MAC version, Select “A” for LoRaWAN Regional Parameters version, Select “Default ADR algorithm” for ADR algorithm, and enter “3600” for Uplink interval. In JOIN(OTAA/ABP) tab, check box for “Device supports OTAA”. In CODEC tab, select “Cayenne LPP” in CODEC dropdown list.

3 - In ChirpStack, select Applications and Create. Enter “FarmTest” for Application name, enter “description” for Application description, and select “STM32WL” for Service-profile.

4 - In ChirpStack, select Applications, then select “FarmTest” and then select Create. Enter “LoRaE5mini” for Device name, enter “description” for Device description, enter Device EUI for LoRa-E5 mini board (same # as entered in “se-identity.h”), enter “Seeed LoRaE5” for Device-profile, and select CREATE DEVICE. (note: for initial testing and demonstration you may want to check Disable frame-counter validation box)

5 - Add Application key for Device. Enter Application key specified in “se-identity.h” and select SET DEVICE-KEYS.

Run LoRa-E5 mini sensor node firmware to check for join to ChirpStack LoRaWAN network server

(note: LoRa-E5 mini board needs to be connected to PC with Tera Term installed)

1 - Set up Tera Term serial terminal - check COM port number, start Tera Term and configure per below.
image

2 - Check for LoRa-E5 mini board join to Chirpstack LoRaWAN network with serial terminal - power board and use Tera Term serial terminal to check for network join.

image

3 - Optional step if LoRa-E5 mini board does not join network. In Chirpstack, select Applications, then select Application “FarmTest”, then select Device “LoRaE5mini”, then select CLEAR DEVNONCE. Check Tera Term serial terminal for network join.

Set up and test ChirpStack HTTP Integration with JEDI Pro Generic LoRaWAN Custom Data Collector

ChirpStack is modified to add HTTP integration for forwarding LoRaWAN meta and sensor data to a specified IP address. Machinechat’s Generic LoRaWAN Custom Data Collector Plug-in is used for listening to the specified IP address and parsing the LoRaWAN data for review (when debug enabled) and use in the JEDI Pro platform.
(note: The Custom Data Collector consists of two files, lorawan-linux.bin and config.yml that are available from Machinechat at: https://support.machinechat.io/hc/en-us/articles/6046199010327-Generic-LoRaWAN-Custom-Data-Collector-Beta-for-JEDI-PRO-Linux )

1 - Enable HTTP Integration in ChirpStack.
Select “Add” in ChirpStack Integrations screen.

2 - Configure HTTP Integration
Select “JSON” for Payload marshaler , add IP address (use same IP as in config.yml file) for Endpoint URL , and select ADD INTEGRATION

3 - Copy lorawan-linux.bin and config.yml files to the ~/jedi/plugins directory where JEDI Pro is installed on the Ubuntu Linux Mini-PC. Modify config.yml file to enable debug and specify IP listening address.

4 - Run Custom Plug-In on command line using “./lorawan-linux.bin ./config.yml” on terminal in Ubuntu Linux Mini-PC and monitor output data. Data should look similar to below (note: remember to make lorawan-linux.bin file executable):

5 - Edit config.yml file to map LoRaWAN data to JEDI Pro data parameters and disable debug. For this project example, edit propertyNames so LoRaWAN cSproperty: “barometer.0” is mapped to mcProperty: “barometer”, LoRaWAN cSproperty: “temperatureSensor.1” is mapped to mcProperty: “temperature”, and LoRaWAN cSproperty: “humiditySensor.2” is mapped to mcProperty: “humidityr”. Disable debugging by setting “setDebug:” to false and save file.

Set up JEDI Pro Custom Data Collector and Data Dashboard

In JEDI Pro, select “Settings” tab, then select “Data Collectors” and select “Add Collector”.

Configure Collector as shown below. Name Data Collector “LoRaWAN” (or whatever you prefer), select Collector Type as “Custom Plug-In”, select “lorawan-linux.bin” as Plug-In Executable file, enter location of config.yml file (example: “/home/scottr/jedi/plugins/config.yml” for Plug-in Options, select check box for “Run As Background Process and Monitor” , then select “VALIDATE PLUG-IN” to verifiy functionality.

In JEDI Pro, select “Data Dashboards”, then select “+” to add a new chart.

Configure data chart and select “Add” to include in your Data Dashboard(see example below)


image

Conclusion

Seeed’s LoRa-E5 mini board provides a cost effective and compact hardware solution for development, prototyping and low volume deployment of LoRaWAN sensor node. Seeed’s port of STMicroelectronics’ STM32Cube MCU Package for STM32WL series SDK to their LoRa-E5 module provides a quick and efficient starting point for LoRaWAN end node application development. ChirpStack’s HTTP Integration and Machinechat’s Generic LoRaWAN Custom Data Collector are then configured to bring the LoRaWAN end node sensor data into JEDI Pro for IoT data collection, visualization, monitoring and data storage. Seeed’s LoRaWAN example projects serves as a quick start guide and general reference for customers interested in creating LoRa-E5 based LoRaWAN sensor nodes for their own private LoRaWAN network.

References

1 Like