QoS 0 and 1
QoS 0 is an ordinary letter — posted, and never heard of again if the connection drops with it. QoS 1 is registered mail, posted again until a receipt comes back, so it arrives at least once, and sometimes twice.
QoS, quality of service, is how hard MQTT tries to deliver a message. There are three levels. This lesson is the two you will use.
The connection underneath MQTT, TCP, already resends lost pieces of data. What it cannot survive is the connection itself going down — Wi-Fi drops, a router restarts — with a message on its way. That is what QoS is about.
QoS 0: an ordinary letter
The sender posts the message and forgets it. No receipt comes back. If the connection drops while it is on its way, it is gone, and neither the sender nor the broker knows it was ever sent.
For a temperature posted every thirty seconds that is fine: a lost reading is replaced by the next one. QoS 0 costs one packet, and it is the right default for readings.
QoS 1: registered mail
The sender keeps a copy until the receiver sends back a receipt, a packet called PUBACK. If the connection drops before the receipt arrives, the sender connects again, keeping its session, and sends its copy again, marked DUP to say it may be a repeat.
So a QoS 1 message gets there. But if the message arrived and only the receipt was lost, the receiver now has it twice. QoS 1 means at least once.

Commands that are safe twice
Because a QoS 1 message can arrive twice, write commands so that twice does no
harm. heater = off twice leaves the heater off. heater = toggle twice turns
it back on. Send the state you want, not the change to make.
Common mistakes
- QoS 1 on every reading. It doubles the packets and buys nothing when the next reading is thirty seconds away.
- Toggle commands. A duplicate undoes them. Send
onoroff. - Expecting QoS to survive a reboot. The copy the sender keeps is in its memory. A board that restarts has lost it, whatever the QoS.
Edit this page — content/fundamentals/mqtt/qos-0-and-1.mdx
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.