Skip to content

Guides

Connect a LoRaWAN network server

Bring the uplinks of a ChirpStack or The Things Stack application into Thinger.io, with devices and a Data Bucket created on the first message.

Not available on free Cloud

Tutorial4 min read

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_SERVER is the hostname of your instance, and YOUR_USER your 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 ​

  1. Install the network server plugin

    Go to Plugins > Marketplace, open the plugin of your network server and click Install (see Install a plugin):

    Network serverPlugin
    ChirpStackChirpStack
    The Things StackThe Things Stack

    Do not use ttn-stack: it is deprecated. The plugin is installed stopped: on its page, click Start.

  2. 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:

    PartWhat it does
    uplink device resourceReceives each message from the network server plugin, in the common format.
    uplink propertyKeeps the last uplink of each device. The downlink device resource reads the network server and the DevEUI from it, and dashboards can show its fields, such as the counter or the battery.
    downlink device 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 ruleCreates 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 uplink and downlink device 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 ​

  1. 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}
    Auto Provision rule of the LoRaWAN Device Template

    API

    YOUR_TOKEN is an access token of your account.

    PUT/v1/users/{user}/products/{product}/profile/{category}/{resource}API reference
    bash
    curl -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 agent

    In 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_update with the product_profile_autoprovision type. See MCP tools.

  2. 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 in decodedPayload. To store your own fields, edit the function parseOrDecodeIncomingData in the product script: the Data Bucket stores what it returns.

Connect the network server ​

  1. Add the application to the plugin

    Open the plugin from the Plugins menu, go to Applications and click Add.

    ChirpStack

    FieldValue
    Application NameThe name of the application in ChirpStack. The plugin matches it with the application name of each uplink.
    Device Id Prefixmy_device_, the prefix of your Auto Provision pattern.
    Access TokenAn API token of your ChirpStack server, used to send downlinks.
    Server URLThe address of your ChirpStack server, such as chirpstack.example.com.
    PortThe gRPC port of ChirpStack. The default is 8080.
    EnabledOn.

    The Things Stack

    FieldValue
    Application NameThe application ID in The Things Stack.
    Device Id Prefixmy_device_, the prefix of your Auto Provision pattern.
    EnabledOn.
  2. 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 Authorization and the copied token as its value, Bearer included.

    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.

  3. 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 is test_app: use that Application Name in the plugin, or change deviceInfo.applicationName in the file to yours.

    Send it with the ChirpStack API Token of the plugin settings as YOUR_TOKEN:

    bash
    curl -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:

json
{
  "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.

Next steps ​