IoTServa Get Started
Guide

MQTT Topic Naming for Multi-Site IoT Projects

A consistent MQTT topic scheme saves years of pain on multi-site projects. See a simple convention, what to avoid, and how QoS and retained messages fit in.

4 minute readUpdated

Six teal cables converging into one small white hub

Agree one topic scheme per organization before devices multiply, and put site, asset and measurement in the same order every time.

MQTT Defines Transport, Not Meaning

MQTT moves messages to named topics through a broker. It does not say what a topic should be called or what the payload contains. Two vendors can both speak MQTT and still be incompatible.

A Simple Convention

Use a path that runs from broad to specific: site, then area, then asset, then measurement. For example, factory/line-2/oven/temperature. Keep names lowercase, avoid spaces, and never start a topic with a slash.

What to Avoid

Do not put values or timestamps in the topic. Do not use one topic for many measurements. Do not let each team invent its own scheme, because wildcards then stop being useful.

QoS and Retained Messages

QoS 0 may lose messages, QoS 1 delivers at least once and QoS 2 exactly once at higher cost. Most telemetry uses QoS 0 or 1. A retained message is delivered to new subscribers immediately, which can make a dashboard show an old value as if it were live unless you also track message age.

Security

Use TLS on port 8883, authenticate every client and limit each client to the topics it needs. An open broker with wildcard access exposes every device behind it.

Common Questions

How should I name MQTT topics?

Use a path that runs from broad to specific, such as site, area, asset and measurement, in lowercase with no spaces and no leading slash. Keep the same order everywhere. A consistent scheme lets subscribers use wildcards safely and keeps many teams from inventing incompatible names.

Should I use retained messages for sensor data?

Use retained messages when a new subscriber needs the last known value immediately, such as a dashboard. Include a timestamp in the payload, because a retained message can look live when the source has stopped sending. Do not retain high-rate raw telemetry.

References

Start with One Site. Prove It on Real Devices.

Tell us which protocols are on site. We will scope a pilot that reads your real devices.

WhatsApp