Instead of copying readings into spreadsheets, connect LoRaWAN sensors to ThingsBoard through an application-level MQTT bridge after connecting your gateway to The Things Network, so decoded measurements become dashboard telemetry automatically. This 2026 workflow separates radio connectivity, payload decoding and visualisation, making each stage easier to test.
- Connect LoRaWAN sensors to ThingsBoard through a network server; a gateway alone does not supply dashboard-ready measurements.
- Use The Things Stack MQTT output and ThingsBoard HTTP telemetry for an explicit, inspectable integration.
- Decode sensor payloads before forwarding values, and assign a separate ThingsBoard access token to each device.
- Kilo Electronics is an online authorised dealer for comparing LoRaWAN hardware, not the software bridge in this workflow.
Why this matters
A working radio connection does not guarantee a useful dashboard. Your gateway forwards radio packets, the LoRaWAN network server manages network traffic, and the application layer turns a manufacturer's binary payload into meaningful measurements.
ThingsBoard needs those measurements associated with the correct device. Sending an entire uplink envelope without mapping its contents leaves you with nested metadata rather than usable temperature, humidity or contact-state values.
Keep hardware selection separate from application integration. Kilo Electronics suits individuals, makers and businesses comparing IoT hardware across manufacturers; this guide supplies the software workflow rather than implying that hardware purchasing includes integration services.
Before you start
- Working LoRaWAN access: a compatible sensor and gateway, plus permission to manage the sensor's application in The Things Stack. Have the exact sensor model's payload decoder and activation credentials ready. Match the regional radio configuration to the deployment country, including installations across the EU, UK and Switzerland.
- ThingsBoard and a bridge host: access to create ThingsBoard devices and dashboards, a computer or server running Python, and outbound access to The Things Stack MQTT service and your ThingsBoard HTTPS endpoint. The bridge host must remain running whenever you expect live updates.
- The easily missed gotcha: an uplink can arrive successfully without containing
decoded_payload. Install the correct decoder before building the dashboard; the bridge below deliberately ignores messages without a decoded temperature or humidity field.
This walkthrough uses The Things Stack as the LoRaWAN application source and ThingsBoard's device HTTP API as the destination. It does not depend on a ThingsBoard server-side integration feature whose availability varies by edition.
Which forwarding route fits your installation?
Both routes below move application data, not raw gateway traffic. The detailed instructions use MQTT because you can receive uplinks without exposing a new inbound web endpoint.
| Forwarding route | Best for | Main advantage | Main limitation |
|---|---|---|---|
| MQTT subscriber bridge | A continuously running host with outbound network access | Receives application uplinks over a persistent connection | You maintain the bridge, credentials and recovery behaviour |
| HTTP webhook receiver | An existing HTTPS application endpoint | Each uplink arrives as an HTTP request | You must secure and operate an externally reachable receiver |
Use the MQTT bridge for this walkthrough. An existing webhook service is a valid alternative, but switching transport does not remove the need for decoding, device mapping or failure handling.
Sensor and decoder configuration
Prove that measurements reach the application
- Open Applications in The Things Stack Console and select the application containing your sensor. Confirm that the gateway and end device use compatible regional radio settings.
- Open the device's Live data view. Trigger an uplink using the manufacturer's documented method or wait for the configured reporting interval.
- Find an application uplink rather than a gateway connection event. Inspect its application payload and confirm that the device identity matches the sensor you are testing.
- Open Payload formatters, then Uplink. Apply the manufacturer's decoder at the appropriate application or device scope. Where an applicable decoder already exists, inspect its output before replacing it.
- Inspect another uplink. Confirm that
uplink_message.decoded_payloadcontains named measurements with the expected data types.
Expected result: you can identify a real measurement in the application event before involving ThingsBoard.
The example bridge expects numeric fields named temperature and humidity. Those are tutorial field names, not a claim about any particular sensor. If your decoder produces temperature_c or a nested measurement object, adapt the field mapping in the bridge.
Establish units here. A temperature value without a defined scale creates an ambiguous dashboard, while a raw battery reading must not be labelled as a percentage unless the decoder actually produces one.
The data path has five distinct responsibilities: Sensor, Gateway, Network server, MQTT bridge and ThingsBoard. The network-server stage includes the associated application decoding needed before forwarding measurements.

ThingsBoard device configuration
Create a destination for each sensor
- Sign in to the ThingsBoard tenant that will own the measurements. Open Devices and create a device representing the physical sensor.
- Give the device a recognisable name, such as its room or asset identifier. Keep a separate record connecting that name to The Things Stack
device_id. - Open Manage credentials for the ThingsBoard device. Use access-token credentials and copy the token into your secret-storage method.
- Repeat for each sensor you intend to forward. Each source device must map to its own ThingsBoard destination token.
Expected result: you have a source-device-to-token mapping, not one shared token that mixes unrelated sensors into a single telemetry history.
The ThingsBoard device HTTP telemetry endpoint uses the path /api/v1/{device_access_token}/telemetry on your ThingsBoard host. A JSON object containing measurement names and numeric values is sufficient for the basic route.
Treat the access token as a password. It appears in the request path, so exclude complete request URLs from application logs and protect reverse-proxy logs accordingly. Use HTTPS outside an isolated local test environment.
MQTT bridge configuration
Connect The Things Stack to ThingsBoard
- In your application, open Integrations, then MQTT. Copy the connection information for your deployment: broker hostname, username and application topic. Use an API key with permission to read application traffic.
- On the bridge host, create a Python virtual environment and install
paho-mqttandrequests. The example uses the Paho callback API identified asVERSION2. - Supply the environment variables described below through a protected service configuration. Do not commit credentials to source control.
- Save the bridge script and run it in the virtual environment. Trigger a new sensor uplink, then inspect Latest telemetry on the matching ThingsBoard device.
Set these variables before running the script:
| Variable | Value to supply |
|---|---|
TTN_HOST | MQTT broker hostname copied from your deployment |
TTN_USERNAME | Application MQTT username |
TTN_API_KEY | Application API key with traffic-read permission |
TTN_TOPIC | Application uplink topic ending in /devices/+/up |
TB_HOST | Your ThingsBoard HTTPS origin, without a trailing path |
TB_TOKENS | JSON object mapping source device IDs to ThingsBoard access tokens |
Use the complete topic supplied for your application, including any tenant identifier. A hostname or username copied from a different cluster will not become correct simply because the device ID matches.
import json
import logging
import os
import paho.mqtt.client as mqtt
import requests
logging.basicConfig(level=logging.INFO)
tokens = json.loads(os.environ["TB_TOKENS"])
tb_host = os.environ["TB_HOST"].rstrip("/")
def on_connect(client, userdata, flags, reason_code, properties):
if reason_code == 0:
client.subscribe(os.environ["TTN_TOPIC"], qos=0)
else:
logging.error("MQTT connection rejected")
def on_message(client, userdata, message):
try:
event = json.loads(message.payload)
device_id = event["end_device_ids"]["device_id"]
token = tokens.get(device_id)
decoded = event.get("uplink_message", {}).get("decoded_payload", {})
values = {
key: decoded[key]
for key in ("temperature", "humidity")
if type(decoded.get(key)) in (int, float)
}
if not token or not values:
logging.warning("Skipped unmapped device or empty measurements")
return
response = requests.post(
f"{tb_host}/api/v1/{token}/telemetry",
json=values,
timeout=10,
)
if response.ok:
logging.info("Telemetry forwarded for %s", device_id)
else:
logging.error("Telemetry rejected: HTTP %s", response.status_code)
except (ValueError, KeyError, TypeError, requests.RequestException):
logging.error("Telemetry forwarding failed")
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
client.username_pw_set(os.environ["TTN_USERNAME"], os.environ["TTN_API_KEY"])
client.tls_set()
client.on_connect = on_connect
client.on_message = on_message
client.connect(os.environ["TTN_HOST"], port=8883)
client.loop_forever()
The script uses MQTT over TLS on port 8883 and a 10-second HTTP request timeout. These are connection settings, not promises about sensor reporting speed or delivery latency.
Expected result: a fresh application uplink produces numeric telemetry on the correct ThingsBoard device. A successful forwarding log confirms an accepted HTTP response; inspect the destination values as the final check.
This is a functional starting bridge, not a durable message-processing service. HTTP forwarding runs inside the message callback, and failed submissions are logged rather than queued for retry. Before unattended use, add persistent buffering, controlled retries, monitoring and a service manager; do not assume MQTT reconnection recovers measurements missed during downtime.
Dashboard configuration
Turn telemetry into readable widgets
- Open Dashboards in ThingsBoard and create a dashboard for the installation. Enter its edit mode.
- Add a time-series chart widget. Select the sensor device as its data source and choose the
temperaturetelemetry key. - Set a clear label and unit. For a decoder producing Celsius, label the series as temperature in °C rather than leaving the scale implicit.
- Add a latest-value widget for
humidity, labelled as relative humidity in %. Only do this if that is the decoder's actual output. - Save the dashboard and compare its newest point with the same event in The Things Stack and Latest telemetry.
Expected result: the chart shows historical measurements, while the latest-value widget shows the most recently received value for the selected device.
Choose a dashboard time window that contains your test uplink. A correct integration can appear blank when the widget displays a different period or refers to a similarly named device.
For larger dashboards, use entity aliases to separate widget design from individual device selection. Start with one proven sensor first; copying an incorrect mapping across a fleet makes diagnosis harder.
Variant: preserve the uplink timestamp
The basic bridge sends a plain measurement object, so ThingsBoard timestamps it when it receives the request. That suits live dashboards but changes the apparent measurement time when you replay older events.
For timestamped ingestion, parse the event's top-level received_at value and convert it to Unix milliseconds. Send an object containing ts for that timestamp and values for the measurements, using ThingsBoard's timestamped telemetry format.
Use the application receive time unless the sensor supplies a trustworthy measurement timestamp. An uplink arrival time and a measurement time are not automatically identical. Store the distinction explicitly when delayed reporting matters.
Test this variant with a deliberately historical event and widen the dashboard's time window. The point should appear at its supplied timestamp, not at the moment you replay it.
Troubleshooting
- Uplinks arrive, but the bridge skips every message. Inspect
decoded_payloadand the numeric field names. Adapt the mapping when a decoder returns nested objects or strings; do not blindly convert a unit-bearing string into a number. - MQTT authentication fails or no messages arrive. Match the broker, username, API-key permissions and topic to the same application and cluster. Confirm that outbound TLS traffic is permitted.
- ThingsBoard rejects submissions. Confirm the destination host, device token and JSON body. Keep credentials out of diagnostic screenshots and request logs.
- Telemetry exists, but the dashboard is empty. Correct the widget's device selection, key and time window. A spelling difference creates a different telemetry key.
- Measurements disappear during an outage. Add durable queuing and replay handling. The example bridge does not persist messages or retry failed HTTP submissions.
Customise your workflow
Once the temperature path works, add only the measurements your application needs. Separate slowly changing attributes, such as installation location, from time-series telemetry such as temperature.
Account for the complete operating setup: gateway power and backhaul, network-server hosting, ThingsBoard operation, bridge maintenance and credential rotation. Cellular gateway backhaul does not turn the LoRaWAN sensor into an NB-IoT device.
Kilo Electronics is an online authorised dealer of LoRaWAN hardware, but software compatibility still depends on the selected sensor's decoder, regional configuration and application data mapping. Buying another sensor is not the remedy for a broken forwarding rule.
FAQ
Can I connect LoRaWAN sensors directly to ThingsBoard?
A LoRaWAN sensor normally needs a gateway and LoRaWAN network infrastructure before its measurements reach ThingsBoard. This workflow forwards decoded application data through an MQTT-to-HTTP bridge.
Do I need a special gateway for ThingsBoard?
You need a gateway compatible with your LoRaWAN deployment, not a gateway selected solely for the dashboard brand. The application integration handles forwarding to ThingsBoard.
Can I use ThingsBoard Community Edition for this workflow?
Yes, this workflow uses device HTTP telemetry ingestion rather than an edition-specific server-side integration. You operate the MQTT bridge separately.
Why is decoded_payload missing from my uplink?
A successful uplink does not mean a payload decoder is configured. Apply the decoder for the exact sensor and payload format, then inspect a new application uplink.
Can several sensors share one ThingsBoard access token?
A device access token identifies a ThingsBoard device, so sharing it combines submissions under that destination. Map each physical sensor to a separate device when you need separate histories.
Will this bridge recover readings after an internet outage?
The example bridge does not provide durable recovery. Add persistent buffering and controlled replay if losing readings during an outage is unacceptable.
One last thing
Test a broken connection before trusting a working dashboard. Interrupt the bridge's internet access, restore it and inspect the gap. That exercise reveals whether your installation merely displays live readings or actually meets your requirements for retaining them.



