
This provides an introduction to the course content.
In this module, you will learn how MQTT helps IoT devices communicate efficiently and reliably. You will explore the MQTT publish/subscribe model and practice working with topic structures and wildcards. You will also learn how MQTT Quality of Service (QoS) levels impact message delivery, when to use clean versus persistent sessions, and how retained messages ensure new subscribers receive important data right away. By the end of this module, you will have a solid understanding of how to apply MQTT concepts in real-world IoT scenarios.
This video shows how MQTT can be used in a Smart Home application.
It uses a smart home simulation program Smart Home I/O
Sensors in the home send their data over MQTT to the EMQX broker on different topics
The EMQX broker then sends the data to Kafka via the Rule Engine and Kafka integrator.
The home owner presses commands on their remote which sends commands via MQTT to the EMQX broker. The EMQX Rule Engine will interpret the commands and send a command back to the home to the correct actuator. i.e. door, gate, light, etc. This command data is also forwarded to Kafka.
The Smart Home acts as a gateway between the sensors and actuators in the home and the EMQX broker. So, there is only one MQTT connection from the Smart Home to the EMQX broker.
This will allow you to deep dive into MQTT 3.1.1 but studying the packet exchanges between the clients and the broker for different MQTT scenarios.
Introduction to the different MQTT 3.1.1 labs in this course.
The following resources are the step-by-step instructions for all the lab exercises.
Lab Files
MQTT_Fundamentals_Lab.pdf contains the lab exercise instructions
MQTT_Fundamentals_Lab_ref.txt contains text used in the labs that you can copy/paste
In this section, you will install and setup the software used in this course.
MQTTX will be used to create MQTT clients that will connect to the public EMQX broker.
You will setup three clients that will used throughout all of the exercises in this course.
While not the focus of the course, you can also see how to connect clients using one-way TLS.
Wireshark will be used to view the MQTT packets that are sent between the clients and the broker
In this section, you will examine the client connect, disconnect, ping related packets.
In this exercise, you will explore the different features of MQTTX using different publish and subscribe scenarios including using wildcard subscriptions and retained messages.
In this exercise you will see the difference between a clean session client and a persistent session client. You will see how for persistent session clients, the broker will store its topic messages and deliver them when it comes back online.
In this section, you will examine the packet exchanges between the publisher and broker and the broker and subscriber for the different quality of service levels, QoS 0, QoS 1 and QoS 2.
In this section, you will examine what happens when the message publish QoS level is different than the subscribe QoS level.
The EMQX public broker is configured to deliver the messages to the subscribers as the minimum of the publish QoS level and subscribe QoS level.
You will verify this.
In this exercise you will test the Last Will message.
Last Will messages can be a bit tricky to test because they are only sent when a client disconnects ungracefully, such as during a loss of power.
They are not sent when a client disconnects normally using a Disconnect packet.
To test this, you will shut down an MQTTX instance. This immediately terminates the TCP connection, allowing the EMQX broker to detect the disconnect right away, without waiting for the Keep Alive timer to expire.
Course conclusion
MQTT is everywhere: IoT, real-time dashboards, industrial systems, and event-driven architectures.
In this course, you will learn MQTT the right way: by using real clients, a real MQTT broker, and real packet captures to see exactly what’s happening under the hood.
You’ll work hands-on with MQTTX clients connected to the EMQX public broker, while using Wireshark to trace and decode MQTT packets in real time. This approach helps you visualize how MQTT actually works on the network, not just how it’s described in slides.
By the end of this course, you won’t just use MQTT, you’ll understand the packets and handshake involved in MQTT communication.
What you’ll learn:
Core MQTT concepts: clients, brokers, topics, sessions, and keep-alive
The focus is on MQTT 3.1.1
Publishing and subscribing with MQTTX using a live EMQX public broker
QoS levels QoS 0, QoS 1 and QoS 2 explained through actual packet traces
Know how to choose the right QoS level for your application
CONNECT, CONNACK, PUBLISH, SUBSCRIBE, and DISCONNECT packets — decoded packets in Wireshark
How clean sessions, persistent sessions, and retain messages really work
Common MQTT pitfalls and how to recognize them in Wireshark
How to debug MQTT issues using packet-level visibility