How to Organize MQTT Topics for Industrial Devices
A simple MQTT topic naming convention for factories: organize sites, lines, devices, telemetry and commands, with useful wildcard subscriptions.
motor7temp makes sense when you know the machine. Add another production line
and a second factory, and that name starts to leave questions unanswered.
A useful MQTT topic tells you where a message belongs before you open its payload. Here is a simple naming approach for industrial devices.
Give each level a job
Start with a consistent structure:
site/line/device/category/signal
For one motor, that could become:
plant-01/line-02/motor-07/telemetry/temperature
plant-01/line-02/motor-07/status/state
plant-01/line-02/motor-07/command/speed
You can immediately distinguish a measurement, a reported state, and a command. This is a suggested convention; MQTT does not require this particular hierarchy.
Keep changing values in the payload. Publish a temperature reading to
telemetry/temperature, rather than creating a new topic for every temperature.
Document its unit, too, so every consumer interprets the reading consistently.
Plan the subscriptions you will need
A consistent structure makes it easier to select useful groups of messages:
| Subscription filter | What it covers |
|---|---|
plant-01/line-02/+/telemetry/temperature |
Temperature readings from every device on line 02 |
plant-01/line-02/motor-07/# |
All topics under motor 07 |
Under the MQTT wildcard rules,
+ matches one complete level. # matches the parent and any levels below it,
and must appear last. Use wildcards in subscriptions, not published topic names.
Keep the naming predictable
- Use lowercase consistently. MQTT topics are case-sensitive.
- Keep device IDs stable and use the same level order across machines.
- Avoid spaces and leading or trailing slashes as a team convention.
- Keep commands separate from telemetry. Enforce permissions through the broker; a name alone does not restrict access.
Before connecting the whole factory, review a few sample messages with an MQTT client such as Katman. Check the topic names, inspect the payloads, and make sure your subscriptions select the devices you intended.