Multi - MQTT communication with CodeSys

Hi there all,
I am busy with MQTT. I would like to know how i could use multiple mqtt communication direct with codesys. Let’s say that i need my plc to listen to more topic on diferent brokers with different credentials. I tried WagoAppCloud but there is no option to set different ip to extern MQTT Broker. So if i set it up in WBM i will get only one option.
Any Ideas ?

Hello Tomast,
So you can also use the Codesys IIoT Libraries SL, if you use the newest Firmware the license is part of the Wago PFC.

1 Like

Hi @Michael,
Thx for reply. I will check this one - i tought i needed to pay extra for this license. Does it work on PFC and CC100 or only pfc?

It Works on all Wago PLCs

tested this yesterday on the CC100. I was able to install the libraries, but unfortunately, I didn’t succeed in establishing communication using my MQTT credentials. I received a “not authorized” error, even though the same credentials work perfectly in Python script

Is there any other manual or tutorial available? I think (or actually, I know) I’m doing something wrong.

Hello,
Are you using plain MQTT or MQTT over encrypted communication ?
Maybe you have a certificate problem.

Hi, I use MQTT without tls. I’ve managed to get it working. There is one thing: i got over a few hours an issue with MQTTSubscribe: everything was OK without any errors but i he stopt with picking new data up. i needed to restart the plc to get it working again. MQTT Client - Connected to Broker - TRUE , sbuscrbie active - true

I’ve created a Function Block Diagram (FBD) that includes one MQTTClient FB responsible for handling communication with the broker. Under this main block, I have 12 instances of the MQTT.MQTTSubscribe FB.

All the MQTTSubscribe blocks are enabled when MQTT.MQTTClient.xConnectedToBroker is TRUE. This setup works quite well for MQTTSubscribe_0 through MQTTSubscribe_8, but the remaining MQTTSubscribe instances return an ERROR = TIME OUT. anyone an idea?