MQTT Explained for Business IoT Projects
If you are planning a connected product, someone on the technical side has probably mentioned MQTT. It appears in almost every IoT architecture diagram, yet it is rarely explained in terms a business owner or product manager can use to make decisions.
This article gives you MQTT explained in plain language: what it is, why it suits devices with limited power and patchy networks, and how brokers, topics and quality of service levels work in real projects. By the end you should be able to follow a technical discussion, ask the right questions and spot design choices that will cause trouble later.
How MQTT works
MQTT is a lightweight messaging protocol designed for situations where devices are small, bandwidth is limited and connections drop. It was originally created for monitoring remote equipment over unreliable links, and that heritage shows in its design. Messages are compact, the protocol overhead is small and devices can keep a single long-lived connection open rather than repeatedly setting up new ones.
The key idea is publish and subscribe. Devices do not talk to each other directly. Instead, every device or application connects to a central server called a broker. A temperature sensor publishes a reading to a named channel. Any application interested in that reading subscribes to the same channel and receives it. The sensor does not need to know who is listening, and the listeners do not need to know where the sensor is.
This decoupling is what makes MQTT so practical for business systems. You can add a new dashboard, an alerting service or an ERP integration without changing a single line of device firmware. Each new consumer simply subscribes.
Why not just use HTTP?
HTTP works well for web pages and many APIs, and some IoT devices do use it. But HTTP is request and response: the device asks, the server answers. Pushing a command down to a device, such as "switch off pump 3", is awkward unless the device keeps polling. MQTT keeps a connection open in both directions, so the server can send commands the moment they are needed, and devices spend less energy and data on repeated handshakes.
Brokers and topics
The broker is the heart of an MQTT system. It accepts connections, checks credentials, receives published messages and forwards them to every subscriber. You can run an open-source broker such as Mosquitto or EMQX on your own server, or use a managed service like AWS IoT Core, Azure IoT Hub or HiveMQ Cloud, which handle scaling and availability for you.
Topics are the named channels messages travel on. They are plain text strings separated by slashes, which lets you build a hierarchy. A sensible structure might look like this:
- factory1/line2/loom07/temperature for a single reading
- factory1/line2/loom07/status for online or offline state
- factory1/line2/loom07/commands for instructions sent to the machine
Subscribers can use wildcards. A plus sign matches one level, so factory1/+/+/temperature receives temperatures from every machine on every line. A hash matches everything below a level, so factory1/# receives every message from that site.
Designing topics well
Topic design looks trivial but it shapes your security rules, your integrations and how easily the system grows. A few practical guidelines:
- Put the broad scope first (organisation, site) and the specific measurement last.
- Use stable device identifiers, not names people might change.
- Keep telemetry, status and commands on separate branches so permissions can differ.
- Document the scheme early and treat changes like an API change.
Two further broker features are worth knowing. Retained messages let the broker keep the last value on a topic, so a new dashboard immediately sees the current state. Last will messages let a device register a message the broker publishes if it disconnects unexpectedly, which is a simple way to detect devices that have gone offline.
QoS levels
Quality of service, or QoS, controls how hard MQTT tries to deliver each message. There are three levels, and choosing the right one is a genuine business decision because it trades reliability against network use and battery life.
| Level | Guarantee | Good for |
|---|---|---|
| QoS 0 | At most once. Sent once, no confirmation. | Frequent sensor readings where missing one is harmless |
| QoS 1 | At least once. Resent until confirmed, may arrive twice. | Alerts, events and most business data |
| QoS 2 | Exactly once. A four-step handshake prevents duplicates. | Rare cases where duplicates cause real harm, such as billing counts |
In projects we deliver, QoS 1 is the usual default for anything that matters, combined with receiving systems that can safely ignore duplicates. Using QoS 2 everywhere sounds safe but adds traffic and complexity, and not every managed broker supports it fully. QoS 0 is fine for a temperature reading sent every ten seconds, because the next one is never far away.
Also note that QoS only covers the hop between a client and the broker. End-to-end reliability depends on both the publisher and subscriber choosing suitable levels, and on persistent sessions so that messages queue while a subscriber is briefly offline.
Security
MQTT itself is simple, and that means security is your responsibility to configure. An open broker on the internet with no authentication is an invitation for anyone to read your data or send commands to your equipment.
At a minimum, a production MQTT setup should include:
- TLS encryption on every connection, typically on port 8883, so data cannot be read in transit.
- Per-device credentials, ideally X.509 client certificates, so a compromised device can be revoked without affecting others.
- Topic-level permissions, so each device can only publish to its own telemetry topics and subscribe to its own command topic.
- Separate credentials for applications such as dashboards and integrations, with only the access they need.
- Monitoring of connection attempts and unusual traffic.
Managed brokers make much of this easier because certificate handling and policies are built in. Self-hosted brokers can be just as secure, but you need to plan for patching, certificate rotation and backups.
Common mistakes with MQTT
- Sharing one username and password across every device.
- Flat, unstructured topic names that make permissions impossible to manage.
- Sending large payloads, such as images, through MQTT instead of uploading them to storage and sending a reference.
- Assuming QoS 2 removes the need for duplicate handling in downstream systems.
- Forgetting to monitor broker health, so an outage goes unnoticed until users complain.
How The Coders Adda can help
We design MQTT architectures as part of complete connected systems: topic schemes, broker selection, device security and the dashboards and integrations that consume the data. Whether you prefer a managed cloud service or a self-hosted broker, our team can help you choose sensibly and build it properly. Explore our IoT development services to see how we work.
If you are planning a device project and want a second opinion on the messaging design, tell us about your project.