Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. MQTT messages and sensor tree

MQTT messages and sensor tree

Scheduled Pinned Locked Moved General Discussion
5 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Thomas AugustinusT Offline
    Thomas AugustinusT Offline
    Thomas Augustinus
    wrote on last edited by Thomas Augustinus
    #1

    Hi There,
    I have my MQTT client gateway up and running - and tried to decode the mqtt topic tree that is sent to the mqtt broker.

    EDIT: I have deleted the (wrong) information from this post. Below I have added the correct interpretation in a reply.

    I have set the publish prefix to "to", node id and sensor id are set in the sensor sketch

    ex. from mqtt.fx subscribing to "to/#"
    to/10/4/1/0/16 payload 1/0
    Prefix "to", node 10, sensor 4

    I have another sensor (id 11) that does not work so well. The radio works but it reports several errors and I have not fund out why yet. But it reports several other mqtt topics that are forwarded to the mqtt broker during boot:
    to/11/255/3/0/6 payload "0"
    to/11/255/3/0/12 payload "1.0"
    to/11/4/0/0/0 no payload
    Prefix "to", node 11, sensor 4 and 255

    The strange thing is that the binary sensor I have that works, does NOT send any messages to mqtt unless I activate the button. I will investigate later...

    So - the question is how to understand the mqtt topic tree - so that my controlling app can subscribe to the right topics.

    I have - at least partially answered the questions below...
    /th

    1 Reply Last reply
    0
    • Thomas AugustinusT Offline
      Thomas AugustinusT Offline
      Thomas Augustinus
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • Thomas AugustinusT Offline
        Thomas AugustinusT Offline
        Thomas Augustinus
        wrote on last edited by Thomas Augustinus
        #3

        Ok, Responding to my own post so whoever is in the same boat does not have to search for this info...

        In the API-description - which I for some reason had not discovered before, there is a wealth of information. In the serial API description there are all the tables we need to understand the mqtt client operation.

        So... Look here for v2.0 serial API description.

        The documents are not directly describing the mqtt tree - but the information in the mqtt tree is all described there:

        mqtt topic tree: prefix/node-id/child-sensor-id/message-type/ack/sub-type + payload

        Ok - prefix, node-id and child-sensor-id are defined by you in the sketches. Prefix in the gw the other two in the sensors. NB. your sensors must use manual id assigment unless you have a controller that handles that - I do not.

        Message type: defines what the message contains AND what the sub-type means:

        • Presentation (0): Contains the S_xxx sensor type
        • set/req (1/2): Contains the V_xxx data type
        • Internal (3): Contains an I_xxx constant that describes what the payload is - ex. I_CONFIG (6) or I_SKETCH_VERSION (12) from my example above
        • stream (4): for fw update. I have not investigated that yet.

        The **ack **field is used to know if a message is an ack to a previous message or a real message. I assume that only normal messages will be forwarded to the mqtt broker - so I think it will always be 0.

        I hope this information can help somone else to avoid spending time digging in the documentation, code and exampes :-)

        /th

        1 Reply Last reply
        0
        • scalzS Offline
          scalzS Offline
          scalz
          Hardware Contributor
          wrote on last edited by
          #4

          in MyGatewayTransportMQTTClient.cpp, l.21 ;)
          // Topic structure: MY_MQTT_PUBLISH_TOPIC_PREFIX/NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE

          Thomas AugustinusT 1 Reply Last reply
          1
          • scalzS scalz

            in MyGatewayTransportMQTTClient.cpp, l.21 ;)
            // Topic structure: MY_MQTT_PUBLISH_TOPIC_PREFIX/NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE

            Thomas AugustinusT Offline
            Thomas AugustinusT Offline
            Thomas Augustinus
            wrote on last edited by
            #5

            @scalz - jeez I spent a lot of time invesstigating this :-)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            18

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular