I am just trying out the MQTT Client SL library after installing the CODESYS IIoT Libraries into ctrlX PLC.
I am using Cedalo MQTT broker installed in my ctrlX CORE at port 8883.
From ctrlX PLC, I have successfully connected to the MQTT Broker using the MQTTClient function block.
So my next attempt is to subscribe to a mqtt topic by using the MQTTSubscribe function block.
The topic in this case is a "Temperature" topic that was already published to the mqtt broker from a sensor.
My attempt is to retrieve the message from the topic in ctrlX PLC.
According to the FB description, the input wsTopicFilter is a WSTRING(1024) data type.
However after adding the MQTT Subscribe FB and downloaded to PLC, I got the error at the output of the MQTTSubscribe FB:
VAR_OUTPUT MQTTSubscribe.eMQTTError : MQTT_Error --> TOPIC_FILTER_EMPTY
Can anyone help?
Solved! Go to Solution.
The topic in MQTT is the name of the variable you want to retrieve.
This name can contain wildcards, therefore I the FB parmater is called TopicFilter.
In your screenshoot you just provide an empty string "" which makes no sense.
Therefore you get the error message, which exactly points you to the problem.
Hi, thank you for your feedback. Yes you are right.
I managed to find the solution when I referred to the example MQTT Client SL FB with the visualization.
Everything works now. Since the MQTTClient and MQTTSubscribe variables are available in the Data Layer, I brought it up to webiq and created a similar hmi which now can be accessed using a tablet pc/iPad.