This repository contains guide and resources to quickly deploy an experimental LoRaWAN network. It contains guides for various nodes and gateways, as well as setting up network server locally or in cloud with The Things Stack.
Section 2 - Setting up and deploying gateways - provides a non-exhaustive list of recommended gateways that can be used to start with LoRaWAN deployment.
Section 5 - Setting up and deploying nodes - provides a non-exhaustive list of recommended experimental nodes that can be used to start with LoRaWAN deployment.
-
A standard used in this setup is The Things Stack - a LoRaWAN network server implementation by The Things Network (and subsequently The Things Industries). This choice was made due to it being high on features (new LoRaWAN standards are implemented very quickly), open-source (github here) and rich in documentation and community support.
It is possible to use the community cloud version, that is deployed globally and operated by TTN, as well as deploy an independent instance of the stack. The latter provides more versatility in terms of customization, as well as autonomicity, while community network provides vanilla flow that is extremely easy and fast to start with.
This guide shows the use of the console (GUI client) for TTN, however there is also a CLI client available (ttn-lw-cli). It can provide more versatile configuration options for various deployment cases.
Using this option boils down to creating an account in the community network server. Adding an application, gateways and devices is described in the further parts of the manual (see table of contents).
To create an account, go to https://console.cloud.thethings.network and choose the region (most probably it will be EU)
If you don't yet have an account - register and then log in to the console with your account. If you see the screen below - you are ready to add your applications, gateways and devices, all of which are described in subsequent steps.
TODO
To be able to receive messages from the devices some gateways are required. If you are using the community network, there is a great chance that there is already a gateway belonging to someone else deployed around you ( you can check it on the map).
However, you can still add the gateways that you own. Below the instructions some gateways, the list is not exhaustive.
Before proceeding, go to The Things Network Console -> Gateways -> Add Gateway and find the gateway server address that your network server is connected with - this is needed for setup of all gateways. In this case the address is
eu1.cloud.tethings.network
This gateway comes a part of LoRa STM32 Nucleo pack. A full manual for the pack can be found here - section 6 on page 28 describes the gateway setup.
Connect the gateway as shown in the picture:
It is assumed that the serial monitor also provides 5V power supply to the Nucleo board, and Ethernet is connected to the internet. Open serial monitor at 115200 baud rate, and press the black button to restart the board.
You will be presented with the information screen with all the details of the current configuration, including the LORAWAN SERVER
option. For the gateway to
be able to join our stack, we need to provide the gateway server address acquired
in the beginning of this section.
The Nucleo board communicates with the concentrator shield via AT commands (full reference can be found here).
To change the gateway server address, paste the following command in the terminal:
# 1700 - uplink and downlink UDP ports of the server
AT+PKTFWD=eu1.cloud.thethings.network,1700,1700
If the network you are connecting the gateway to does not have a DHCP server, you can set up an IP address manually as well
AT+IP=STATIC,<ip>,<netmask>,<gatewayip>
Frequency plan can also be changed if needed, with the command
AT+CH=<Freq>
# Freq = EU868 | US915 | EU433 | CN780 | AU915 | ...
If everything set up correctly, you should see the messages saying the uplink and downlink UDPs are connected.
To add the gateway to your TTN account, navigate to the console, go to gateways tab and select "Add Gateway", as before.
Now, fill in
- Gateway ID - any string ID (e.g. my-nucleo)
- Gateway EUI - this can be found in the serial output of the device. This might be a little bit confusing, because in the gateway output it's called
GATEWAY ID
, but this is the Gateway EUI we need. In this case it's0080E1FFFF014E4A
- Name and description can be skipped
- Gateway server - in this example
eu1.cloud.thethings.network
- Frequency plan -
Europe 863-870 MHz (SF9 for RX2)
- Enforce duty cycle - recommended, but can be disabled for experimental purposes
After this click Create gateway
.
If everything was set up correctly, you will see your gateway go online after some time, and some uplink and downlink messages will be seen as well, if there are devices around.
You can also manually add the location of the gateway on the map.
A detailed instruction on how to set up TTIG can be found here.
A robust gateway with great hardware.
A detailed instruction on how to set up Tektelic Kona Micro can be found here
This is a great gateway that can also serve as a Wi-Fi access point simultaneously.
A detailed instruction on how to set up MikroTik Routerboard wAP LoRa8 kit can be found here
To be able to add nodes and manage their data, an application is needed. To create an application, go to console -> Applications -> Add application.
Simply enter an Application ID and press "Create application".
Now you are ready to add devices.
This section is dedicated to configuring different types of development environment for developing firmware for B-L072Z-LRWAN1 STM32 Discovery Kit.
mbedOS is the recommended platform, as it is more versatile and easy to work with than LoRaWAN extension modules for STM32CubeIDE. First two sections describe two ways of working with mbedOS, the last section is dedicated to STM32CubeIDE.
mbedOS allows for various ways to create and cross-compile the firmware for
a lot of end devices and development boards. The B-L072Z-LRWAN1 STM32
board
from the nodes in this manual supports mbedOS.
This variant allows for working wit the code and cross-compiling locally.
More details about installing the Mbed CLI 2 (including Windows), as well as dependencies can be found here.
Below the installation process:
Prerequisites (for Unix systems)
- Make sure you have Python 3.6 or higher, and the corresponding development package (i.e.
python3-dev
) - Install CMake
- Install Ninja
- Install GNU Arm Embedded Toolchain
After the prerequisites are satisfied, create a virtual environment in the root of this repository for installing python packets to avoid conflicts with the host packets
➜ python3 -m venv env_mbed
➜ source ./env_mbed/bin/activate
# To deactivate the virtual environment use
➜ deactivate
After activating the virtual environment install the Mbed CLI, and make sure that
~/.local/bin
is in the path
➜ python -m pip install mbed-tools
# If ~/.local/bin not in PATH
➜ PATH="$PATH:~/.local/bin"
Navigate to the directory with the project (e.g. ./mbed-os-example-lorawan
in this repository) and prepare the project:
➜ mbed_tools deploy
Checking out all libraries to revisions specified in .lib files. Resolving any unresolved libraries.
The following library dependencies were fetched:
Library Name Repository URL Path Git Reference
-------------- ---------------------------------- ----------------------------------------------------------------------- ---------------
mbed-os https://github.com/ARMmbed/mbed-os /Users/ivanturasov/5lic_repo/repository/mbed-os-example-lorawan/mbed-os master
Now the project is ready for building, refer to project readme in ./mbed-os-example-lorawan/README.md
Go to https://os.mbed.com/accounts/login/ and create an account.
After logging in, go to Compiler
in the top right of the page, near profile,
and verify you can see the online IDE.
This variant can be used to create firmwares for both B-L072Z-LRWAN1 STM32
and Nucleo-L073RZ Dev Board with I-NUCLEO-LRWAN1
First download and install the IDE (link). It requires registering a free profile at the ST portal.
Launch the IDE, and note the path to the workspace that you begin in. After, download the I-CUBE-LRWAN software expansion and move the downloaded files to the workspace directory for convenience.
At this point, the pre-configuration is complete, further steps are described in the respective end devices'
This part is dedicated to configuring the example firmware for the nodes building it and flashing it to the device. The base for the firmware can be different - B-L072Z-LRWAN1 can run arm mbedOS and ST firmware, while Nucleo-L073RZ can only be used with ST firmware at the moment of writing.
Go to the console, navigate to the application created in the section above,
and click Add end device
button.
This step is the same for both nodes described further.
Go to the tab Manually
and configure the following parameters:
- Frequency plan - select the same, as was selected for the gateway (
Europe 863-870 MHz (SF9 for RX2)
) - LoRaWAN version - MAC V1.0.3
- Regional Parameters Version - PHY V1.0.3 REV A
- DevEUI - Generate
- AppEUI - Fill with zeros
- AppKey - Generate
- End device ID - any string (e.g.
my-new-device
)
Click Register end device
.
Note - advanced activation options like ABP can be configured here, but this
manual covers only OTAA. For more details explore The Things Network
documentation.
The Things Uno (actually based on Arduino Leonardo) is a perfect device to start rapid prototyping with LoRaWAN.
Extensive guide on how to start with, configure and flash this board can be found here.
-
The mbed-os example provided in
./mbed-os-example-lorawan
can be modified to add peripherals, LED controls or anything else - for this add code tomain.c
.-
Local
Navigate to
./mbed-os-example-lorawan
and follow the build and flash instructions in theREADME.md
.Fille the
"lora.device-eui"
,"lora.application-eui"
and"lora.application-key"
fields inmbed_app.json
with the DevEUI, AppEUI and AppKey generated in the console in the previous step.Flash the resulting binary with either
--flash
flag in mbed-tools, or by dragging the .bin file in the USB volume of the node connected to the host machine -
Online
Go to mbed-os-example-lorawan page and click
Import into compiler
.Fille the
"lora.device-eui"
,"lora.application-eui"
and"lora.application-key"
fields inmbed_app.json
with the DevEUI, AppEUI and AppKey generated in the console in the previous step.Compile and download the binary, and put it in the USB volume of the node connected to the host machine.
-
Open the IDE and go to Import the project, then select Import Atolli TrueSTUDIO Project
Select the path where you saved the LoRaWAN extension, and navigate to STM32CubeIDE/STM32CubeExpansion_LRWAN_V2.1.0/Projects/B-L072Z-LRWAN1/Applications/LoRaWAN/LoRaWAN_End_Node
Select the project that contains cmwx1zzabz_0xx
and click Finish.
In the file explorer open the file
STM32CubeIDE/STM32CubeExpansion_LRWAN_V2.1.0/Projects/B-L072Z-LRWAN1/Applications/LoRaWAN/LoRaWAN_End_Node/LoRaWAN/App/se-identity.h
and fill in the keys generated when creating the device in the console
Build the firmware with the hammer in the left top corner, and then run it in the device with the play button. After it's flashed, open the serial monitor and verify that the keys are configured correctly and the connection with the server was successful.
The device page in the application should be showing the messages flying from the device.