📄 MQTT Devices

MQTT Devices


MQTT is a popular lightweight pub/sub IoT protocol. It is different from regular OT protocols because, instead of communicating directly between devices, you’re communicating with an intermediate server called the broker. You can publish messages to the broker, and you can subscribe to messages onto the broker. The message ‘address’ is called a topic. The ‘value’ is, usually, a JSON Payload. We have fully integrated MQTT in EnvisionSCADA so that you can turn this into regular variables. 

You still need a broker. We recommend Mosquitto (Open Source), ActiveMQ or HiveMQ. In the future we plan on implementing a MQTT server in EnvisionSCADA itself. For debugging we recommend MQTT Explorer, which is a client itself that allows to easily see what’s happening on the MQTT Server. 

Note that we do not support certificates yet. Everything is ready for it, and it is on our roadmap. If you need it sooner, contact us, and we'll make it happen. 

Please check https://mqtt.org/ for more information.

MQTT Clients

The MQTT client is the driver client that connects to the MQTT Broker. You will need to specify the URL to an existing MQTT broker on the network.

Go into the menu and click on the menu Item MQTT Clients.


Here you can add, edit, and remove MQTT Clients. This means that EnvisionSCADA can connect to multiple brokers at the same time. The following properties are available:

Property Description
Name The name of the MQTT Client.
Broker URL The URL of the broker.
Port The port of the broker, 1883 is the default port in MQTT.
Timeout Timeout between the client and the broker.
Retry The time between retrying to reconnect.
Username The Username, if configured on the broker.
Password The Password, if configured on the broker.

MQTT Devices

Click the devices icon next to the MQTT Client to add devices coming from this client connection with the broker.

Here you can add, edit, and remove MQTT Devices. The following properties are available:

Property  Description
Name The name of the device.
Template See chapter Templates.
Timeout (in seconds) The individual timeout of each device. If the client does not receive any data from any of the variables from this device, the device and its variables will be marked offline. Depending on whether this is a sensor within the same building that publishes every 5 minutes, or a remote sensor that only communicates every hour, you need to configure the right timeout here. 
Description Free description for your own information.

Click the list icon next to the gear to add variables to this device.


MQTT Variables

Here you can add, edit, and remove MQTT Variables. The following properties are available:

Property Description
Name The name of the device.
Asset See chapter Assets.
PublishTopic When you write a variable, the system will send it to the broker with this topic.
Note that you can use the placeholders {DeviceName} and {VariableName}
SubscribeTopic When you want to receive a variable from the broker and put its value in this variable, you can specify its subscribe topic here. This only works in case that the subscribe topic is unique for each variable, for example Warehouse\CO2meter1\CO2. Many devices work with one publish and subscribe topic, and the variable name is mentioned in the payload (JSON). In this case, you may use the same publish and subscribe topic for the different variables, and proceed to Settings to further configure this variable, see below. 
Note that you can use the placeholders {DeviceName} and {VariableName}.
Description Description for the device.

Click the settings gear icon to open more settings. 

Property Description
Identity In Message If the name of the variable (identity) is used as a key in the JSON payload, and not in the topic, enable this. The system will search for a matching Variable Name as a key in the JSON payload to match the message with the variable. 
TimeStamp Key If a key matches this name, then it will use this as the timestamp for the received variable.
Value Key Note that you can use the placeholder {VariableName}.
Publish Format If this is left empty, when writing the value will be published as a raw value. You can specify a format here. This can be a json format, but also something else. The example above will send a JSON and will replace {VariableValue} with the value being sent. The following replacers are also supported: 
{DeviceName}
{VariableName}
{TimeStamp}
The timestamp will always be sent in the international UTC standard format for example 2023-07-12T13:14:15Z

For information about the other common variable settings, see article Variable Settings.