Just downloaded it on my phone last night and tried it out. Here’s an example of the kind of info it provided me when I asked for suggestions on MQTT topics:
While there is no universal standard for MQTT topics, there are best practices and common conventions that many developers and organizations follow to ensure consistency, scalability, and interoperability. Below, I’ll outline some widely accepted guidelines and examples of topic naming conventions.
—
### 1. General Best Practices
These are the most common recommendations for MQTT topic design:
1. Use a Clear Hierarchy:
-
- Organize topics in a logical, tree-like structure.*
-
- Example:
domain/device-type/device-id/sensor-type
*
2. Avoid Special Characters:
-
- Use only alphanumeric characters, hyphens (
-
), underscores (_
), and forward slashes (/
).*
-
- Avoid spaces,
#
, +
, and other special characters unless used as wildcards.*
3. Be Consistent:
-
- Use a consistent naming convention (e.g., lowercase, snake_case, or camelCase).*
-
- Example:
home/sensors/temperature/living-room
*
4. Avoid Starting or Ending with a Slash:
5. Use Wildcards Sparingly:
-
+
(single-level wildcard): Matches one level in the hierarchy.*
-
#
(multi-level wildcard): Matches all levels below.*
—
### 2. Common Conventions
While not formal standards, these conventions are widely used in the industry:
#### a. Domain-Based Structure
- Start with a high-level domain or application name.
- Example: home/sensors/temperature/living-room
#### b. Location-Based Structure
- Include location information in the topic hierarchy.
- Example: building/floor/room/device-type/device-id
#### c. Device-Centric Structure
- Focus on the device type and ID.
- Example: sensors/temperature/device-001
#### d. Action or Command Topics
- Use separate topics for commands and status updates.
- Example:
-
- Command:
home/actuators/light/living-room/command
*
-
- Status:
home/actuators/light/living-room/status
*
—
### 3. Industry-Specific Conventions
Some industries have developed their own conventions for MQTT topics:
#### a. Smart Home
- Example: home/{device-type}/{location}/{sensor-type}
-
home/sensors/temperature/living-room
*
-
home/actuators/light/bedroom/switch
*
#### b. Industrial IoT (IIoT)
- Example: factory/{machine-type}/{unit-id}/{sensor-type}
-
factory/motor/unit-1/status
*
-
factory/sensors/temperature/zone-1
*
#### c. Automotive
- Example: vehicle/{vehicle-id}/{sensor-type}
-
-
vehicle/car-001/fuel-level
*
#### d. Agriculture
- Example: farm/{field-id}/{sensor-type}
-
-
farm/field-1/temperature
*
—
### 4. Example Topic Structures
Here are some examples of well-structured MQTT topics:
#### Smart Home
- home/sensors/temperature/living-room
- home/actuators/light/bedroom/switch
- home/security/door/front-door/status
#### Industrial IoT
- factory/motor/unit-1/status
- factory/sensors/temperature/zone-1
- factory/alarms/motor/unit-1/overheat
#### Automotive
- vehicle/car-001/speed
- vehicle/car-001/fuel-level
- vehicle/car-001/engine-temperature
#### Agriculture
- farm/field-1/moisture
- farm/field-1/temperature
- farm/field-1/irrigation/status
—
### 5. Tools and Resources
- Eclipse IoT: Provides guidelines for MQTT topic design in IoT systems.
- MQTT.org: Offers best practices and examples for MQTT topic naming.
- Industry-Specific Standards: Some industries (e.g., automotive, healthcare) may have their own guidelines for MQTT topics.
—
By following these conventions and best practices, you can create a scalable and maintainable MQTT topic structure for your application. Let me know if you need further assistance!
I have no complaints about it.