TheThingsIndustries Integration

ThingsBoard PE Feature

Only ThingsBoard Professional Edition supports Platform Integrations feature.

See ThingsBoard PE Installation Options to install ThingsBoard PE.


TheThingsIndustries is LoRaWAN network designed for connecting your devices using LoRaWAN stack. After integrating TheThingsIndustries with the ThingsBoard, you can connect, communicate, process and visualize data from devices in the ThingsBoard IoT platform.

TheThingsIndustries setup

Register Application

The first step is to create an application in TheThingsIndustries console. Go to console by , open Applications section, press add application button and fill required fields.

  • Application ID - thingsboard-integration


Payload Decoder

Our device submits data in binary format. We have 2 options where to decode this data:

  • TheThingsIndustries decoder - data will be decoded before entering the ThingsBoard
  • ThingsBoard converters - uplink/downlink converters will be used to decode data from binary format into JSON

In this tutorial, we will make an initial transformation into JSON with TTI decoder and then use ThingsBoard converters for correct data processing. In real life scenario, it is up to you where to decode/encode data, because it is possible to do this on any side.

After application registered in TTI, go to Payload formatters, Uplink select decoder function. We will take the first byte as a temperature value from a device and transform it into JSON.

Decode Function

function Decoder(bytes, port) {
  var decoded = {temperature: bytes[0]};
  return decoded;

Output json:

  "temperature": 2


Press Save payload function

Device Registration in TheThingsIndustries

Next step is a Device creation in the TTI. Open End devices page and press Add end device

  • Device ID - thermostat1.
  • DevEUI - unique device identifier.

  • Press Network layer settings button.


  • Select configuration for your device.


  • Press Application layer settings button.

Fill the AppSKey by generation button.

Press Add end device button.

Integration with the ThingsBoard

We need to create Integration on The Things Industries, to do this open Integrations - MQTT and press Generate new API key. Copy username and password we will need it later.


Now we can start configuring the ThingsBoard.

First, we need to create Uplink Data converter that will be used for receiving messaged from the TTI. The converter should transform incoming payload into the required message format. Message must contains deviceName and deviceType. Those fields are used for submitting data to the correct device. If a device was not found then new device will be created. Here is how payload from TheThingsIndustries will look like:

  "end_device_ids": {
    "device_id": "thermostat1",
    "application_ids": {
      "application_id": "thingsboard-integration"
    "dev_eui": "ABABABABABABABAA",
    "join_eui": "0000000000000000",
    "dev_addr": "270000BC"
  "correlation_ids": [
  "received_at": "2020-08-11T08:59:45.869225403Z",
  "uplink_message": {
    "session_key_id": "BXGsg614fdmYH7efd+fRvA==",
    "f_port": 2,
    "f_cnt": 23787,
    "frm_payload": "AhJF8HTI3khf",
    "decoded_payload": {
      "temperature": 2
    "settings": {
      "data_rate": {}
    "received_at": "2020-08-11T10:08:31.505981496Z"

We will take device_id and map it to the deviceName and application_id map to the deviceType. But you can use another mapping in your specific use cases. Also, we will take the value of the temperature field and use it as a device telemetry.

Go to Data Converters and create new uplink Converter with this function:

var data = decodeToJson(payload);
var deviceName = data.end_device_ids.device_id;
var deviceType = data.end_device_ids.application_ids.application_id;

var result = {
    deviceName: deviceName,
    deviceType: deviceType,
    telemetry: {
         temperature: data.uplink_message.decoded_payload.temperature

function decodeToString(payload) {
    return String.fromCharCode.apply(String, payload);

function decodeToJson(payload) {
    var str = decodeToString(payload);
    var data = JSON.parse(str);
    return data;

return result;


For sending Downlink messages from the ThingsBoard to the device inside TTI, we need to define downlink Converter. In general, output from Downlink converter should have the following structure:

  "downlinks": [{
    "f_port": 2,
    "frm_payload": "vu8=",
    "priority": "NORMAL"
  • contentType - defines how data will be encoded {TEXT | JSON | BINARY}
  • data - actual data that will be sent to the device in TTI. More details about API can be found in this TTI API
  • metadata - in this object you should place correct devId (device id) value that will be used to identify target device in TTI

Go to Data Converters and create new downlink Converter with this function:

var data = {
        downlinks: [{
            f_port: 2,
            confirmed: false,
            frm_payload: btoa(msg.version),
            priority: "NORMAL"

var result = {
    contentType: "JSON",
    data: JSON.stringify(data),
    metadata: {
        devId: 'thermostat1'

return result;

This converter will take version field from the incoming message and add it is a payload field in the outbound message. Destination device is a thermostat1 device.


TTI Integration

Next we will create Integration with TheThingsIndustries inside the ThingsBoard. Open Integrations section and add new Integration with type TheThingsIndustries

  • Name: TTI Integration
  • Type: TheThingsIndustries
  • Uplink data converter: TTI Uplink
  • Downlink data converter: TTI Downlink
  • Region: eu1 (region where your application was registered inside TTI)
  • Username: thingsboard-integration@thingsboard (use Username from TTI integration)
  • Password: use Password from TTI integration




Lets verify our integration.

When device sends data, we can check it in the ThingsBoard, to do this:

Go to Device Group -> All -> thermostat1 - you can see that

  • new device was registered in the Thingsboard with name “thermostat1”
  • In the Latest Telemetry section you will see that last submitted temperature = 2.


For testing Downlink Messages, we will update our Root Rule Chain to send downlink message when device attribute is changed. Open and edit Root Rule Chain. Add Integration Downlink Action node and connect it with the Message Type Switch Node using relation Attributes Updated



Save Changes.

Go to Device Group -> All -> thermostat1 -> attributes section. We will add Shared attribute with name version and value v.0.11


By making this step, we triggered downlink message to the device thermostat1 and this message should contains version field value.
Open TTI Console, navigate to thingsboard-integration application, to the section Data.
And we see that Downlink message was received (It is displayed as bytes 76 2E 30 2E 31 31).


See also

With this integration you can also configure Downlink converters and trigger required actions using Rule Engine nodes.

Next steps

  • 入门指南 - 这些指南提供了ThingsBoard主要功能的快速概述。

  • 安装指南 - 了解如何在各种操作系统上安装ThingsBoard。

  • 数据看板 - 这些指南包含有关如何配置复杂的ThingsBoard仪表板的说明。

  • 数据处理 - 了解如何使用ThingsBoard规则引擎。

  • 数据分析 - 了解如何使用规则引擎执行基本的分析任务。

  • 硬件样品 - 了解如何将各种硬件平台连接到ThingsBoard。

  • 高级功能 - 了解高级ThingsBoard功能。

  • 开发指南 - 了解ThingsBoard中的贡献和开发。