Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors

Connect LoRaWAN and LPWAN devices

Devices on a low-power wide-area network (LPWAN), like LoRaWAN or Sigfox, connect to ThingsBoard through platform integrations. They don’t send data to ThingsBoard themselves: their messages go to the network server of their network, and a ThingsBoard integration takes the messages from there. A LoRaWAN device works this way: a network server receives its radio messages through a LoRaWAN gateway. This page shows how your AI agent connects LoRaWAN devices through a network server, and how to do the same from the terminal.

LoRaWAN device ──► LoRaWAN gateway ──► Network server ──► ThingsBoard
(The Things Stack, (integration
ChirpStack, LORIOT) and converter)

The agent sets up the ThingsBoard side. It finds the decoder of your device, creates the integration after your yes, and gives you the steps to do in the console of the network server, with your values filled in. You register the device in the network server and turn it on. Then the agent checks that the data arrives and that the values make sense.

Network server What the integration needs Where the messages are decoded Device models in one application
The Things Stack Sandbox (TTN), The Things Stack Cloud or Enterprise (TTI) The link of the application in the console, and an API key of the application In The Things Stack: the decoder from the LoRaWAN Device Repository, or a payload formatter Any
Self-hosted The Things Stack The username and the address from the MQTT page of the application, and an API key of the application In The Things Stack, as above Any
ChirpStack An HTTP integration of the ChirpStack application that sends to ThingsBoard. ChirpStack must reach your ThingsBoard In ThingsBoard: the converter of the integration One
LORIOT The server, the application ID, and the email and password of your LORIOT account, or an API token. ThingsBoard must be reachable from the internet In ThingsBoard: the converter of the integration One

ThingsBoard connects to The Things Stack over MQTT. ChirpStack and LORIOT send the messages to ThingsBoard over HTTP.

  • ThingsBoard CLI, connected to ThingsBoard Cloud or your own ThingsBoard server.
  • An account on the network server. If you have none yet, the agent recommends The Things Stack Sandbox: it is free, and you install nothing.
  • A LoRaWAN gateway in range of the device. The steps of the agent include its registration in the network server, if it is not registered yet.
  • The device and its manual. The DevEUI of the device is on its label, and the manual says how to write the keys into the device.
  • For ChirpStack and LORIOT, a ThingsBoard that the network server reaches. LORIOT is a cloud service, so it needs a ThingsBoard with a public address. ChirpStack needs a ThingsBoard on its own computer or network, or a public one.

The steps below connect a LoRaWAN device. The agent asks one value per question, and each question says what the value is and where you find it.

  1. Ask the agent, like “Connect my LoRaWAN sensor”. After the agent deploys a solution, you can also select Yes when it asks Connect a real device to it?, then LoRaWAN sensor when it asks what device it is.

  2. Name the model of the device and select its network server. The question about the network server opens with a one-line diagram of how your device connects, like EM300-TH → LoRaWAN gateway → network server → ThingsBoard. If you don’t know which network server to use, the agent recommends The Things Stack Sandbox.

    Before it asks about the console of the network server, the agent reads the current guides of the network server, so that its steps use the names of today’s menus and fields. For ChirpStack and LORIOT, the agent also checks whether the network server can reach your ThingsBoard.

  3. Wait while the agent finds the decoder, which turns the bytes that the device sends into values. The agent looks for the model in ThingsBoard IoT Hub first. If IoT Hub has a package of the model for your network server, the agent uses the package: it brings the decoder, the device profile, and a dashboard. Otherwise:

    • The Things Stack: If the LoRaWAN Device Repository has the model, you register the device by picking its brand and model, and its decoder comes with it. Otherwise, the agent writes a payload formatter, lorawan/<model>-formatter.js in your project, for you to paste into the console. It writes the formatter from the decoder of the manufacturer or from the datasheet of the device.
    • ChirpStack and LORIOT: The agent writes the decoder of the ThingsBoard converter, lorawan/<model>-decoder.tbel, starting from the default decoder of ThingsBoard. It takes the layout of the bytes from the decoder of the manufacturer or from the datasheet, and it tests the decoder on your ThingsBoard with the example bytes of the manufacturer.
  4. Check the values that the device sends. The agent lists the keys with their units and asks Use it or Change something. Device information, like the serial number or the firmware version, is kept as attributes. With an IoT Hub package, the agent skips this step.

  5. Select Create when the agent asks to create the integration.

    Then answer the questions about the application in the network server, like the link of the application in the console of The Things Stack, or the server and the application ID in LORIOT. For ChirpStack, the agent asks nothing and gives you the address to paste into ChirpStack. If you have no application yet, the agent tells you how to create one.

  6. Give the key that the integration needs, if the agent asks for one: the API key of the application in The Things Stack, or the password of your LORIOT account. The key never passes through the agent. For details, see Give the key of the network server.

  7. Follow the steps from the agent’s message. The message shows the link to the integration, the dashboard of an IoT Hub package, the path of the formatter or the decoder file, and the steps to do in the console of the network server, in the order you do them. At the end, turn the device on.

  8. Say “check my sensor”. LoRaWAN devices send every few minutes, and the first message comes right after the device joins the network. The agent waits up to 10 minutes for the data. For details, see Check the integration.

  9. Choose the next step. When the data arrives, the agent shows the values that it received and asks what to do next, like build a dashboard for the device.

To connect more devices, register them in the same application of the network server. They appear in ThingsBoard with their first message. In ChirpStack and LORIOT, an application holds devices of one model: register a device of another model in another application, which gets its own integration.

The integration needs a key to reach the network server: the API key of an application in The Things Stack, or the password or API token of your LORIOT account. ThingsBoard keeps the key in its secrets storage, and the integration refers to it by the name of the secret, like ${secret:ttn-office-climate-api-key;type:TEXT}. The key never passes through the agent: you give it to the tb secret set command, and the agent sees only the name of the secret. For details, see Secrets storage.

The first time it needs a key, the agent says where to find the key and asks how you’d like to give it:

  • In a file: The agent opens the secrets.env file in the root folder of your project in your text editor and names the line to fill in, like ttn-office-climate-api-key=. Paste the key right after = on the same line, save the file, and select Done. The agent runs tb secret set <name> --env-file secrets.env, which reads the key from the file and stores it in ThingsBoard. Over SSH, without a desktop, the agent gives you a nano command that opens the file at that line.
  • In a terminal: Run tb secret set <name> in a terminal of your own, not inside the agent. The command asks for the key without showing it. Paste the key, press Enter, and select Done.

For the next key in the same conversation, the agent uses the way you chose. To replace a wrong or revoked key, put the new key after <name>= in secrets.env and the agent stores it again, or run tb secret set <name> again.

The agent never opens or reads secrets.env: only tb secret set --env-file reads it. tb init sets up these protections in a new project for Claude Code:

  • Git: .gitignore ignores secrets.env and the copies that editors leave next to it. When tb secret set creates the file, only your user can read it.
  • Agent settings: The settings deny the file tools of the agent on the file.
  • Hook: A PreToolUse hook, tb secret guard --hook, refuses any tool call of the agent that names the file, except tb secret set --env-file and opening the file in a text editor. It also refuses a search that would read the file, like a recursive grep over the project folder.
  • Git history: While git tracks secrets.env, its keys are in the history of the repository. The hook then blocks every git command of the agent and tells you how to stop tracking the file. Replace the keys in that case.

The hook guards against reading the file by accident. It does not stop a deliberate way around it, like a script that reads the file. Projects that an earlier version of tb init created, and projects for Antigravity, don’t have the hook.

Say “check my sensor” or “check the integration”. The agent runs tb integration check --wait, which checks these steps in order:

Step It passes when
Running The integration runs without an error
Devices created A message from the network server reached ThingsBoard and created the device
Data arriving Decoded values arrive from the device

The check waits up to 10 minutes for a message that the device sends after the check started. It also shows the latest errors of the integration and its converter.

When all steps pass, the agent judges each value against the values that you confirmed. For a value that is off by a power of ten, it fixes the scale in the decoder. For a value that makes no sense, it fixes the layout of the bytes. With ChirpStack and LORIOT, the agent replaces the decoder in ThingsBoard itself. With The Things Stack, it writes a new formatter file for you to paste into the console. Then it checks again.

You can create the integration and check it yourself. The commands differ for each network server.

Terminal window
tb secret set ttn-office-climate-api-key # store the API key of the application; it asks for the key
tb integration create things-stack --app-url https://eu1.cloud.thethings.network/console/applications/office-climate --key-secret ttn-office-climate-api-key
tb integration model "TTN - office-climate" --model milesight-iot-em300-th --device-profile EM300-TH
tb integration check "TTN - office-climate" --wait
  • tb integration create things-stack creates the integration with the shared LoRaWAN converter of ThingsBoard. On ThingsBoard 4.3 and 4.4.0.x, which don’t have this converter, the CLI uses its own copy. The command checks the connection before it saves anything. If the application already has an integration, the command uses it as it is.
  • Without --key-secret, the command exits with code 2 and suggests the name of the secret, like ttn-office-climate-api-key, or tti-… for The Things Stack Cloud and a self-hosted one. A secret that does not exist also exits with code 2.
  • For a self-hosted The Things Stack, use --username and --address from the MQTT page of the application instead of --app-url, like --username office-climate@ttn --address tts.example.com:8883.
  • The integration is named TTN - <application ID> or TTI - <application ID>. Use --name to set another name.
  • The shared converter names a device by its end device ID and gives it the device profile of its brand and model. tb integration model sets the name of that profile for one model and, with --attributes sn,firmware_version, the decoded keys to keep as attributes.
Terminal window
tb integration base-url # the address ChirpStack sends to, and whether it is reachable
tb integration decoder-template chirpstack -o lorawan/em300-th-decoder.tbel
tb integration test-decoder --type chirpstack --decoder lorawan/em300-th-decoder.tbel --device-profile EM300-TH
tb integration create chirpstack --decoder lorawan/em300-th-decoder.tbel --device-profile EM300-TH
tb integration check "ChirpStack - EM300-TH" --wait
  • tb integration base-url shows the address of ThingsBoard that a network server sends to, and whether it is local to this computer, on a private network, or public. Use --base-url with base-url, create chirpstack, and create loriot to set another address.
  • tb integration decoder-template writes the default TBEL decoder of ThingsBoard for ChirpStack or LORIOT. Replace its example layout of the bytes with the layout of your device.
  • tb integration test-decoder runs the decoder on your ThingsBoard with a message of the network server, like the converter test of the ThingsBoard UI, and shows the device name, the profile, the telemetry, and the attributes. It saves nothing. Without --uplink, it uses the example message of ThingsBoard. To test on the bytes of your device, add --uplink <file> with an uplink message of ChirpStack.
  • tb integration create chirpstack creates the integration and a converter that decodes one model, and prints the address to paste into the HTTP integration of the ChirpStack application. Without --device-profile, devices get the profile name that they have in ChirpStack.
  • tb integration set-decoder "ChirpStack - EM300-TH" --decoder <file> replaces the decoder of the converter.
Terminal window
tb secret set loriot-<application ID>-password # store the password of your LORIOT account
tb integration create loriot --server eu1 --app-id <application ID> --login <email> --password-secret loriot-<application ID>-password --decoder lorawan/em300-th-decoder.tbel --device-profile EM300-TH
tb integration check "LORIOT - <application ID>" --wait
  • tb integration create loriot exits with code 2 before it creates anything if LORIOT can’t reach your ThingsBoard.
  • The integration adds its HTTP Push output to the LORIOT application and waits for its start. If LORIOT refuses the start, like for a wrong login, the command removes the integration and its converter again, exits with code 2, and names the output that it may have left in LORIOT.
  • Use --token-secret with a secret that holds an API token of the application instead of --login and --password-secret. Use --manual-output to add the HTTP Push output yourself, for a LORIOT plan without API access or when the application has no free output.
Terminal window
tb secret set <name> # store a key; it asks for the value without showing it
tb secret set <name> --env-file secrets.env # take the value from the <name>= line of the file
tb secret list # list the names of the secrets
  • tb secret set stores a value under a name or replaces it, and never prints the value. Use --stdin to read the value from standard input.
  • With --env-file, the command takes the value from the <name>= line of the file. If the line has no value, the command writes the line, and creates the file if needed, then exits with code 2. Paste the value after = and run the command again.
  • tb secret list shows the names only, never the values.

Add --format json to any of these commands for scripts and AI agents.

The integration is not running
  • The Things Stack: The API key is wrong or revoked, or it belongs to another application. Generate a new key on the MQTT integration page of this application and store it again. With --username and --address, check that both come from the same application.
  • LORIOT: The password has changed, or the application has as many outputs as your plan allows. Store the new password, or create the integration with --manual-output.
No device appears in ThingsBoard

No message reached ThingsBoard. Open the live data of the end device in the console of the network server:

  • No uplink messages: The device has not joined. Check its keys, DevEUI, JoinEUI, and AppKey, as you registered them. Check that the gateway is online in the console and that the device is on and in range.
  • Uplink messages arrive: For The Things Stack, check that the integration is the one of this application. For ChirpStack, check the address of the HTTP integration and that ChirpStack reaches ThingsBoard. For LORIOT, check the outputs of the application.
The device sends, but its values are not decoded

The device shows only rssi, snr, fCnt, and data. With The Things Stack, the payload formatter is not set, or you set it after the device joined: the next message is decoded. With ChirpStack and LORIOT, the agent reads the errors of the converter, tests a fixed decoder with the real bytes of the device, and replaces the decoder.

The device got a generic device profile

With The Things Stack, the message came without the model of the device. Simulate uplink in the console always sends such a message. The messages of a device that you registered from the LoRaWAN Device Repository carry its model. A device that you added manually needs a payload formatter that adds the model, or a new registration from the Repository.

The integration of the package decodes another model

In ChirpStack and LORIOT, one application holds devices of one model. If an integration with the name from the package decodes another model, the install exits with code 2. It suggests the integration that this model already uses, or a free name. For a free name, create another application in the network server for the new model.

  • Downlinks: The integration only receives data from the devices. Commands to the devices come in a later release.
  • Devices of a solution: Connecting the real devices to the devices of an existing solution comes in a later release. The real devices get their own names in ThingsBoard, and the agent offers a dashboard for them.
  • Several models in one ChirpStack or LORIOT application: One application holds devices of one model for now. Register devices of another model in another application.