In this tutorial you connect a LoRaWAN application to Thinger.io through a network server plugin. Each sensor of the application becomes a device on its first uplink, and its messages are stored in a Data Bucket. LoRaWAN explains how the pieces fit; this page walks through them once, end to end.
What you need
- A Thinger.io private instance. Plugins are not available on the free Cloud account.
YOUR_SERVERis the hostname of your instance, andYOUR_USERyour username. - An application on ChirpStack or on The Things Stack (The Things Network or The Things Industries), with devices of a single model.
- For ChirpStack, an API token of your ChirpStack server, and its gRPC port reachable from your instance.
You can follow the steps without a network server: the last step sends a sample uplink by hand.
Install the plugins
Install the network server plugin
Go to Plugins > Marketplace, open the plugin of your network server and click Install (see Install a plugin):
Network server Plugin ChirpStack ChirpStack The Things Stack The Things Stack Do not use
ttn-stack: it is deprecated. The plugin is installed stopped: on its page, click Start.Install the LoRaWAN Device Template
Install the LoRaWAN Device Template plugin the same way. It creates the product LoRaWAN Device Template (
lorawan_device_template) with:Part What it does uplinkdevice resourceReceives each message from the network server plugin, in the common format. uplinkpropertyKeeps the last uplink of each device. The downlinkdevice resource reads the network server and the DevEUI from it, and dashboards can show its fields, such as the counter or the battery.downlinkdevice resourceSends a downlink through the plugin that delivered the last uplink. See Send a downlink. Data Bucket device_dataStores every uplink, after your decoder. Auto Provision rule Creates the device on its first uplink. If the Marketplace has a plugin for your sensor model, you can install it instead: it creates the same kind of product with the decoder of that sensor.
Warning
Keep the names and the input of the
uplinkanddownlinkdevice resources as they are. The network server plugins call them by name and with the common format, so a product that changes them stops working with every network server.
Prepare the product
Set the device ID pattern
The plugin names each device with a prefix you choose followed by the DevEUI in uppercase hexadecimal, such as
my_device_70B3D597B0000D15. Make the product's Auto Provision pattern match it: the prefix followed by[0-9A-F]{16}.Console
Go to Products, open LoRaWAN Device Template and edit its Auto Provision rule Device Pattern ID. Set the Device Pattern to
my_device_[0-9A-F]{16}and save.![Auto Provision modal of the LoRaWAN Device Template product with the device pattern my_device_[0-9A-F]{16}](/screenshots/lorawan-guide-autoprovision.webp)
Auto Provision rule of the LoRaWAN Device Template API
YOUR_TOKENis an access token of your account.bashcurl -X PUT "https://YOUR_SERVER/v1/users/YOUR_USER/products/lorawan_device_template/profile/autoprovisions/device_autoprovisioning" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Device Pattern ID", "enabled": true, "config": { "mode": "pattern", "pattern": "my_device_[0-9A-F]{16}" } }'AI
Ask your AI agentIn the product lorawan_device_template, change the Auto Provision rule device_autoprovisioning so it matches device IDs that start with my_device_ followed by 16 uppercase hexadecimal characters.
The agent uses
thinger_resource_updatewith theproduct_profile_autoprovisiontype. See MCP tools.Add your decoder
The plugin delivers each uplink with the raw payload in hexadecimal (
payload), the port (fPort), the counter (fCnt) and the DevEUI (deviceEui). If the network server decodes the payload, it also comes indecodedPayload. To store your own fields, edit the functionparseOrDecodeIncomingDatain the product script: the Data Bucket stores what it returns.
Connect the network server
Add the application to the plugin
Open the plugin from the Plugins menu, go to Applications and click Add.
ChirpStack
Field Value Application Name The name of the application in ChirpStack. The plugin matches it with the application name of each uplink. Device Id Prefix my_device_, the prefix of your Auto Provision pattern.Access Token An API token of your ChirpStack server, used to send downlinks. Server URL The address of your ChirpStack server, such as chirpstack.example.com.Port The gRPC port of ChirpStack. The default is 8080.Enabled On. The Things Stack
Field Value Application Name The application ID in The Things Stack. Device Id Prefix my_device_, the prefix of your Auto Provision pattern.Enabled On. Create the integration in the network server
In the plugin, go to Settings and copy the Endpoint Base URL for Uplinks, which is
https://YOUR_SERVER/users/YOUR_USER/plugins/<plugin>/uplink, and the API token (ChirpStack API Token or TTN API Token). Then create the integration in the network server:ChirpStack
Open the application, go to Integrations and add an HTTP integration. Set the Event endpoint URL(s) to the uplink URL, and add a header with the key
Authorizationand the copied token as its value,Bearerincluded.The Things Stack
Open the application, go to Integrations > Webhooks, click Add webhook and choose the Thinger.io template. Fill in your instance hostname, your username and the copied token, and keep the default plugin endpoint.
Send a test uplink
Without waiting for a sensor, you can post the sample uplink of the ChirpStack plugin,
uplink_sample.json, an uplink in the format of ChirpStack. Its application name istest_app: use that Application Name in the plugin, or changedeviceInfo.applicationNamein the file to yours.Send it with the ChirpStack API Token of the plugin settings as
YOUR_TOKEN:bashcurl -X POST "https://YOUR_SERVER/users/YOUR_USER/plugins/chirpstack/uplink" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ --data @uplink_sample.json
Result
The device my_device_70B3D597B0000D15 appears in Devices, as an HTTP device of the product LoRaWAN Device Template, and the Data Bucket device_data stores the uplink with these fields, among others:
{
"appId": "test_app",
"deviceEui": "70B3D597B0000D15",
"deviceId": "my_device_70B3D597B0000D15",
"fCnt": 5825,
"fPort": 1,
"payload": "01472309c51c28",
"decodedPayload": null,
"source": "chirpstack"
}The plugin's Inspector tab shows the messages as they arrive. The sample has no decoded payload, so decodedPayload is null and the bucket keeps the raw payload until you add your decoder. The device's uplink property holds the same object, which the downlink device resource needs to send a downlink.
When you are done testing, delete the test device from Devices. Uninstalling the LoRaWAN Device Template plugin removes its product.