Learn how to integrate LoRaWAN® data from the RAK gateway built-in Network Server into ThingsBoard using MQTT for quick, cost‑effective IoT setups. This guide explains how to integrate application data from the built-in Network Server (NS) of the RAK gateway into ThingsBoard, a popular open-source IoT platform, using the MQTT protocol.
By utilizing the built-in NS, users can bypass the complexity and cost associated with deploying a separate LoRaWAN network server. This solution is ideal for small-scale industrial deployments that require low latency, minimal infrastructure, and a quick setup.
In this example, a public MQTT broker, HiveMQ, is used to bridge the data between the RAK gateway and ThingsBoard.
Prerequisites
Before you begin, ensure the following prerequisites are met:
- A LoRaWAN gateway running WisGateOS 2
- An active ThingsBoard account (either Cloud or Community Edition)
- The gateway must have Internet access (via Ethernet, Wi-Fi, or cellular).
- A basic understanding of LoRaWAN and MQTT protocols
- At least one LoRaWAN node device (e.g., a WisBlock node or any compatible sensor)
Configure the RAK Gateway
Set Gateway Work Mode and Add Device
Before proceeding, ensure that your gateway is configured to use the built-in LoRaWAN network server and your node has been added to an application.
For detailed instructions, refer to the WisGateOS User Manual.
Configure MQTT Integration
- Navigate to LoRa® > Configuration > Integration Interface Parameters in the gateway’s Web UI.
- Enable the Integration Interface option and select Generic MQTT as the Integration mode.
- Configure the following MQTT parameters:
- MQTT Broker Address: Enter the hostname of your MQTT server. Example: broker.hivemq.com
- MQTT Broker Port: 1883
- Set up the topic fields according to your application and device configuration.
- Click Save changes to apply the configuration.
Configure the ThingsBoard
- Log in to your ThingsBoard instance. If you don't have an account, create one before proceeding.
- After successfully logging in, you will be taken to the ThingsBoard homepage.
- Click Integration Center > Data Converters in the left navigation tree to create a data converter for the uplink.
- Click the icon
+and choose the Create new converter option.
In the configuration interface, keep the Converter type set to Uplink (default). Select MQTT for the Integration type, enter a name for the decoder in the Name field (e.g., Uplink Decoder), and then choose JS (JavaScript) for the decoding configuration.
- Paste your device-specific decoder script into the code editor, then click Add to save.
The script below is for reference only. Please adjust it according to your device’s payload format.
/** Decoder **/
// decode payload to string
var payloadStr = decodeToString(payload);
var data = JSON.parse(payloadStr).data;
var bytes = atob(data).split('').map(function (c) {
return c.charCodeAt(0);
});
var values = {};
let i = 0;
while (i < bytes.length) {
var channelId = (bytes[i] << 8) | bytes[i + 1];
var value = (bytes[i + 2] << 8) | bytes[i + 3];
i += 4;
switch (channelId) {
case 0x01BE:
values.wind_speed = value / 100;
break;
case 0x02BF:
values.wind_direction = value;
break;
case 0x0367:
values.temperature = value / 10.0;
break;
case 0x0470:
values.humidity = value / 10.0;
break;
case 0x0573:
values.pressure = value / 10.0;
break;
default:
break;
}
}
var integrationName = 'MQTT Integration';
var deviceName = 'dev_ac1f09fffe08f2a9';
var result = {
deviceName: deviceName,
attributes: {
integrationName: metadata['integrationName'],
wind_direction: values.wind_direction,
wind_speed: values.wind_speed,
temperature: values.temperature,
humidity: values.humidity,
pressure: values.pressure,
},
};
/** Helper functions **/
function decodeToString(payload) {
return String.fromCharCode.apply(String, payload);
}
return result;
- Navigate to the Integration Center > Integrations menu and click the icon + to add the MQTT integration.
- Enter the name of the integration (for example, MQTT Integration) in the Name field and select MQTT from the Integration type drop-down menu. Click Next to proceed.
- In the Uplink data converter options, click Select existing to choose the previously created decoder (Uplink Decoder), and then click Next.
In the Downlink Data Converter interface, no configuration is necessary; simply click Skip to bypass this setup.
Enter the address broker.hivemq.com in the Host field, and enter the port number 1883. Click the Add Topic Filter button to configure the subscription topic.
Subscription topics:
| SUBSCRIPTION TOPIC | DESCRIPTION |
application/{{application_name}}/device/{{device_EUI}}/join |
Device join event |
application/{{application_name}}/device/{{device_EUI}}/rx |
Uplink data |
application/{{application_name}}/device/{{device_EUI}}/tx |
Downlink sent |
application/{{application_name}}/device/{{device_EUI}}/ack |
Acknowledgment of downlink |
application/{{application_name}}/device/{{device_EUI}}/status |
Device status update |
Replace application_name and device_EUI with your actual application ID and device EUI.
All topic values must be lowercase.
- Click the Add button to save and finalize the settings.
- Once the device has joined and is sending uplink data, check the uplink data in ThingsBoard > Integrations > Your Integration > Events.
Visualize Data in ThingsBoard
After successfully creating the data converter, completing the integration, and receiving uplink data (visible in the Events tab), follow these steps to visualize your device data:
- Navigate to Entities > Devices > Groups.
- Click the group named All in the Device groups menu. The device should automatically appear based on your decoder logic.
- Click on the device and go to the Attributes tab to view real-time values such as temperature, humidity, wind speed, etc.
- To visualize the data, select a specific data field (e.g., humidity) by checking the corresponding box.
- Click Show on widget.
- In the Current bundle dropdown, select a widget category (e.g., Analog gauges), then click Add to dashboard.
- In the Add Widget to Dashboard window:
- If no dashboard exists, select Create New Dashboard, then enter a name (e.g., Sensor Hub).
- Optionally, enable Open Dashboard to view it immediately after adding the widget.
If you don’t check Open Dashboard, you can later access the dashboard via Dashboard Groups - All - [Group Name].
- Click Add to save and apply the configuration.
- To visualize additional data (e.g., temperature, pressure):
- Repeat the steps above.
- When prompted, choose Select existing dashboard, then select your previously created dashboard (e.g., Sensor Hub).
Troubleshooting
| ISSUE | CAUSE | SOLUTION |
| No data in the ThingsBoard Events tab | MQTT is not connected or has wrong topic filters | Verify broker URL, port (1883), and topic format |
| Decoder returns empty values | Incorrect JavaScript logic or unexpected payload | Debug using TBEL/JS preview in ThingsBoard |
| Gateway fails to connect to MQTT | No internet access or DNS resolution failure | Check the gateway’s network and DNS settings |
FAQs
-
Can I use a private MQTT broker instead of HiveMQ?
Yes, simply replace the broker address with your own MQTT broker hostname. -
Why choose the built-in NS instead of a cloud-based LNS?
The built-in NS is ideal for quick prototyping or isolated deployments, as it reduces infrastructure requirements and simplifies installation. -
Can I perform downlink commands from ThingsBoard?
Yes, this is possible with additional configuration for a downlink decoder and appropriate topics. -
Why is my device not joining the network despite proper configuration?
Double-check the device’s EUI and AppKey, and ensure that the gateway has adequate LoRa® coverage and correct frequency settings. -
Why does the gateway show as connected but no data appears in ThingsBoard?
Check the following:
- MQTT broker connection (is the address and port correct?)
- Topic format (must match the actual application and device EUI, all in lowercase)
- Decoder script (must correspond to the device’s payload format)
- Also, ensure that the Integration Interface is enabled on the
gateway.
Changelog
-
Version 1.1 - Added UTM links
- Date Published: 09/01/2025
-
Version 1 - How to Integrate RAK WisGate Lite 2 with ThingsBoard via
MQTT
- Date Published: 08/14/2025
Updated