%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#E67E22'}}}%%
flowchart LR
A["Pub/Sub Basics"] --> B["Quality of Service"]
B --> C["Security"]
C --> D["Advanced Topics"]
D --> E["Practice"]
style A fill:#16A085,color:#fff
style B fill:#16A085,color:#fff
style C fill:#E67E22,color:#fff
style D fill:#E67E22,color:#fff
style E fill:#2C3E50,color:#fff
1200 MQTT Fundamentals
1200.1 MQTT - Message Queue Telemetry Transport
MQTT is the de facto standard for IoT messaging, enabling millions of devices to communicate efficiently through a publish-subscribe pattern. This chapter series provides comprehensive coverage of MQTT concepts, from basic pub/sub mechanics to advanced security and optimization.
MQTT decouples message producers (publishers) from consumers (subscribers) through a central broker. Sensors publish data to topics, applications subscribe to topics they care about, and the broker handles all routing. The three QoS levels (0: fire-and-forget, 1: at-least-once, 2: exactly-once) let you trade off between reliability and overhead based on your application’s needs.
1200.2 Chapter Overview
This comprehensive guide to MQTT is organized into focused chapters:
| Chapter | Focus | Difficulty | Time |
|---|---|---|---|
| Publish-Subscribe Basics | Topics, wildcards, broker architecture | Beginner | 25 min |
| Quality of Service | QoS levels, reliability vs overhead trade-offs | Intermediate | 20 min |
| Security | TLS, authentication, access control | Intermediate | 15 min |
| Advanced Topics | Packet structure, topic design, MQTT 5.0 | Intermediate | 20 min |
| Practice and Exercises | Hands-on labs, pitfalls, resources | Intermediate | 30 min |
1200.3 Learning Path
Recommended sequence:
- Start with Pub/Sub Basics - Understand the publish-subscribe pattern, topics, and wildcards
- Learn QoS Levels - Master reliability vs overhead trade-offs
- Study Security - Configure TLS, authentication, and access control
- Explore Advanced Topics - Packet structure, topic design patterns, MQTT 5.0
- Complete Practice Exercises - Build hands-on skills and avoid common pitfalls
1200.4 Why MQTT?
The Problem: Traditional request-response patterns (like HTTP polling) don’t scale for IoT:
- N devices x M polls/hour = billions of wasted requests
- Servers must track every device connection
- Devices waste energy checking for messages that aren’t there
The Solution: Publish-subscribe messaging with a central broker:
- Decouple senders from receivers
- Store messages for offline devices
- Push instead of poll
- Scale to millions of devices
1200.5 MQTT at a Glance
| Feature | Description |
|---|---|
| Pattern | Publish-Subscribe (via broker) |
| Transport | TCP (port 1883) or TLS (port 8883) |
| Message Size | Up to 256 MB (typically KB) |
| QoS Levels | 0 (fire-forget), 1 (at-least-once), 2 (exactly-once) |
| Key Features | Retained messages, Last Will, Session persistence |
| Protocol Versions | 3.1.1 (2014), 5.0 (2019) |
1200.6 Quick Reference: When to Use MQTT
Choose MQTT when:
- You need publish-subscribe (one-to-many communication)
- Devices send frequent updates (every few seconds to minutes)
- Multiple subscribers need the same data
- Network is unreliable (automatic reconnection, QoS guarantees)
- Battery-powered devices need efficient persistent connections
Choose CoAP instead when:
- You need request-response (client-server pattern)
- RESTful APIs are required (GET/POST/PUT/DELETE)
- UDP is acceptable (lower overhead than TCP)
Choose HTTP instead when:
- Integration with web services is primary goal
- Infrequent communication (hourly/daily updates)
- Large payloads (firmware updates, images)
1200.7 Prerequisites
Before starting this series:
- Basic Networking Concepts: TCP/IP, client-server architecture
- IoT Reference Architectures: IoT system layers and components
- Basic programming knowledge (Python, C++, or JavaScript)
1200.9 Start Learning
Ready to begin? Start with MQTT Publish-Subscribe Basics to understand the core concepts that make MQTT the leading IoT messaging protocol.