Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

One of the many cloud services that you can use to monitor information that is sent by an MQTT publisher is Thingsboard. This article will demonstrate how to configure both Thingsboard and RouterOS to publish the data using the MQTT protocol. RouterOS, in this scenario, is going to act as a gateway and publish the data from the RouterBoard to the Thingsboard's server. Thingsboard, in this scenario, will act as an MQTT broker (server, where data will be posted).

...

Warning

Please consider using SSL MQTT (TCP port 8883 and certificates), instead of non-SSL MQTT (TCP port 1883). If you use non-SSL MQTT, the communication between the client (MQTT publisher) and the server (MQTT broker) can be easily sniffed/packet captured, and the that will compromise authentication data (such as client ID-ids, username, usernames and passwordpasswords) will be compromised.

Thingsboard configuration

...

  • Change the "address" to the actual IP/domain address of your ThingsBoard server;
  • Change the "certificate" selected to the actual client certificate name that you've imported;
  • Make sure to use "port=8883" (the MQTT SSL port that the server is listening to);
  • Make sure to enable "ssl=yes".

MQTT Publish

a) A quick MQTT publish test with a static value:

Code Block
languageros
/iot/mqtt/publish broker="tb" topic="v1/devices/me/telemetry" message="{\"cpu\":\"7\"}"

b) In order to publish relevant data from the RouterOS to the Thingsboard, you can use the script shown below as a reference. The script collects the data from the RouterOS device (model name, serial number, RouterOS version, current CPU, used memory, free memory, and uptime) and publishes the message (the data) to the broker in the JSON format:

...