DL28 INTEGRATION INTO THINGSBOARD IOT PLATFORM
This tutorial will show you in great detail how to set up and integrate DL28 into ThingsBoard IoT platform. With this Decode marks the beginning of partnership with ThingsBoard as their Silver Partner.
MQTT (a lightweight messaging protocol) is based on „publish/subscribe“ principle of message exchange between clients over the broker. Distance clients are connected to the broker by using the TCP/IP protocol. Broker has a static IP address. Clients could have either static or dynamic IP address. Default port is 1883.
DL28 supports MQTT client, it can send-publish messages to the broker, and receive-subscribe messages from the broker.
TEXT and JSON message formats are supported.
DL28 disposes internal MODBUS memory map, used to collect all the data from the connected devices, meters and IO modules. These data could be readout in different ways, and this time we are explaining MQTT way.
DL28 set up
Connect to the DL28 webserver using either default parameters or adequate ones in case you have changed the default parameters.
Default setup is | IP address : 192.168.0.67 | Username : admin | Password : admin |
Set all devices, meters, IO modules that are connected to the DL28. After establishing a successful communication with each, you should have all relevant data stored in the DL28 modbus map. Form the list of data that you would like to exchange over the MQTT.
Procedure will be explained using a small example based on data collected/read from GPRS Router 343 and heat meter by using a modbus RTU and M-Bus protocols, respectively. This is shown on the below screenshots.
Setting up MQTT protocol on DL28 device for communication with ThingsBoard broker:
Enable: enable/start MQTT protocol
Enable Debug: debugging over the console, accessible over the USB0 port on DL28
Broker: link or IP address of the broker, demo.thingsboard.io in this case
Port: default value is 1883
Reconnect: time interval for reconnecting to the broker, default value is 10 seconds
Keep Alive Interval: defines the time interval for sending a PING packet for keeping the TCP/IP connection active. In case of missing RESPONSE packet the connection is reestablished. Zero value, turns it off.
Clean Session: tells the broker not to keep information about the client and undelivered messages after the connection is broken.
Client ID: is „Device ID“ given by ThingsBoard
Username: is „Access Token“ generated by ThingsBoard
Password: empty by default
Choose JSON for data format.
Save the setup by clicking on Save button.
Send MQTT message
Open the MQTT → MQTT Publish List page.
Add parameter/s from the list of data that you would like to be sent.
For purpose of writing this document we have used the state of the relays on GT-900-343 in routing regime. The state of relays on modbus RTU device are located in Input registers, address 52001. Relay states are sent to the topic „v1/devices/me/telemetry“, on value change only. (Publish->OnValueChange) for 1 (Period/Treshold).
Temperature value, read from M-Bus heat meter, is sent to topic „v1/devices/me/telemetry“, periodically on every 300 seconds.
Payload Value Prefix field should contain keywords for each data (exio_relay_1, gt900_relay_1, cal_return_temp). Keywords are arbitrary and chosen by the user to reflect the real state of the equipment from the filed, in the best way.
Save the setup.
Receive MQTT message
Open MQTT Subscribe List page.
Add parameter/s that you would like to be received.
We have added a parameter for turning the relay On and Off on modbus RTU device, GT900-343.
Memory location for the relay is within Input group of the internal modbus map registers, address 52000.
The state of the relays is changed over the „v1/devices/me/rpc/request/+“ topic.
Payload Value Prefix fields is for keywords that will represent the data (exio_relay_1, gt900_relay_1). Keywords are arbitrary and chosen by the user.
Save the changes.
After setup is finished restart the application by clicking on Restart button located on Restart → Restart Application page.
MQTT Broker
ThingsBoard broker, demo installation (https://demo.thingsboard.io), is provided either free as ThingsBoard Community edition (CE) or as a commercial account – ThingsBoard Professional edition (PE), for this purpose we are using free account.
Go to the login page and make your own account.
Username: „your e-mail address“
Password: „password“
After log-in, click on to the Devices field in the menu and then on sign + in bottom right corner. Choose the option Add New Device. Enter the name, type and description of the device and click on Add.
DL28 will show on the device list. Click on the field for DL28 device.
COPY DEVICE ID, to be added to DL28 as client number on DL28.
COPY ACCESS TOKEN, to be entered as Username on DL28 Settings page for MQTT.
Tab Attributes, contains incoming data that were sent to topic „v1/devices/me/attributes“ by DL28. This topic is reserved for receiving the static data like firmware version, serial number and similar.
Tab Latest Telemetry, contains data sent to topic „v1/devices/me/telemetry“ by DL28. This topic is meant for dynamic data like value for temperature, pressure, volume flow and similar, also for commands like turning the relay on/off.
Click on Dashboards field, in the left panel menu, then click a „+“ sign in bottom right corner and choose the Add new dashboard option. Enter the name and description for the dashboard you would like to create and click on Add.
Dashboard will be created under the given name and by clicking on it you will open it for further editing. To enter into the Edit mode click on a pencil sign shown in bottom right corner. Now you should add some appropriate widgets for data visualization.
Add new widget → Create new widget.
Choose the appropriate bundle from the list, in our case we will choose Control widgets and after that we will choose Switch Control.
Click on Entity alias and press ENTER.
Add DL28 in to the Entity alias list. Note that this should be done only once for all widgets that are tied to this specific device.
Advanced tab gives the possibility to set the values for data parameters.
Above defines that for switch ON, { “gt900_relay_1”: 1 } will be sent and for switching OFF { “gt900_relay_1”: 0 }. Data is sent to topic “v1/devices/me/request+”.
Same keyword, gt900_relay_1, is used for LED indicator.
We will need to add a widget for Return temperature data visualization. For this purpose we have chosen Digital gauges → TEMP widget. Just to remind you that this data is one in a menu that are received from heat meter over the MBus protocol.
After all settings are finished test how the relay is working by clicking on the switch „GT900 RL1“.
After all settings are finished test how the relay is working by clicking on the switch „GT900 RL1“.
More details about the used products are available on their pages and manuals that could be downloaded from download page.
Please feel free to get in touch with Decode Team if you have any additional questions.