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".

Subscription

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".

Notification