|
ThingsBoard PE Feature Only ThingsBoard Professional Edition supports Platform Integrations feature. See ThingsBoard PE Installation Options to install ThingsBoard PE. |
This tutorial will show how to send data to external MQTT broker using knob control widget.
Let’s assume your device is controlling temperature and you would like to use it as an external MQTT broker with the help of Thingsboard.
In this tutorial we will configure ThingsBoard Rule Engine to automatically send messages using MQTT protocol. You can use this tutorial as a basis for much more complex tasks.
MQTT Integration allows to convert existing protocols and payload formats to ThingsBoard message format and is useful in several deployment scenarios:
Please review the integration diagram to learn more.
We assume you have completed the following guides and reviewed the articles listed below:
We will operate with Temperature sensor device that has name “Thermostat-A” and type “thermostat” which will be automatically created in the process of integration work.
In order for integration to work, downlink and uplink converters should be created.
You can check them like this:
Uplink converter should look like this:
Downlink converter should look like this:
For integration to work a remote server should be used. In this case you can use iot.eclipse.org for your MQTT data. Integration should look like this:
Field | Input Data |
Name | Thermostat MQTT integration |
Type | MQTT |
Debug mode | False |
Uplink data converter | Sensor Uplink Converter |
Downlink data converter | Sensor Downlink Converter |
Host | iot.eclipse.org |
Port | 1883 |
Connection timeout(sec) | 10 |
Client ID | (empty) |
Clean session | True |
Enable SSL | False |
Credentials | Anonymous |
Topic filters | devices/Thermostat-A/temperature/latest |
QOS | At most once |
Topic filters | devices/Thermostat-A/temperature/settings/ |
QOS | At most once |
Downlink topic pattern | ${topic} |
Description | (empty) |
Metadata | (empty) |
Download and import attached json file with a dashboard for this tutorial.
In order for widget to work without a real device, emulator should be turned on.
First, you should check if node, npm and npm module mqtt are installed by using following commands:
#to display node version
node -v
#to display npm version
npm -v
#to display npm mqtt module version
npm list mqtt
If you don’t have npm, you can install it from here, and npm MQTT module with following command:
sudo npm install mqtt --save
and node from here.
Download the file and run it with following command to launch device emulator:
node mqtt-downlink-virtual-device.js
Note: device emulator should be put in the folder where node-modules is situated.
Using a control widget (in this case, a knob) leads to value change on the dashboard.
Dashboard can be found here and imported like this.
In this section, we explain the purpose of each node in this tutorial.
Node A: Originator attributes enrichment node
Node B: Script Transformation Node
Node C: Integration Downlink node
You can download and import attached json file with a rule chain for this tutorial. It should be marked as root.
入门指南 - 这些指南提供了ThingsBoard主要功能的快速概述。
安装指南 - 了解如何在各种操作系统上安装ThingsBoard。
设备连接 - 了解如何根据您的连接方式或解决方案连接设备。
数据看板 - 这些指南包含有关如何配置复杂的ThingsBoard仪表板的说明。
数据分析 - 了解如何使用规则引擎执行基本的分析任务。
硬件样品 - 了解如何将各种硬件平台连接到ThingsBoard。
高级功能 - 了解高级ThingsBoard功能。
开发指南 - 了解ThingsBoard中的贡献和开发。