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. Development
  3. Help getting started with MQTT gateway

Help getting started with MQTT gateway

Scheduled Pinned Locked Moved Development
22 Posts 2 Posters 7.1k 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.
  • S Samuel235

    I have my controller running openHAB and mosquitto perfect now, my MQTTGateway is working too. I've made a humidity sensor node with the sketch in the library folder, its passing (null) on the specified topic.

    I'm guessing that the (null) means that there is no message in the communication. Am i correct in assuming this?

    hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #4

    @samuel235 said:

    I'm guessing that the (null) means that there is no message in the communication. Am i correct in assuming this?

    Some messages has no payload. But humidity/set should have one.

    S 1 Reply Last reply
    0
    • hekH hek

      @samuel235 said:

      I'm guessing that the (null) means that there is no message in the communication. Am i correct in assuming this?

      Some messages has no payload. But humidity/set should have one.

      S Offline
      S Offline
      Samuel235
      Hardware Contributor
      wrote on last edited by Samuel235
      #5
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      H: 41.90
      req id
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      T: 24.70
      req id
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      H: 42.00
      req id
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      H: 41.80
      req id
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      T: 24.80
      req id
      

      This is just a snippet from my Humidity sensor, and there is nothing sitting at the end of the send line, so i'm guessing the sensor node is not releasing a value for humidity.

      1 Reply Last reply
      0
      • hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by hek
        #6

        The node is requesting an id from the controller. "req id"...

        So you either have to answer this request (through mqtt) or set a static id on the node.

        #define MY_NODE_ID 42

        S 1 Reply Last reply
        0
        • hekH hek

          The node is requesting an id from the controller. "req id"...

          So you either have to answer this request (through mqtt) or set a static id on the node.

          #define MY_NODE_ID 42

          S Offline
          S Offline
          Samuel235
          Hardware Contributor
          wrote on last edited by
          #7

          @hek I wondered why i was getting 255-255 everywhere. Does this have anything to do with that?

          By the way, i assumed that all the configs were setup to handout random ID's, i'm sure i kept reading "automatic ID assign" when i was editing configs for the radios....

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #8

            The node uses id 255 temporarily while asking for an id.

            It's automatic if you're controller supports it. But as this mqtt topic layout is quite new, I doubt many controllers support it.

            The previous (1.5) MQTT gateway did some handouting on its own which wasn't optimal (stored last used id in EEPROM resulting in no control/reuse of ids).

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Samuel235
              Hardware Contributor
              wrote on last edited by
              #9

              Ahhh right okay, well this is what i kept reading in 'MyConfig.h':

              // Node id defaults to AUTO (tries to fetch id from controller)
              #ifndef MY_NODE_ID
              #define MY_NODE_ID AUTO
              #endif
              

              However, i shall manually set the ID on my nodes now.

              I have put '#define MY_NODE_ID 42' into the humidity sketch, that isn't working, is there a specific place it needs to be? I'm just looking through the config files to see where about in the sendMessage code it calls for it and how it calls for it. I've tried to comment those lines out so it doesn't even attempt to get a ID from the controller, that isn't working at the moment.

              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #10

                @samuel235 said:

                is there a specific place it needs to be?

                Add it before the inclusion of MySensor.h

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Samuel235
                  Hardware Contributor
                  wrote on last edited by
                  #11

                  I tried what you advised but it wasn't asigning a ID to the node still. So after a little looking around i found that you can specify the node id within gw.begin().

                  So i have got it as gw.begin(NULL, 4, false).

                  While i understand that the second piece of data is the node id, and the third is whether or not it goes into sleep mode. What is the first? Also, with me calling false for the sleep mode and then at the end of the sketch it tells the node to sleep for 30 seconds, am i over riding that sleep mode that i call at the end?

                  1 Reply Last reply
                  0
                  • hekH Offline
                    hekH Offline
                    hek
                    Admin
                    wrote on last edited by
                    #12

                    Ah.. you're running mixed library versions on node/gateway.. Yes, then you'd need to call gw.begin() on the node.

                    S 1 Reply Last reply
                    0
                    • hekH hek

                      Ah.. you're running mixed library versions on node/gateway.. Yes, then you'd need to call gw.begin() on the node.

                      S Offline
                      S Offline
                      Samuel235
                      Hardware Contributor
                      wrote on last edited by
                      #13

                      But will this overwrite any config/settings like sleep or anything? What does the NULL mean at the start of gw.begin?

                      1 Reply Last reply
                      0
                      • hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #14

                        I'm splitting this discussion to a new topic.

                        1 Reply Last reply
                        0
                        • hekH Offline
                          hekH Offline
                          hek
                          Admin
                          wrote on last edited by
                          #15

                          The 1.5 API/begin() is documented here:
                          http://www.mysensors.org/download/sensor_api_15#the-full-api

                          First argument is callback-function used if you're interested in incoming data. NULL won't overwrite any configuration.

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            Samuel235
                            Hardware Contributor
                            wrote on last edited by
                            #16

                            I'm sorry, i got confused about which version i was running. I thought it was the development humidity sketch and therefor i didn't look for the API of it. Makes sense now. Thank you.

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              Samuel235
                              Hardware Contributor
                              wrote on last edited by Samuel235
                              #17

                              I now have my controller, broker and gateway setup working fine. I then created a temp and humidity sensor, works fine. I then made a motion node, works fine. Then a light switch node that all work perfectly fine together. Now, i come to configure my relay module (which im struggling with getting it to receive the messages) so i open my serial monitor for the gateway and see that even though its got a solid connection, it keeps trying to make another MQTT connection. Over and over again....

                              0;0;3;0;9;Attempting MQTT connection...
                              0;0;3;0;9;MQTT connected
                              0;0;3;0;9;Attempting MQTT connection...
                              0;0;3;0;9;MQTT connected
                              0;0;3;0;9;Attempting MQTT connection...
                              0;0;3;0;9;MQTT connected
                              0;0;3;0;9;Attempting MQTT connection...
                              0;0;3;0;9;MQTT connected
                              0;0;3;0;9;Attempting MQTT connection...
                              0;0;3;0;9;MQTT connected
                              

                              There is nothing in the loop section of the sketch, so all i can assume is that it keeps dropping its connection to mosquitto broker thats wired over ethernet?

                              1 Reply Last reply
                              0
                              • hekH Offline
                                hekH Offline
                                hek
                                Admin
                                wrote on last edited by
                                #18

                                Strange.. And the log on the relay node?

                                S 1 Reply Last reply
                                0
                                • hekH hek

                                  Strange.. And the log on the relay node?

                                  S Offline
                                  S Offline
                                  Samuel235
                                  Hardware Contributor
                                  wrote on last edited by
                                  #19
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    Samuel235
                                    Hardware Contributor
                                    wrote on last edited by Samuel235
                                    #20
                                    send: 4-4-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=fail:1.5.1
                                    send: 4-4-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
                                    repeater started, id=4, parent=0, distance=1
                                    send: 4-4-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=fail:Relay
                                    send: 4-4-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:1.0
                                    send: 4-4-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=fail:
                                    
                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      Samuel235
                                      Hardware Contributor
                                      wrote on last edited by Samuel235
                                      #21

                                      Just to let you know (Not sure if it tells you that i have edited a post), i have removed what i said about the gateway not working, that is back online now, however its back to doing exactly what it was doing earlier and keep trying to connect. But literally its spamming at a rate of like 10/20 per second...

                                      0;0;3;0;9;Attempting MQTT connection...
                                      0;0;3;0;9;MQTT connected
                                      0;0;3;0;9;Attempting MQTT connection...
                                      0;0;3;0;9;MQTT connected
                                      

                                      I have a weird feeling that there may be a power issue or a connection issue somewhere on this gateway. (Its in a cupboard since i got it working this morning so its a little hard for me to believe it).

                                      I have tried a restart on the MQTT broker btw, still nothing.

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        Samuel235
                                        Hardware Contributor
                                        wrote on last edited by
                                        #22

                                        I now feel like a very big silly idiot. Let this be a lesson to anyone thats developing any sort of project. Document everything in some way, pen and paper or in a file.

                                        I had refreshed the sketch and used the same clientID as the raspberrypi was using when i had my old automation server running there.

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


                                        14

                                        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