Learning best practices for topics

We already know that MQTT allows us to publish messages on topics. A publisher always has to specify the topic name to which a message will be published. The easiest way to understand topic names in MQTT is to think about them as paths in a file system.

If we have to save dozens of files that have information about different types of sensor for a diverse number of drones, we can create a hierarchy of directories or folders to organize all the files that we will save. We can create a directory named sensors, then one sub-directory for each drone, such as octocopter01, and finally a sub-directory with the sensor name, such as altitude. The path in macOS or Linux will be sensors/octocopter01/altitude because ...

Get Hands-On MQTT Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.