The Things Stack
The Things Stack (TTS) is a LoRaWAN service that allows you to send and receive LoRa packets from your nodes. Registering your LoRa-enabled SG Wireless nodes and gateways with TTS gives access to their IoT infrastructure and integrate your devices with the cloud. For more information about The Things Stack and LoRaWAN in general, you can visit their documentation at https://www.thethingsindustries.com/docs/. On this page, we will cover:
In order to use TTS you should navigate to https://console.cloud.thethings.network and select your region. Following that, either login using your account, or create a new one. Already existing accounts on The Things Network (TTN) should work here as well.
Once an account has been registered, you can create an application for your nodes, or register a gateway.
In order to register your device, you must first create an application for these devices to belong to. This way the Network will know where to send the devices data to.
Selecting the Applications tab at the top of the TTN console, will bring up a screen for registering applications.
Applications
Enter a unique Application ID as well as a Description & Handler Registration.
Application ID
Now the SG Wireless module nodes can be registered to send data up to the new Application. Click + Add end device, then on Manually. Select LoRaWAN version: MAC V1.0.2. For the regional parameters, select PHY-V1.0.2-RevA. For Frequency plan please choose one that is compatible with your region and nearby gateways. If you’re not sure which one to choose, select the one closest to your region labelled ‘used by TTN’.
+ Add end device
Manually
LoRaWAN version
MAC V1.0.2
PHY-V1.0.2-RevA
Choose either OTAA or ABP as activation methods. Learn more about the difference here. In this example we’ll use OTAA.
OTAA
ABP
Scroll down and fill in the fields for DevEUI, AppEUI and End device ID.
DevEUI
AppEUI
End device ID
Fill with zeros
AppKey
Generate
from network import LoRa import ubinascii lora = LoRa() print("DevEUI: %s" % (ubinascii.hexlify(lora.mac()).decode('ascii')))
Finally click on Register end device. Great! Now your device is registered with TTS. You can now use the credentials in the LoRaWAN OTAA example.
Register end device
A LoRaWAN gateway receives the LoRa packets sent out by your (and other people’s) nodes and forwards them to the cloud. Next to that, the gateway is able to provide a downlink to your nodes as well. In this case, we will forward the packets to TTS. From there, you can view the traffic coming through your gateway, and view the received messages in your nodes’ application. You can also setup your LoRa-enabled SG Wireless module or Pygate to act as a LoRaWAN gateway. Below we will setup the Gateway in TTS. Have a look at the following pages for more information concerning the device setup:
Inside the TTS Console, there are two options, Applications and Gateways. Select Gateways and then click on register Gateway. This will allow for the set up and registration of a new gateway.
Gateways
register Gateway
Here, it is important we add the Gateway ID and Gateway EUI. The first can be an identifying string of characters unique to the gateway. The latter is what we’ll use in the gateway configuration on the device, and exists of 16 hexadecimal characters. You can use the following to generate the Gateway EUI:
Gateway ID
Gateway EUI
from network import WLAN import binascii wl = WLAN() binascii.hexlify(wl.mac().sta_mac)[:6] + 'fffe' + binascii.hexlify(wl.mac().sta_mac)[6:]
These are unique to each gateway, location and country specific frequency. Please verify that correct settings are selected otherwise the gateway will not connect to TTN. Further down the page, you will have to select a frequency plan. Select the one appropriate for your region and/or the one compatible with your nodes. After that, you can create the gateway.
From here, you can select to download global_conf.json for your selected region. Please check the file for the correct server_address and gateway_ID. This file can be used for configuring the Pygate.
global_conf.json
server_address
gateway_ID