All paths

MQTT in depth

Topics and wildcards, QoS, retained messages and last wills, a broker of your own, Home Assistant discovery and security, built as real code on the Raspberry Pi, and two devices that talk only through the broker.

Raspberry Pi 4 Model BFree7 lessons6 h4 chapters2,962 XPEmbedded engineering · Advanced+250 XP

0 of 7 done

What you will build

3 projects, built step by step

7 lessons in 4 chapters, about 6 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.

Chapter 1 project

QoS 0, 1 and 2

The three delivery promises on a link that loses packets: fire and forget, at least once with its duplicates, and exactly once with its four-packet handshake, each counted in packets.

Open it in the simulator
Chapter 2 project

A broker on the board

Your broker becomes a module, and a real button and LED become clients: the button publishes, an automation decides, the lamp obeys and reports its state, and a dashboard that joins late still knows.

Open it in the simulator
Chapter 3 project

Security

Lock the broker down: usernames and passwords with the real CONNACK codes, access lists that limit each client to its own topics, credentials out of the code, hashed passwords, and what TLS on port 8883 adds.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

The rules of the broker

How topics match, and what each QoS promises on a link that loses packets.

  1. Open303 XP

    Topics and wildcards

    How a broker sorts messages: topic levels, the + and # wildcards written as a real matching function, which filters are legal, and a watcher that lights an LED when its filter matches.

    0 of 7 steps

  2. ProjectLocked606 XP

    QoS 0, 1 and 2

    The three delivery promises on a link that loses packets: fire and forget, at least once with its duplicates, and exactly once with its four-packet handshake, each counted in packets.

    0 of 7 steps

Chapter 2

State that lasts

Retained messages, last wills, keepalives, and a broker module of your own.

  1. Locked326 XP

    Retained messages and the last will

    Build a broker that keeps the last value of a topic for whoever subscribes later, clears it on an empty payload, and publishes a client's last will when it drops off or misses its keepalive.

    0 of 7 steps

  2. ProjectLocked530 XP

    A broker on the board

    Your broker becomes a module, and a real button and LED become clients: the button publishes, an automation decides, the lamp obeys and reports its state, and a dashboard that joins late still knows.

    0 of 6 steps

Chapter 3

Real systems

Home Assistant discovery, and locking the broker down.

  1. Locked326 XP

    Home Assistant discovery

    Announce devices to Home Assistant with retained JSON on discovery topics: a temperature sensor and a button appear on their own, survive a restart, go unavailable through the last will, and disappear on an empty config.

    0 of 7 steps

  2. ProjectLocked606 XP

    Security

    Lock the broker down: usernames and passwords with the real CONNACK codes, access lists that limit each client to its own topics, credentials out of the code, hashed passwords, and what TLS on port 8883 adds.

    0 of 7 steps

Chapter 4

Boss project

Two devices that only meet through the broker.

  1. Locked265 XP

    Boss: two devices over MQTT

    A switch device and a lamp device that only meet through the broker: last wills and birth messages, a command and a retained state, an automation between them, a dashboard on wildcards, and a room of your own.

    0 of 6 steps

Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

The rules of the broker

  1. Topics and wildcardsHow a broker sorts messages: topic levels, the + and # wildcards written as a real matching function, which filters are legal, and a watcher that lights an LED when its filter matches.
  2. QoS 0, 1 and 2The three delivery promises on a link that loses packets: fire and forget, at least once with its duplicates, and exactly once with its four-packet handshake, each counted in packets.
Chapter 2

State that lasts

  1. Retained messages and the last willBuild a broker that keeps the last value of a topic for whoever subscribes later, clears it on an empty payload, and publishes a client's last will when it drops off or misses its keepalive.
  2. A broker on the boardYour broker becomes a module, and a real button and LED become clients: the button publishes, an automation decides, the lamp obeys and reports its state, and a dashboard that joins late still knows.
Chapter 3

Real systems

  1. Home Assistant discoveryAnnounce devices to Home Assistant with retained JSON on discovery topics: a temperature sensor and a button appear on their own, survive a restart, go unavailable through the last will, and disappear on an empty config.
  2. SecurityLock the broker down: usernames and passwords with the real CONNACK codes, access lists that limit each client to its own topics, credentials out of the code, hashed passwords, and what TLS on port 8883 adds.
Chapter 4

Boss project

  1. Boss: two devices over MQTTA switch device and a lamp device that only meet through the broker: last wills and birth messages, a command and a retained state, an automation between them, a dashboard on wildcards, and a room of your own.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About MQTT in depth

Is MQTT in depth free?

Yes. All 7 lessons of MQTT in depth are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi 4 Model B?

No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does MQTT in depth take?

About 6 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: QoS 0, 1 and 2, A broker on the board and Security.

Where do I start?

With "Topics and wildcards", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.