IBH Link UA:MQTT connection
- 1 MQTT Connection
- 1.1 Configuration of the MQTT connection
- 1.2 Further parameters in the MQTT server configuration
- 1.3 Configuration of the Topics
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.
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:
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.
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.
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.
Connection to Amazon AWSIoT
For the AWS IoT connection, copy the contents of the above certificate files into the XML file. Username and password are not required.
Further parameters in the MQTT server configuration
Last Will Message
The IBH Link UA can tell the broker what should happen if the connection aborts unexpectedly.
Saving of MQTT Messages
<MQTTConfiguration> <MQTTServer . . MaxBufferedMessages=1000 PersistDir="mqttpersist" . >
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!)
This parameter can contain "0", "1" or "2". Attention! Not all MQTT brokers support all levels.
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)
Example: deadband="0.1" : Only if a change in variable > 0.1 the variable is transferred.
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
A variable is defined as follows:
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:
The following information is possible as variable type:
- "DateTime" (ISO 8601 string format: "YYYY-MM-DDThh:mm:ss")
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.
A structure is constructed with <struct> </ struct>. Any interleaving is possible.
Connecting variables to external OPC UA server variables
The OPC UA server must be set up with the client function.
Please refer:: IBH_Link_UA:Client_functions#Add_Server