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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #25

    @vickey
    Sorry haven't seen this error. Which ESP board version do you have installed in the IDE? (See Board manager).

    Please do no double post on the forum! Only creates annoyance.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vickey
      wrote on last edited by
      #26

      @hek I am using Stable ESP8266 version 2.0.0 from stable release

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ciprian
        wrote on last edited by
        #27

        If it helps:
        in ESP8266 ver. 2.0.0 was added abort in
        here
        cores/esp8266/core_esp8266_postmortem.c:

        void abort() __attribute__((noreturn));
        
        void abort(){
            // cause exception
            s_abort_called = true;
            do {
                *((int*)0) = 0;
            } while(true);
        } 
        

        i comment the lines in MySensors/core/MyMainESP8266.cpp and it compiled ok.

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

          @ciprian
          This has been fixed since a while back.

          1 Reply Last reply
          0
          • dakkyD Offline
            dakkyD Offline
            dakky
            wrote on last edited by dakky
            #29

            Hello.

            I tried the development branch because I prefer having my gateway not as message broker.
            I had some problems resulting in conflicting entries for the gateway in MyConfig.h and the sketch. MyConfig.h always wins :D for the release it might be more transparent for the user if there is only one location, where the gateway settings are defined: example or MyConfig.h

            So much for the feedback, now to the problems:
            I use the w5100 version of the sketch with a static IP.

            In the serial monitor i see:

            0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
            0;0;3;0;9;Radio init successful.
            IP: 0.40.68.10
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Init complete, id=0, parent=0, distance=0
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Attempting MQTT connection...
            0;0;3;0;9;Attempting MQTT connection...
            

            in the log of the moquitto server i see:

            1450112394: New connection from 192.168.100.10 on port 1883.
            1450112394: New connection from 192.168.100.10 on port 1883.
            1450112394: Socket error on client <unknown>, disconnecting.
            1450112409: New connection from 192.168.100.10 on port 1883.
            1450112409: New connection from 192.168.100.10 on port 1883.
            

            The gateway tries to open a lot of connections and all of them seem to die after a short while
            Any idea?

            Controller: Raspberry Pi 2 :: Openhab2 :: with @TimO MySensors Binding
            Gateway: Arduino MEGA 2560 R3 :: W5100 :: Ethernet GW

            Software: MySensors 2.0development

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mike Cayouette
              wrote on last edited by
              #30

              @dakky The gateway tries to open a lot of connections and all of them seem to die after a short while

              I had a similar problem a while back, not with the mysensors dev branch, but while using the subpub MQTT library on a ESP8266. After upgrading my MQTT (mosquitto) server to version 1.3.5 it corrected to the problem. You may want to take a look at the version you are running.

              Mike

              1 Reply Last reply
              0
              • dakkyD Offline
                dakkyD Offline
                dakky
                wrote on last edited by dakky
                #31

                Thx 4 replying ;)

                mosquitto version 1.4.5 (build date Sun, 08 Nov 2015 21:43:12 +0000)
                

                unfortunetly this seems not to be the problem :(

                EDIT: i updated the PubSubClient lib to version 2.4 instead of the delivered 1.9. Same behavior
                Another EDIT: mosquitto itself seems to work fine: OpenHab successfully connects to the broker and delivers its messages

                Controller: Raspberry Pi 2 :: Openhab2 :: with @TimO MySensors Binding
                Gateway: Arduino MEGA 2560 R3 :: W5100 :: Ethernet GW

                Software: MySensors 2.0development

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  drock1985
                  wrote on last edited by
                  #32

                  Hi,

                  I'm trying to set up the MQTT gateway to work with Home-Assistant; since the serial gateway plugin lacks in binary switches (ex relays, and other things).

                  I have the MQTT sketch installed on a Nano with W5100 module, and serial output from the Arduino is good. But when I add a sensor to the Gateway, there is no communication.

                  Here is my output from Arduino, where would I go next?

                  0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
                  0;0;3;0;9;Radio init successful.
                  IP: 192.168.86.112
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;MQTT connected
                  0;0;3;0;9;Init complete, id=0, parent=0, distance=0
                  ad: 0-0-0 s=0,c=0,t=0,pt=0,l=0,sg=0:
                  0;0;3;0;9;ver mismatch
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;Attempting MQTT connection...
                  0;0;3;0;9;MQTT connected```

                  My Projects
                  2 Door Chime Sensor
                  Washing Machine Monitor

                  1 Reply Last reply
                  0
                  • dakkyD Offline
                    dakkyD Offline
                    dakky
                    wrote on last edited by
                    #33

                    @dakky said:

                    The gateway tries to open a lot of connections and all of them seem to die after a short while
                    Any idea?

                    Narghs!

                    Seems to be a hardware problem. I changed the w5100 module with an w5100 arduino shield and now it works fine:

                    0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
                    0;0;3;0;9;Radio init successful.
                    IP: 192.168.100.10
                    0;0;3;0;9;Attempting MQTT connection...
                    0;0;3;0;9;MQTT connected
                    0;0;3;0;9;Init complete, id=0, parent=0, distance=0
                    

                    I'm still interested in the reason. Hardware broken or wiring fail?

                    • pinging the arduino worked
                    • i can see the connections on the broker

                    => basic networking seems to work, but "delivering content" failed. Any guesses?

                    Strange fact: with the "broken" hardware:

                    0;0;3;0;9;Radio init successful.
                    IP: 0.40.68.10
                    

                    with the shield:

                    0;0;3;0;9;Radio init successful.
                    IP: 192.168.100.10
                    

                    Same sketch, 192.168.100.10 is the correct Ip (obviously) ;)

                    Greeting
                    Dakky

                    Controller: Raspberry Pi 2 :: Openhab2 :: with @TimO MySensors Binding
                    Gateway: Arduino MEGA 2560 R3 :: W5100 :: Ethernet GW

                    Software: MySensors 2.0development

                    ahmedadelhosniA 1 Reply Last reply
                    1
                    • dakkyD dakky

                      @dakky said:

                      The gateway tries to open a lot of connections and all of them seem to die after a short while
                      Any idea?

                      Narghs!

                      Seems to be a hardware problem. I changed the w5100 module with an w5100 arduino shield and now it works fine:

                      0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
                      0;0;3;0;9;Radio init successful.
                      IP: 192.168.100.10
                      0;0;3;0;9;Attempting MQTT connection...
                      0;0;3;0;9;MQTT connected
                      0;0;3;0;9;Init complete, id=0, parent=0, distance=0
                      

                      I'm still interested in the reason. Hardware broken or wiring fail?

                      • pinging the arduino worked
                      • i can see the connections on the broker

                      => basic networking seems to work, but "delivering content" failed. Any guesses?

                      Strange fact: with the "broken" hardware:

                      0;0;3;0;9;Radio init successful.
                      IP: 0.40.68.10
                      

                      with the shield:

                      0;0;3;0;9;Radio init successful.
                      IP: 192.168.100.10
                      

                      Same sketch, 192.168.100.10 is the correct Ip (obviously) ;)

                      Greeting
                      Dakky

                      ahmedadelhosniA Offline
                      ahmedadelhosniA Offline
                      ahmedadelhosni
                      wrote on last edited by
                      #34

                      @dakky I guess I had that problem once or twice before but I don't pay attention to it as there was other bugs which were more important.

                      I remember that I just reset the nano and it worked at once. Glad that it worked for you but as you have said, knowing the root cause it important.

                      Will try to reproduce it again when I have time.

                      1 Reply Last reply
                      0
                      • dakkyD Offline
                        dakkyD Offline
                        dakky
                        wrote on last edited by dakky
                        #35

                        Another question:

                        I don't have any experience with the classic setup (broker on gateway). But does

                        The topic resembles the serial protocol. You must define you preferred subscribe and publish prefix in the sketch. The topic is build like this:
                        MY_MQTT_PUBLISH_TOPIC_PREFIX/FROM-NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE

                        mean, that the consuming controllers configuration (openhab in my case) has to be changed?
                        From

                        sensor-gw1-out/99/3/V_TRIPPED
                        

                        To

                        sensor-gw1-out/99/3/1/0/16
                        

                        in order to represent what is really pushed to the mqtt broker? Because thats what is posted to the broker?

                        Controller: Raspberry Pi 2 :: Openhab2 :: with @TimO MySensors Binding
                        Gateway: Arduino MEGA 2560 R3 :: W5100 :: Ethernet GW

                        Software: MySensors 2.0development

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

                          A little bit cofused. Can this sketch be uploaded to ESP12 set as in the "ESP8266 WiFi Gateway"? Without the arduino?
                          After uploading it to esp all i get

                          load 0x4010f000, len 1264, room 16 
                          tail 0
                          chksum 0x42
                          csum 0x42
                          ~ld
                          
                          
                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            moskovskiy82
                            wrote on last edited by
                            #37

                            Can more detailed instructions be given on the development branch? As i understand this is not a simple copy the code from here https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino paste into arduino IDE compile and upload process?

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

                              @moskovskiy82

                              Yes, after the MySensors library has been installed you should be able to compile/upload the sketch and run it.

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

                                Well i had to move all the libs from production branch and extract clean only the development branch in arduino IDE to get it to work.
                                Afterwards had to do the same thing back to production to compile the humidity sensor as it gave me the following error during compilation

                                Arduino: 1.6.5 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"
                                
                                In file included from Mysensors_DHT_Wireless.ino:31:0:
                                \My Documents\Arduino\libraries\MySensors/MySensor.h:201:3: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
                                  #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
                                   ^
                                Mysensors_DHT_Wireless:39: error: 'MySensor' does not name a type
                                Mysensors_DHT_Wireless.ino: In function 'void setup()':
                                Mysensors_DHT_Wireless:50: error: 'gw' was not declared in this scope
                                Mysensors_DHT_Wireless.ino: In function 'void loop()':
                                Mysensors_DHT_Wireless:75: error: 'gw' was not declared in this scope
                                Mysensors_DHT_Wireless:85: error: 'gw' was not declared in this scope
                                Mysensors_DHT_Wireless:90: error: 'gw' was not declared in this scope
                                'MySensor' does not name a type
                                
                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  moskovskiy82
                                  wrote on last edited by
                                  #40

                                  Is there some miscompatability betweed development/production branches?

                                  My humidity sensor reports in the serial console just fine.

                                  req id
                                  send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
                                  req id
                                  send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
                                  T: 24.60
                                  req id
                                  send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
                                  H: 87.00
                                  

                                  On the gateway i see the following

                                  0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
                                  0;255;3;0;9;Sending message on topic: mygateway1-out/255/255/3/0/3
                                  0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
                                  0;255;3;0;9;Sending message on topic: mygateway1-out/255/255/3/0/3
                                  0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
                                  0;255;3;0;9;Sending message on topic: mygateway1-out/255/255/3/0/3
                                  
                                  

                                  But in mosquitto...

                                  mygateway1-out/255/255/3/0/3 (null)
                                  mygateway1-out/255/255/3/0/3 (null)
                                  mygateway1-out/255/255/3/0/3 (null)
                                  
                                  1 Reply Last reply
                                  0
                                  • M Offline
                                    M Offline
                                    moskovskiy82
                                    wrote on last edited by
                                    #41

                                    Please ignore the last post. Solved by finding out that Openhab doesn't handle Node ID assigning.

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

                                      Hi,

                                      Just tried to set up an ESP-12E as MQTT gateway and noticed one bug in the actual development branch:
                                      As soon as one of the three LED PIN assignments is not defined (commented out), the Example sketch will lock itself after initializing NRF radio, and running DHCP. So, no further NRF communication nor signup at the broker. WDT steps in then.

                                      Just defining all three LEDs, without any other parameter or use the LED blinking feature, and everything is fine.

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

                                        @tante-ju

                                        http://forum.mysensors.org/topic/2749/1-6-gateway-possible-error/8

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

                                          Im lost...

                                          Ive just setup a new MQTT client gateway ( from link at the top of this post..) and have a few nodes successfully sending data to a mosquito server.

                                          What im trying to now do is, using the RelayActuator sketch, is control the relay via a MQTT message...but im confused as to what i need to send it!

                                          Here is the serial output from the RelayActuator sketch:

                                          Starting repeater (RNNRA-, 2.0.0-beta)
                                          Radio init successful.
                                          send: 9-9-0-0 s=255,c=3,t=15,pt=1,l=1,sg=0,st=ok:0
                                          send: 9-9-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=ok:2.0.0-beta
                                          send: 9-9-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                                          send: 9-9-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
                                          send: 9-9-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                                          send: 9-9-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
                                          Init complete, id=9, parent=0, distance=1
                                          

                                          So what message do i send it from another MQTT client ?
                                          ive been trying things such as mygateway1-in/9/0/1/1 with message of 0 or 1

                                          Pls help ! ;-)

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


                                          20

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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