MQTT IoT messaging protocol
IoT Protocol · ISO/IEC 20922 · 9 min read

MQTT — IoT Messaging Protocol

The publish-subscribe messaging backbone of modern IoT. How MQTT fits into smart home and building automation alongside KNX, DALI, and Home Assistant.

home/temphome/pvhome/motionautomatizācijalietotneierakstiMQTTbrokerpub / sub · QoSPublishersSubscribers

What is MQTT?

MQTT (Message Queuing Telemetry Transport) is a lightweight publish-subscribe messaging protocol originally designed for satellite links in the 1990s (IBM/Eurotech). Today it's the dominant protocol for IoT device-to-server communication — from ESP8266 sensors to industrial PLCs.

Unlike KNX (bus-based) or Modbus (master/slave), MQTT uses a broker model: devices publish messages to topics on a central broker (e.g. Mosquitto), and any subscriber listening to that topic receives the message. No direct device-to-device communication.

Core concepts:

  • Broker: Central server that routes all messages (Mosquitto, HiveMQ, EMQX). In smart home = runs on HA server or separate Pi.
  • Topic: Hierarchical string path, e.g. home/livingroom/light/state
  • Publish: A device sends a message to a topic
  • Subscribe: A client listens to a topic and receives all messages published to it
  • Retained message: Broker stores last value — new subscribers get it immediately
  • QoS 0/1/2: At most once / At least once / Exactly once delivery guarantee

MQTT specification

ParameterValue
StandardISO/IEC 20922 (MQTT 3.1.1), MQTT 5.0
TransportTCP/IP (port 1883) or TLS (port 8883)
TopologyStar (broker-centric)
DirectionBidirectional publish/subscribe
PayloadAny binary/text — typically JSON or plain value
Topic separator/ (forward slash), e.g. home/floor1/room2/temp
Wildcard (single level)+ (plus), e.g. home/+/light
Wildcard (multi-level)# (hash), e.g. home/#
QoS 0Fire and forget — no delivery guarantee
QoS 1At least once — receiver ACKs (may duplicate)
QoS 2Exactly once — 4-way handshake
Retained messagesBroker stores last message per topic
Will messageSent by broker if client disconnects unexpectedly
AuthenticationUsername/password, TLS certificates
Port (unencrypted)1883
Port (TLS)8883

MQTT in smart home — the ecosystem

MQTT is the common language of DIY and semi-professional smart home. Several large projects use it as their transport layer:

Zigbee2MQTT

zigbee2mqtt.io

Translates Zigbee radio telegrams to MQTT. Connect a Zigbee coordinator (CC2530, SkyConnect) to HA, run Zigbee2MQTT, and 2,500+ Zigbee devices appear as MQTT topics. No Philips Hue hub needed.

Tasmota / ESPHome

tasmota.github.io

Open-source firmware for ESP8266/ESP32 modules. Flash a cheap Sonoff relay with Tasmota and it becomes an MQTT-publishing smart switch. ESPHome is HA-native.

Home Assistant MQTT integration

home-assistant.io

HA can publish and subscribe to any MQTT topic. Configure via YAML or UI. MQTT Discovery auto-creates HA entities when a device announces itself via a specific topic.

Node-RED

nodered.org

Flow-based visual programming that subscribes to MQTT topics, applies logic, and publishes to other topics or KNX/HTTP endpoints. Often used alongside HA for complex routing.

WirenBoard

wirenboard.com

Russian DIN-rail controller uses MQTT as its primary protocol. WirenBoard publishes all sensor readings and accepts control via MQTT topics. Works with HA and Node-RED.

Topic structure examples

Example MQTT topic tree (smart home)

home/
├── livingroom/
│   ├── light/state          → "ON" / "OFF"
│   ├── light/brightness     → "75"  (0-100%)
│   ├── light/color_temp_k   → "3000"
│   ├── temperature          → "21.5"
│   └── occupancy            → "true" / "false"
├── kitchen/
│   ├── light/state          → "ON"
│   └── humidity             → "45"
├── bedroom/
│   ├── blind/position       → "75"  (0=open, 100=closed)
│   └── thermostat/setpoint  → "20.5"
└── panel/
    ├── meter/power_w        → "1247"
    └── meter/energy_kwh     → "1852.3"

MQTT vs KNX — when to use which

AspectMQTTKNX TP
InfrastructureIP network (Ethernet/WiFi)Dedicated TP bus cable
ReliabilityDepends on network + broker uptimeDeterministic, bus is always on
LatencyMilliseconds (IP) + broker roundtrip<50ms (direct bus telegram)
ScalabilityUnlimited (horizontal scaling)255 addresses per line, 15 lines max
Setup complexityLow (broker + publish/subscribe)High (ETS programming, addressing)
Hardware costLow (ESP8266 = €2)High (KNX actuator = €50–200+)
CertificationNone requiredKNX certified + ETS license
Works without server❌ Broker must be running✅ Local bus works without server
Best use caseSensor data, IoT integration, flexible DIYSafety-critical control, commercial building
Typical userMaker, HA integrator, IoT developerElectrical engineer, DALI/KNX specialist

The real answer: In a well-designed premium installation, KNX handles hardware control (switching, dimming, shutter) and MQTT/IP handles sensor data aggregation and software integrations (energy monitoring, presence, weather). They're complementary — not competing.

KNX + MQTT integration options

Home Assistant (KNX + MQTT integrations)

Both KNX and MQTT integrations run in HA. Automations can read MQTT sensor values and trigger KNX actuators — or vice versa. Zero additional hardware.

knx-mqtt-bridge (open source)

Standalone Node.js service that bridges KNX group addresses to MQTT topics bidirectionally. Each KNX GA maps to an MQTT topic. Runs on Pi or Docker.

Node-RED KNX + MQTT nodes

node-red-contrib-knx + MQTT nodes. Visual flow programming: MQTT topic → transform → KNX telegram. Good for complex conditional routing.

WirenBoard WB-MGW gateway

WirenBoard gateway unit can translate between RS-485/Modbus devices and MQTT. Then HA reads MQTT and publishes to KNX. Common in Eastern EU.

KNX + MQTT architecture designed for your project

We integrate MQTT sensor networks with KNX control panels — Zigbee2MQTT, energy meters, HVAC sensors — all unified in one system.

Request a quote →
Loading...
Back to top