# 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.&#x20;

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

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 messages. For example, a weather station sensor could publish data to the topic "weather data".
2. **Subscriber**: A subscriber receives messages by subscribing to specific topics. It specifies which topics it is interested in, and then receives the corresponding messages from publishers that send messages to these topics.
3. **Broker (manager):** 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.&#x20;
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 include subjects such as "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. A subscription to a specific topic is created on this broker.

{% hint style="warning" %}
All steps in this document assume that a properly functioning broker is available. This document does not explain how to configure a broker.
{% endhint %}

{% hint style="info" %}
Internal broker version: mosquitto version 2.0.11\
Client version: MQTT 3.1/3.1.1 proto
{% endhint %}
