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. Guide: Setting up and testing MQTT Client Gateway

Guide: Setting up and testing MQTT Client Gateway

Scheduled Pinned Locked Moved Development
78 Posts 18 Posters 53.1k Views 18 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.
  • greglG Offline
    greglG Offline
    gregl
    Hero Member
    wrote on last edited by
    #46

    Hi @hek
    Nothing...
    there is no message received from the node. ( based off the serial output)

    How can i serial.print out all the messages it receives?

    1 Reply Last reply
    0
    • greglG Offline
      greglG Offline
      gregl
      Hero Member
      wrote on last edited by
      #47

      @hek

      mmm..perhaps there is a problem between mosquito and the mqttclient gateway. As ive now attached a serial monitor to the mqttclient gateway and sending the message doesnt appear in the console. I assume it should...

      Opening port
      Port open
      0;255;3;0;9;read: 9-9-0 s=255,c=3,t=15,pt=1,l=1,sg=0:0
      0;255;3;0;9;Sending message on topic: mygateway1-out/9/255/3/0/15
      0;255;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=10,sg=0:2.0.0-beta
      0;255;3;0;9;Sending message on topic: mygateway1-out/9/255/0/0/18
      0;255;3;0;9;read: 9-9-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
      0;255;3;0;9;Sending message on topic: mygateway1-out/9/255/3/0/6
      0;255;3;0;9;read: 9-9-0 s=255,c=3,t=11,pt=0,l=5,sg=0:Relay
      0;255;3;0;9;Sending message on topic: mygateway1-out/9/255/3/0/11
      0;255;3;0;9;read: 9-9-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
      0;255;3;0;9;Sending message on topic: mygateway1-out/9/255/3/0/12
      0;255;3;0;9;read: 9-9-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
      0;255;3;0;9;Sending message on topic: mygateway1-out/9/1/0/0/3
      0;255;3;0;9;read: 1-1-0 s=0,c=1,t=0,pt=7,l=5,sg=0:26.8
      0;255;3;0;9;Sending message on topic: mygateway1-out/1/0/1/0/0
      0;255;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:26.7
      0;255;3;0;9;Sending message on topic: mygateway1-out/1/1/1/0/0
      

      as you can see no incoming messages from mosqutto.

      1 Reply Last reply
      0
      • greglG Offline
        greglG Offline
        gregl
        Hero Member
        wrote on last edited by
        #48

        I can see in mosquitto logs a subscription from the gateway

        1452645694: mosquitto version 1.3.4 terminating
        1452645694: Sending CONNACK to mysensors-1 (0)
        1452645694: Received SUBSCRIBE from mysensors-1
        1452645694: 	mygateway1-in/+/+/+/+/+ (QoS 0)
        1452645694: Sending SUBACK to mysensors-1
        

        So looks like i need to add an extra level to the message i send!
        So i just tried sending a message to topic:

        mygateway1-in/9/1/0/1/1

        and now i can see in my serial outputs of both the mqttclient gateway and the relaysketch node the message received!
        ( but its not swithing my relay yet! )

        @hek is this the correct MQTT formatting:
        MY_MQTT_PUBLISH_TOPIC_PREFIX/FROM-NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE

        1 Reply Last reply
        0
        • greglG Offline
          greglG Offline
          gregl
          Hero Member
          wrote on last edited by
          #49

          Ok got it... ( sorry for making mess of this discussion!)
          If i publish to
          mygateway1-in/9/1/1/0/2 and send message values of 0 or 1 it works.... ;-)

          Hope this helps someone else!

          Greg ;-)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tante ju
            wrote on last edited by
            #50

            @hek
            That thread does not directly touch on the issue I noticed, although that might be connected.

            Some other questions:
            Why is the topic structure as it is? I like my MQTT topics in hierarchical order. So, having different prefixes for send and receive (in and out) is not nice, but ok. BUt why is the ACK flag before the data type, which is usually linked to a value or variable in the sensor? I would consider ACK to be a sub-value of that one.

            And is there a way to have more speaky names instead of numbers? So, the source does not have that option and as that gateway is now included in the library I only see the possibility of changing the source in the library, which will disconnect from updates. Not nice. What about an option of excluding gatewayTransportSend and incomingMQTT via define from the library and define then in the own sketch?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              moskovskiy82
              wrote on last edited by
              #51

              What is the correct way to run DHCP? Tried commenting out
              #define MY_IP_ADDRESS
              but that didn't help.

              Also is it possible to use fqdn for the mqtt broker instead of the ip?

              greglG 1 Reply Last reply
              0
              • M moskovskiy82

                What is the correct way to run DHCP? Tried commenting out
                #define MY_IP_ADDRESS
                but that didn't help.

                Also is it possible to use fqdn for the mqtt broker instead of the ip?

                greglG Offline
                greglG Offline
                gregl
                Hero Member
                wrote on last edited by
                #52

                @moskovskiy82

                I also tried to use DHCP and fqdn for mosqitto, but no luck....so I cant help but I too would like to know if its possible.

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

                  @gregl

                  A PR was merged 5 days ago where you can specify
                  MY_CONTROLLER_URL_ADDRESS

                  https://github.com/mysensors/Arduino/pull/375

                  I haven't verified it myself yet though.

                  greglG 1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mbj
                    wrote on last edited by
                    #54

                    Finally I have the ESP8266 gateway running with Mosquitto and Openhab. Because the ESP8266 Gateway installation was painless and Mosquitto and Openhab the major problems I have posted some general info at this link in case anyone is interested, see http://forum.mysensors.org/topic/3005/switching-from-v1-5-mqtt-gateway-to-esp8266-mqtt-client-gateway.
                    (Sorry if this is the wrong procedure but found no way to add other tags to a message in this thread).

                    M 1 Reply Last reply
                    1
                    • hekH hek

                      @gregl

                      A PR was merged 5 days ago where you can specify
                      MY_CONTROLLER_URL_ADDRESS

                      https://github.com/mysensors/Arduino/pull/375

                      I haven't verified it myself yet though.

                      greglG Offline
                      greglG Offline
                      gregl
                      Hero Member
                      wrote on last edited by
                      #55

                      @hek
                      Thanks Hek - will give it a try soon!

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        moskovskiy82
                        wrote on last edited by
                        #56

                        I have been successfully running the MQTT client gateway receiving the data from sensors. Now build the first mysensors relay and would like to know if the MQTT client gateway can act as a transmitter?

                        I have assigned the nod id of 55 to the relay sensor and trying to send
                        mosquitto_pub -t mygateway1-in/55/1/0/0/3 -m "1"

                        But doesn't seem to help

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

                          Yes, it should work as a transmitter as well. What does the log say on gateway and node?

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            moskovskiy82
                            wrote on last edited by
                            #58

                            Resolved. Power supply was the problem

                            1 Reply Last reply
                            0
                            • M mbj

                              Finally I have the ESP8266 gateway running with Mosquitto and Openhab. Because the ESP8266 Gateway installation was painless and Mosquitto and Openhab the major problems I have posted some general info at this link in case anyone is interested, see http://forum.mysensors.org/topic/3005/switching-from-v1-5-mqtt-gateway-to-esp8266-mqtt-client-gateway.
                              (Sorry if this is the wrong procedure but found no way to add other tags to a message in this thread).

                              M Offline
                              M Offline
                              mbj
                              wrote on last edited by
                              #59

                              @mbj said:

                              Finally I have the ESP8266 gateway running with Mosquitto and Openhab. Because the ESP8266 Gateway installation was painless and Mosquitto and Openhab the major problems I have posted some general info at this link in case anyone is interested, see http://forum.mysensors.org/topic/3005/switching-from-v1-5-mqtt-gateway-to-esp8266-mqtt-client-gateway.
                              (Sorry if this is the wrong procedure but found no way to add other tags to a message in this thread).

                              Do not know if this info is of any interest but my ESP8266 MQTT gateway (based on a NodeMCU board) has been running without hiccups for almost a month now. So it has been very stable. I have also made a very short test using a Wemos D1 Mini for the gateway and this one seemed to be working as expected as well (not very surprised but you never know until it has been tested :-)).

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                DirkB19
                                wrote on last edited by
                                #60

                                Hi,

                                I've uploaded the GatewayW5100MQTTClient.ino to a UNO with W5100.

                                I have changed IP adresses to my Mosquitto broker (on Raspberry Pi) as instructed.

                                However,
                                I don't see the gateway connecting to the Mosquitto (in the /var/log/mosquitto/mosquitto.log on RPI) and also I don't see anything in the serial monitor. I've got 10+ sensornodes that work well when using another gateway (to OpenHab).
                                What am I overlooking here ?

                                The same hardware UNO+W5100 worked before as MQTTgateway(+broker), so I'm guessing it's not the hardware?

                                Any help is appreciated.
                                Thanks,
                                DirkB

                                greglG M 2 Replies Last reply
                                0
                                • D DirkB19

                                  Hi,

                                  I've uploaded the GatewayW5100MQTTClient.ino to a UNO with W5100.

                                  I have changed IP adresses to my Mosquitto broker (on Raspberry Pi) as instructed.

                                  However,
                                  I don't see the gateway connecting to the Mosquitto (in the /var/log/mosquitto/mosquitto.log on RPI) and also I don't see anything in the serial monitor. I've got 10+ sensornodes that work well when using another gateway (to OpenHab).
                                  What am I overlooking here ?

                                  The same hardware UNO+W5100 worked before as MQTTgateway(+broker), so I'm guessing it's not the hardware?

                                  Any help is appreciated.
                                  Thanks,
                                  DirkB

                                  greglG Offline
                                  greglG Offline
                                  gregl
                                  Hero Member
                                  wrote on last edited by
                                  #61

                                  @DirkB19

                                  Hi Dirk - did you change the MAC address ( these need to be unique too and it could have the same one "DEADBEEFFEED" as your existing GW )

                                  1 Reply Last reply
                                  0
                                  • D DirkB19

                                    Hi,

                                    I've uploaded the GatewayW5100MQTTClient.ino to a UNO with W5100.

                                    I have changed IP adresses to my Mosquitto broker (on Raspberry Pi) as instructed.

                                    However,
                                    I don't see the gateway connecting to the Mosquitto (in the /var/log/mosquitto/mosquitto.log on RPI) and also I don't see anything in the serial monitor. I've got 10+ sensornodes that work well when using another gateway (to OpenHab).
                                    What am I overlooking here ?

                                    The same hardware UNO+W5100 worked before as MQTTgateway(+broker), so I'm guessing it's not the hardware?

                                    Any help is appreciated.
                                    Thanks,
                                    DirkB

                                    M Offline
                                    M Offline
                                    mbj
                                    wrote on last edited by
                                    #62

                                    @DirkB19 If you do not see anything in the serial monitor for the gateway then the problem must be with the gateway itself. Have you observed that there is a special #define MY_W5100_SPI_EN to uncomment when compiling for an Uno with the shield installed ? If not, you can try that.

                                    D 1 Reply Last reply
                                    0
                                    • M mbj

                                      @DirkB19 If you do not see anything in the serial monitor for the gateway then the problem must be with the gateway itself. Have you observed that there is a special #define MY_W5100_SPI_EN to uncomment when compiling for an Uno with the shield installed ? If not, you can try that.

                                      D Offline
                                      D Offline
                                      DirkB19
                                      wrote on last edited by
                                      #63

                                      @mbj said:

                                      MY_W5100_SPI_EN

                                      Sorry for this NOOB question, but where is this to be uncommented.
                                      I don't see it in the gateway sketch ?
                                      I use this sketch GatewayW5100MQTTClient.ino

                                      M 1 Reply Last reply
                                      0
                                      • D DirkB19

                                        @mbj said:

                                        MY_W5100_SPI_EN

                                        Sorry for this NOOB question, but where is this to be uncommented.
                                        I don't see it in the gateway sketch ?
                                        I use this sketch GatewayW5100MQTTClient.ino

                                        M Offline
                                        M Offline
                                        mbj
                                        wrote on last edited by
                                        #64

                                        @DirkB19

                                        It is looking like this, just uncomment the #define - line:

                                        // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                                        //#define MY_W5100_SPI_EN 4

                                        D 1 Reply Last reply
                                        0
                                        • M mbj

                                          @DirkB19

                                          It is looking like this, just uncomment the #define - line:

                                          // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                                          //#define MY_W5100_SPI_EN 4

                                          D Offline
                                          D Offline
                                          DirkB19
                                          wrote on last edited by
                                          #65

                                          @mbj

                                          Thanks for the help, but I'm still very confused because OK, I found the line to uncomment.
                                          I uncommented, but still nothing on serial monitor.
                                          So then I see lines below this in the sketch and I realize that my radio is wired as follows ;
                                          SCK -- Pin 13
                                          MISO -- Pin 12
                                          MOSI -- Pin 11
                                          CS -- Pin 6
                                          CE -- Pin 5
                                          ?
                                          But there's no Pins 14,15,16 to be found on my W5100/UNO ? So I'm very confused ...

                                          #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                                          #define MY_SOFTSPI
                                          #define MY_SOFT_SPI_SCK_PIN 14
                                          #define MY_SOFT_SPI_MISO_PIN 16
                                          #define MY_SOFT_SPI_MOSI_PIN 15
                                          #endif

                                          // When W5100 is connected we have to move CE/CSN pins for NRF radio
                                          #define MY_RF24_CE_PIN 5
                                          #define MY_RF24_CS_PIN 6

                                          martinhjelmareM M 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          13

                                          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