Has someone linked TTN with Thingsboard?

I have two LoRaWAN gateways connected to TheThingsNetwork with several node sensors and I would like to manage everything from a single platform like thingsboard.io. I have been reviewing different connection options such as HTTP or even creating a Thingsboard gateway to connect by MQTT but without success.

Can someone give me a clue how to start?

I have TTN data now arriving on ThingsBoard, using node-red. There are a few aspects I am still working on, but basically if you follow this guide

https://techink.site/node-red-thingsboard/

you should be able to publish data.

Here is a simple mqtt-config.json for ThingsBoard IoT Gateway which will subscibe to TTN’s mqtt broker. This allows for direct device communication from TTN > Thingsboard IoT Gateway. Devices for your application will be created automatically in ThingsBoard.

Example shows a TTN app named ttn-example-app. Devices in this example return temperature and humidity. Valid types are string, boolean, double or long.

{
  "brokers": [
    {
      "host": "us-west.thethings.network",
      "port": 1883,
      "ssl": false,
      "retryInterval": 3000,
      "credentials": {
        "type": "basic",
        "username": "ttn-example-app",
        "password": "ttn-account-v2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"        
      },
      "mapping": [
        {
          "topicFilter": "+/devices/+/up",
          "converter": {
            "type": "json",
            "filterExpression": "",
            "deviceNameJsonExpression": "${$.dev_id}",
            "attributes": [
              {
                "type": "string",
                "key": "hardware_serial",
                "value": "${$.hardware_serial}"
              }
            ],
            "timeseries": [
              {
                "type": "long",
                "key": "humidity",
                "value": "${$.payload_fields.humidity}"
              },
              {
                "type": "double",
                "key": "temperature",
                "value": "${$.payload_fields.temperature}"
              }
            ]
          }
        }
      ]
    }
  ]
}

edit: one important note - the gateway insists that all values defined are reported in every message, so make sure your TTN decoder is kicking out humidity and temperature in every message or it won’t be processed. This is pretty annoying behavior and I’m actively looking for a suitable workaround. The problem has been addressed in this commit, but is not yet available in the current 1.2.1 release.

3 Likes

Allright after some struggles I have successfully built ThingsBoard master and ThingsBoard Gateway develop/1.2.2 which fixes the issue mentioned above, where the JSON parser fails to work unless all fields are present in all packets.

Here is the build process that worked for me:
Build host: Ubuntu 17.10, no less than 8GB RAM (failed w/ 2GB and 4GB)



sudo apt-get update && sudo apt-get upgrade -y
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer
sudo apt-get install -y maven
git clone https://github.com/thingsboard/thingsboard.git
cd thingsboard
mvn clean install
sudo dpkg -i application/target/thingsboard.deb
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
cd ..
git clone https://github.com/thingsboard/netty-mqtt
cd netty-mqtt
mvn clean install
cd ..
git clone -b develop/1.2.2  https://github.com/thingsboard/thingsboard-gateway
cd thingsboard-gateway
mvn clean install
sudo dpkg -i target/tb-gateway.deb
sudo systemctl daemon-reload
sudo systemctl start thingsboard

You’ll then need to run through the configuration steps here: https://thingsboard.io/docs/iot-gateway/getting-started/#step-3-gateway-provisioning

And then you can run sudo systemctl start tb-gateway to have a working configuration.

Once you have the releases built I have found that this platform works well on a 2GB system for small/demo environment use. Simply copy the build packages (.deb|.rpm|.exe) to your target server and deploy as normal. For my testing, I built the packages on a local Ubuntu VM then deployed to a 2GB system on Azure for not much money at all. Works well so far!

3 Likes

Please, could you tell me whether thingsboard gateway allows to send downlink messages to the node?

For the Professional Edition, see https://thingsboard.io/docs/user-guide/integrations/ttn/

1 Like

Hi,

I have done the TTN integration in Thingsboard. I have registered a device in TTN and simulated some uplink message. This has created a device in Thingsboard. How this happened? and what is the use of access token of the device and how it will be used?

Thank you.

Hello, Did you managed to make downlink working to?

Hi Bhi,

Did you manage to get it working
DAt

My Thingsboard-gateway mqtt.json for TTN:

{
  "broker": {
    "name":"Default Local Broker",
    "host":"eu.thethings.network",
    "port":1883,
    "clientId": "ThingsBoard_gateway",
    "security": {
      "type": "basic",
      "username": "ttn_app",
      "password": "ttn-account-v2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
  },
  "mapping": [
    {
      "topicFilter": "+/devices/+/up",
      "converter": {
        "type": "json",
        "deviceNameJsonExpression": "${$.dev_id}",
		"deviceTypeJsonExpression": "gps",
        "timeout": 60000,
        "attributes": [
          {
            "type": "string",
            "key": "model",
            "value": "${sensorModel}"
          },
          {
            "type": "string",
            "key": "${sensorModel}",
            "value": "on"
          }
        ],
        "timeseries": [
          {
          "type": "double",
          "key": "Latitude",
          "value": "${$.payload_fields.Latitude}"
          },
          {
          "type": "double",
          "key": "Longitude",
          "value": "${$.payload_fields.Longitude}"
          },
          {
          "type": "double",
          "key": "BatV",
          "value": "${$.payload_fields.BatV}"
          }
        ]
      }
    }
  ]
}

Next time you post, please format it for readability.

Is this a working config? Or does it not work, if so what is the problem?

Are you aware that you replied to a post from 2018??

@megandai - there is a special place in Dante’s Circle for those that delete posts around another one.