Zum Inhalt springen
uencoder

Verwenden MQTT topic Struktur für IoT messaging

MQTT topics verwenden slash-separated hierarchies mit wildcards für subscription. Lernen topic design, QoS levels, und retained messages.

  1. 1

    MQTT topics are slash-separated hierarchical paths: home/livingroom/temperature. They are case-sensitive and must not start or end with /. Wildcards: + matches one level (home/+/temperature), # matches all remaining levels (home/# — must be last). Subscribers use wildcards; publishers always publish to a specific topic.

  2. 2
    URL-Parser →

    Analysieren an MQTT topic like a URL path to understand its hierarchy. Split on / to get the topic levels. This helps validate topic structure and design hierarchical naming schemes for IoT devices.

  3. 3
    URL-Kodierer →

    Codieren special characters in MQTT topics. Topics can contain spaces and UTF-8 characters, but they should be URL-encoded for safety. Avoid leading spaces, which are valid but confusing. Use lowercase with hyphens for consistency.

Häufige Fragen

What are MQTT QoS levels?
QoS 0: at most once (fire and forget, no acknowledgment). QoS 1: at least once (acknowledged, may duplicate). QoS 2: exactly once (four-step handshake, no duplicates). Use QoS 0 for frequent sensor data (duplicates don't matter), QoS 1 for commands, QoS 2 for critical messages (billing, state changes).
What is a retained message?
A retained message is the last message published to a topic, stored by the broker. New subscribers immediately receive the retained message on subscription. This is useful for state (device on/off, current temperature) — new clients get the current state without waiting for the next publish. Only one retained message per topic.

Workflows, die diese Aufgabe lösen

Verwandte Tools