Skip to main content

MQTT Publish and Subscribe

Loading...

This example shows how to use MQTT (Message Queuing Telemetry Transport) protocol to establish a publish-subscribe messaging pattern for IoT and cloud applications. You'll learn how to:

  • Set up MQTT client connections
  • Publish messages to specific topics
  • Subscribe to topics and handle incoming messages

Perfect for building real-time notifications, IoT device communication, or any application requiring lightweight message distribution across multiple clients.

In this example, we have set up MQTT subscribing to one topic named "topic1".

AppBlocks Editor view for MQTT subscription configuration, at the bottom-right there is a button to add MQTT topics

In the application, we publish to the topic "topic1" when the "MD" button is pressed, and utilize the "On MQTT Notification" block to handle received data whenever the device receives a notification from the broker on "topic1".

Applications tab of AppBlocks editor view, showcasing the use of MQTT protocol for publishing and subscribing to topics.