Publish MI-8 Data to ThingsBoard

Published on Jan 31, 2023 | Last updated Apr 2, 2023 | Technical Articles

ThingsBoard Cloud is a commercial hosting service for the open-source ThingsBoard IOT platform. It provides a central database to publish, query, and display recorded sensor data from devices from numerous vendors, including the FusionDAQ MI-8. ThingsBoard Cloud combines scalability and fault tolerance to ensure your data is is never lost. Whether you need to manage one device or ten thousand, ThingsBoard can be a great place to start.

Create ThingsBoard Device

The first step in integrating FusionDAQ devices into ThingsBoard is to create a ‘Device’ within the ThingsBoard dashboard. There should be a one-to-one relationship between physical devices such as the MI-8 and ThingsBoard devices.

Create a ThingsBoard Cloud account if you haven’t already. Once you have, log into the ThingsBoard Dashboard and Click on the ‘Home’ link on the left menu bar. Scroll down to ‘Device management and click on ‘Devices’

Next, select the ‘All’ Device group and then click on the + button to create a new ThingsBoard device.

The ‘Add new device’ window should appear and allow you to customize the new device. The device ‘Name’ is the only field that should be modified. The exact name isn’t significant and isn’t needed to configure the MI-8. The name is solely used to identify the data within the ThingsBoard platform. Use the existing ‘default’ device profile and click the ‘Add’ button.

Now that the new device is created, click the three dot button for that device in the ‘All: Devices’ window then select ‘Manage Credentials’

The Device Credentials window will then display the Access token for the given device. This access token is what links the MI-8 DAQ to a specific ThingsBoard device. Each ThingsBoard device has a unique HTTP/HTTPS URL they use to post their data to ThingsBoard. This access token is part of that URL.

Configure the MI-8

Once you have an access token you can configure the MI-8. All MI-8 DAQs are configured through a file in the root directory of their SD card named config.json. The MI-8 User manual contains detailed information for making changes to this file, but for this example we will focus on the name and push fields. These are the fields which describe how to connect to ThingsBoard or any other service.

MI-8 config.json file used in this example

The name field is optional in this file. This name is displayed on the MI-8 OLED screen and is sent to ThingsBoard as a device attribute. Best practice is for the name in config.json to match the name of the device in ThingsBoard, but this doesn’t have to be the case. The name field isn’t used to associate telemetry data between the MI-8 and ThingsBoard. It is only meant as an aid for the user.

The push field describes the connection to the ThingsBoard servers. In this example we use HTTP POST requests (“mode”:”post”). MQTT is also supported by ThingsBoard, but POST consumes less cellular data. The HTTP request URL is built up through the server, port, use_ssl, and path/attributes_path fields.

Things board telemetry (sensor data) requests are sent to HTTP://thingsboard.cloud:80/api/vi/{ACCESS_TOKEN}/telemetry

The use_ssl field describes whether HTTP or HTTPS is used. The server field is everything between the double slashes ‘//’ and the colon. Next comes the port and one additional slash. Everything beyond that is the path.

Set server to “thingsboard.cloud”. Username and password should remain empty.

Set path to “api/vi/{ACCESS_TOKEN}/telemetry” and set attributes_path to “api/vi/{ACCESS_TOKEN}/attributes”. Replace {ACCESS_TOKEN} with the access token from the device credentials page in ThingsBoard. Each device has an unique access token. Sensors values will be sent to path periodically, attributes (name, IMEI, ICCID, etc) are sent to attributes_path once when the MI-8 first powers up.

Set push_attributes equal to true so that attributes (things such as the MI-8 IMEI number which don’t change frequently) are sent once each power up.

Set port equal to 80 and use_ssl equal to false to use an unsecured HTTP connection to push data to ThingsBoard. Set port equal to 443 and use_ssl equal to true to use SSL encryption (HTTPS). Either protocol is supported, but HTTPS will consume more cellular data each time data is pushed to the server.

Set use_json equal to true. All data sent to ThingsBoard should be formatted as JSON to simplify integration.

Set use_headers false. HTTP headers are not required by ThingsBoard and require additional cellular data each push.

Finally set include_name, include_imei, and include_iccid to false. These fields cause the ICCID, IMEI, and MI-8 name to be included in the telemetry pushes which would consume additional cellular data. They do not need included here since they are already sent to ThingsBoard in a separate attributes HTTP request once per MI-8 power cycle.

Save config.json, disconnect the PC from the MI-8 USB port (if connected and mass-storage enabled), and then power cycle the MI-8 so new settings take affect.

Verify MI-8 Connection within ThingsBoard

At this point the MI-8 should be configured and ready to communicate with ThingsBoard. Return to the ThingsBoard Dashboard and then navigate to Device Groups and then All. Click on the device that was just associated with the MI-8 and then navigate to the ‘Latest Telemetry’ tab. All sensor values configured in the active MI-8 trigger (see operating manual) should be present once the MI-8 powers up and is able to establish a cellular connection. Note that GPS values are only transmitted after the first GPS fix, which could take several minutes depending on how long it has been and how far the MI-8 has moved since the last fix. GPS values (lat, lon and alt) will only appear in the telemetry window after they have been transmitted at least once.

Now, navigate to the ‘Attributes’ tab. Attributes are additional data sent from the MI-8 to ThingsBoard that are more or less fixed and do not change such as the modem IMEI, the SIM ID (ICCID), and the MI-8 firmware version. Attributes are only sent to ThingsBoard once each time the MI-8 is powered on.

Conclusion

ThingsBoard is a great option to consider for managing data from IOT devices such as the FusionDAQ MI-8. ThingsBoard is designed to be scalable, which means that it can handle large amounts of data from a large number of devices. This scalability is important if you plan to expand your IoT deployment over time, as it ensures that the platform can continue to handle the growing volume of data without any performance issues.

Another benefit of ThingsBoard is the platform’s flexibility and customizability. You can tailor the platform to meet your specific needs, including creating custom dashboards, widgets, and rules. This allows you to create a user experience that is tailored to your specific use case, without being limited by the features provided by the platform out of the box. Overall, ThingsBoard is a powerful and flexible platform for hosting your IoT data, and provides the features, scalability, and flexibility needed to create a robust and customized IoT solution.