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.