Connect Devices via MQTT

About MQTT

MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as a lightweight publish/subscribe message transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth.

The protocol is based on the publish/subscribe model (also known as Pub/Sub) and consists of 4 main components:

  1. Publisher: A publisher is a source of messages. It sends messages to specific "topics" in the network. Topics are named channels or categories that identify the type of message. For example, a weather station sensor could publish data to the "Weatherdata" topic.

  2. Subscriber: A subscriber receives messages by subscribing to specific topics. It indicates which topics it is interested in and then receives the corresponding messages from publishers who send messages to these topics.

  3. Broker: An MQTT broker is a server that receives all messages from the publishers and then forwards the messages to the corresponding subscribers. The broker is the heart of the MQTT protocol.

  4. Topics are like channels or categories under which messages are grouped. Publishers send messages to specific topics, and subscribers receive messages by subscribing to topics. For example, topics could be subjects like "Sensor Data/Temperature", "Messages/Warnings", or "Control Commands/Light".

Procedure

Devices are connected via MQTT in the following steps:

  1. First, a connection to a broker is created and configured.

  2. On this broker, a subscription to a specific topic is created.

Internal Broker Version: mosquitto version 2.0.11 Client Version: MQTT 3.1/3.1.1 proto

Last updated