MQTT

This sample demonstrates how to set up a publisher and subscriber based on OPC UA Pub/Sub MQTT. The sample solution contains a TwinCAT project that includes the following PLC configuration:

The I/O configuration includes an OPC UA RT Device with two publishers and two subscribers:

MQTT 1:

Creation of the subscribers

The subscribers have been created automatically based on the Configuration import/export. We highly recommend using this exchange format wherever possible.

How to start the sample

Please make sure that your system meets the system requirements.

Before you activate the TwinCAT project, please make sure that you have an MQTT Message Broker running locally on the same system. The message broker should listen on port 1883/tcp without any encryption or user authentication. Please note that this is only for demonstration purposes! Please adapt this configuration to your environment. The MQTT settings can be found on the OPC UA RT device.

MQTT 2:

You can then activate the TwinCAT project and login to the PLC projects to debug the PLC runtime. You should see that the subscriber PLC project receives data (which is published by the other PLC project).