MQTT Publish
This function block is designed to publish messages to an MQTT broker. It allows users to specify broker parameters, topic, and message contents, enabling straightforward data communication.
📥 Inputs
Enable
This boolean input enables or disables the publishing action.
Data
This generic input allows users to send any data type to be published to the specified MQTT topic.
📤 Outputs
This function block does not produce any outputs.
🕹️ Controls
Broker Address
Input field for specifying the MQTT broker address.
Port
Input field for specifying the port to connect to the MQTT broker (default is 1883).
Topic
Input field for defining the MQTT topic to which messages will be published.
Username
Input field for the broker’s username, if authentication is required.
Password
Input field for the broker’s password, if authentication is required.
Quality of Service
Dropdown menu to specify the QoS level for message delivery (options are 0, 1, or 2).
Keep alive (s):
Input field for the keep-alive interval.
Retain
A switch to choose whether or not the published message should be retained by the broker.
🎨 Features
Easy Configuration
Users can quickly configure MQTT broker settings and messaging parameters through the user interface.
Dynamic Connection Handling
The block automatically reconnects to the MQTT broker when parameters change.
Error Logging
Informative log messages provide feedback on the connection status and data publishing success.
📝 Usage Instructions
Set Broker Address and Port: Enter the MQTT broker address and port number.
Define Topic and Auth Credentials: Specify the topic for publishing and, if required, the username and password.
Adjust Parameters: Set the Quality of Service (QoS) level and specify the keep-alive duration as needed.
Connect and Enable: Enable the block and connect it to data inputs to start publishing.
Monitor Logs: Check logs for connection status and success message on data publishing.
📊 Evaluation
When run, this function block sends the provided data to the specified MQTT topic, logging success or any potential errors encountered during the process.
💡 Tips and Tricks
🛠️ Troubleshooting
Last updated