IBH Link UA:MQTT connection

From IBHsoftec Wiki English
Jump to: navigation, search

MQTT Connection

MQTT Overview.png

Configuration of the MQTT connection

The configuration takes place via an XML file, which is read in via the web interface under "Client". Multiple connections to different MQTT brokers can be made simultaneously.

Unsecured connection

MQTT Config Unsecure.png


MQTT Config Unsecure Example.png

An MQTT connection to the MQTT Broker (RabbitMQ) will be established on mqtt.ibhsoftec.com. In parallel, the structure "MQTT-Test" is set up in the OPC UA server with its own namespace under MQTT.

View of the MQTT structure in the UA Expert:

MQTT Address Space.png]

Secure connection

With the secure connection you copy the contents of the certificate files into the XML file. Depending on the configuration of the MQTT Broker, you can also omit username and password.

MQTT Broker Address.png

Connection to the Microsoft Azure IoT Hub

To connect to the Azure IoT Hub, you only need the AzureIoTConnectionString. The rest is anchored in the software. Note that only one topic per Azure IoT Hub is possible.

MQTT AzureIoTConnectionString.png


Copy the Connection string (primary key) shown above and replace the text – starting with HostName into the XML-Data. The XML file is inserted as shown below to connect to the Microsoft Azure IoT Hub.

MQTT Insert XML File.png

Connection to Amazon AWSIoT




MQTT AWSIoT Certificat Created.png

For the AWS IoT connection, copy the contents of the above certificate files into the XML file. Username and password are not required.

MQTT AWSIoT Configuration.png

Further parameters in the MQTT server configuration

Last Will Message

Last Will Message

The IBH Link UA can tell the broker what should happen if the connection aborts unexpectedly.

MQTT Last Will.png

Saving of MQTT Messages



The IBH Link UA can save MQTT messages during connection interruptions. This parameter specifies the maximum number of messages that can be cached.


If you insert an SD card on the back of the IBH Link UA, messages will be stored retentively on the card if this parameter is specified. In this case, no data is lost even when the machine is switched off. The parameter specifies the directory for the messages on the SD card.

Configuration of the Topics

One or more topics can be defined under Publish or Subscribe. (For Microsoft Azure IoT only 1 topic!)

MQTT Topic Configuration.png

Topic Parameters

MQTT Topic Parameters.png


Quality of Service Levels

This parameter can contain "0", "1" or "2". Attention! Not all MQTT brokers support all levels.


Retained Messages

May contain "true" or "false". Attention! Not all MQTT brokers support retain, in case of doubt omit parameters.


no Trigger defined

The variables in the topic will be transmitted individually when changed.
Constants, values from external OPC servers or values without assignment are not transmitted;

The transfer is for each variable separately.

It can be given a tolerance limit via the parameter deadband = "double val" (From firmware version 5.3)

deadband="0.1" : Only if a change in variable > 0.1 the variable is transferred.
Trigger defined

All variables are transferred at once when the trigger condition occurs.
The trigger definition consists of 3 parameters:

1. trigger_mode=rising_edge or falling_edge or value_change
2. trigger_var= Node Definition of Trigger Variables
3. trigger_sampling_interval= ms

on trigger_mode="value_change" can be given a tolerance limit via the parameter deadband = "double val" (From firmware version 5.3)


This is a byte variable for the transmission status in the OPC server.
The value is set to 1 on successful transmission or buffering, and if an error has occurred or the buffer is full, it is set to 2.
The PLC may only pass a new value at 1 and then set the value to 0.

Variables and structures


MQTT Variables Structures.png

MQTT Variables Structures UAExpert.png

A variable is defined as follows:

MQTT Variable Name.png

The variable name can be chosen freely. The variable then appears in the OPC UA server under its own namespace. Under the optional parameter "name" one can output a variable name, which contains special characters like e.g. '/'. A topic can contain any number of variables. The variables are transmitted as JSON strings via MQTT.

The above example is transmitted as follows:

MQTT Variables Structures Example.png

The following information is possible as variable type:

  1. "Boolean"
  2. "SByte"
  3. "Byte"
  4. "Int16"
  5. "Uint16"
  6. "Int32"
  7. "UInt32"
  8. "Float"
  9. "Double"
  10. "DateTime" (ISO 8601 string format: "YYYY-MM-DDThh:mm:ss")
  11. "String"
  12. "SByteArray"
  13. "ByteArray"
  14. "Int16Array"
  15. "Uint16Array"
  16. "Int32Array"
  17. "UInt32Array"
  18. "FloatArray"
  19. "DoubleArray"
  20. "StringArray"

If no opcvar is specified, the variable is not automatically described. However, the variable can be described with the client function.
A variable can also contain a constant. In this case, instead of opcvar const is specified. For fields no constant is possible.


MQTT Variable Const.png

A structure is constructed with <struct> </ struct>. Any interleaving is possible.

Connecting variables to external OPC UA server variables


MQTT Variables To External Server.png

The OPC UA server must be set up with the client function.

Please refer:: IBH_Link_UA:Client_functions#Add_Server