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. Controllers
  3. MQTT Broker gateway

MQTT Broker gateway

Scheduled Pinned Locked Moved Controllers
132 Posts 34 Posters 115.6k Views 7 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.
  • H Offline
    H Offline
    hooraysimpsons
    wrote on last edited by
    #81

    I can't seem to get openhab to communicate with my MQTT gateway. I can connect to the gateway with the MyMQTT Android app and I receive messages from my light sensor node including the sketch name and light level. I can ping my gateway without issue as well.

    However, OpenHab never seems like it notices the gateway. No data in the sketch name or node result. I've used the sitemap, items, and config files as described above and I've also customized them to match my sensor node more specifically. Both without success. The only change I've made is my sensor node is defined as node ID 20 within it's sketch.

    When using start_Debug.bat what should I see in the command line window to indicate OpenHab even sees or connects to the gateway. I see no indication that it attempts to connect to the IP address of my gateway.

    Thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gambituk
      wrote on last edited by
      #82

      Maybe if you can share your items, sitemap, and rules if any.

      H 1 Reply Last reply
      0
      • G Gambituk

        Maybe if you can share your items, sitemap, and rules if any.

        H Offline
        H Offline
        hooraysimpsons
        wrote on last edited by hooraysimpsons
        #83

        @Gambituk
        openhab.cfg
        test.items
        1present0absent.map
        test.sitemap

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gambituk
          wrote on last edited by
          #84

          can you also please paste a sample of what you see in myMQTT or screenshot maybe? or it can be easier to copy and paste from a terminal window? are you using raspberry pi or something else?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            C.r.a.z.y.
            wrote on last edited by
            #85

            @hooraysimpsons unplug the power and restart your modem, check your dhcp menu if it has ip for Ardiuno.

            Check your mqtt from serial monitor, you must see "gateway started..."

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Gambituk
              wrote on last edited by
              #86

              mosquitto_sub -h localhost -v -t '#'
              This is what i use to see what is happening on mqtt broker, i am using a raspberry pi and mosquitto installed on the same pi. you can also swap localhost for ip address ie 192.168.0.5 etc

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Gambituk
                wrote on last edited by
                #87

                @C.r.a.z.y. it sounds like he is getting as far as the mqtt broker, so the gateway must be working. ?

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hooraysimpsons
                  wrote on last edited by
                  #88

                  Crazy- I was thinking my network connection as a source of the problem. On my router homepage the gateway does not show up as being given an IP. However, the MyMQTT Android App sees the gateway without issue so the routing across my network from phone to gateway is successful. I have attached a screenshot of the MyMQTT andoird app output.

                  2015-03-08 14.55.12.png

                  I am trying to run OpenHab on a windows PC. I don't have mosquitto running at all. My understanding is that it is not required.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Gambituk
                    wrote on last edited by
                    #89

                    Group all
                    Group node1 (all)
                    Group node2 (all)
                    Group sketch (all)

                     Number node1_light  "Light Level"     (node1,all)  {mqtt="<[mysensor:MyMQTT/20/0/V_LIGHT_LEVEL:state:default]"}
                    

                    Try changing the first line of items like this above.. and in sitemap change node1_temp to node1_light

                    Also see if activating any of the switches in openhab publishes to myMQTT ?

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      C.r.a.z.y.
                      wrote on last edited by
                      #90

                      Restarting the modem and checking wires of arduino solved my problem before.
                      I am sure mqtt have to be in dhcp list.

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hooraysimpsons
                        wrote on last edited by hooraysimpsons
                        #91

                        I have restarted my router with no effect. The gateway still does not show up as an active client (using DDWRT) but I still have a connection from phone to gateway.

                        Added the above line. I've used one before like it but went back to what was given at the beggining of this thread to start anew. I also tried with the following edits
                        "Light Level"
                        "Light Level [%s]"
                        "Light Level [%.1f]"

                        None of which make a difference. The reason I think OpenHab doesn't even see the gateway is because nothing shows up in sketch name either which should work even if the above line was incorrect.

                        I have done the testing with the Android App turned off as well since I know OpenHab had some issues earlier if other clients were accessing the gateway.

                        I still see no reference to my gateway's IP in any of the OpenHab output/logs. So I'm not sure it is even trying.

                        The only error message in my openhab log is:
                        11:23:46.951 [ERROR] [sphere.cpr.AtmosphereFramework:2215 ] -

                        I tried clearing the EEPROM in the gateway. I changed it's Mac address and removed the DHCP lease for it from my router. Still no evidence of the gateway on my router status page but also still able to connect to it with my phone.

                        Another update:
                        I installed Mosquitto and I see the light sensor level using mosquitto_sub -h 192.168.1.134 -t MyMQTT

                        M 1 Reply Last reply
                        0
                        • H hooraysimpsons

                          I have restarted my router with no effect. The gateway still does not show up as an active client (using DDWRT) but I still have a connection from phone to gateway.

                          Added the above line. I've used one before like it but went back to what was given at the beggining of this thread to start anew. I also tried with the following edits
                          "Light Level"
                          "Light Level [%s]"
                          "Light Level [%.1f]"

                          None of which make a difference. The reason I think OpenHab doesn't even see the gateway is because nothing shows up in sketch name either which should work even if the above line was incorrect.

                          I have done the testing with the Android App turned off as well since I know OpenHab had some issues earlier if other clients were accessing the gateway.

                          I still see no reference to my gateway's IP in any of the OpenHab output/logs. So I'm not sure it is even trying.

                          The only error message in my openhab log is:
                          11:23:46.951 [ERROR] [sphere.cpr.AtmosphereFramework:2215 ] -

                          I tried clearing the EEPROM in the gateway. I changed it's Mac address and removed the DHCP lease for it from my router. Still no evidence of the gateway on my router status page but also still able to connect to it with my phone.

                          Another update:
                          I installed Mosquitto and I see the light sensor level using mosquitto_sub -h 192.168.1.134 -t MyMQTT

                          M Offline
                          M Offline
                          marceloaqno
                          Code Contributor
                          wrote on last edited by
                          #92

                          @hooraysimpsons Your gateway seems to be working fine. Do you see something like this on your openhab logs?

                          2015-02-27 17:48:06.349 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
                          2015-02-27 17:48:06.350 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mysensor'
                          
                          H 1 Reply Last reply
                          0
                          • M marceloaqno

                            @hooraysimpsons Your gateway seems to be working fine. Do you see something like this on your openhab logs?

                            2015-02-27 17:48:06.349 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
                            2015-02-27 17:48:06.350 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mysensor'
                            
                            H Offline
                            H Offline
                            hooraysimpsons
                            wrote on last edited by
                            #93

                            @celonunes Nope. I figured it out. In my openhab config file there was space prior to my MQTT related lines

                            " mqtt:mysensor.url=tcp://192.168.1.134:1883"
                            " mqtt:mysensor.clientId=OpenhabMQTT"
                            Instead of
                            "mqtt:mysensor.url=tcp://192.168.1.134:1883"
                            "mqtt:mysensor.clientId=OpenhabMQTT"

                            Removed the space and now I get my light sensor output value. I still don't get the sketch name coming through but I'll look into that later.

                            IdeasKickerI 1 Reply Last reply
                            1
                            • C Offline
                              C Offline
                              C.r.a.z.y.
                              wrote on last edited by C.r.a.z.y.
                              #94

                              @celonunes @hek
                              I installed this https://github.com/lurch/rpi-serial-console
                              pi@raspberrypi ~ $ rpi-serial-console status
                              Serial console on /dev/ttyAMA0 is disabled

                              Now my nodes are working perfect when i use manual button or ui but my logs are not correct

                              My config:

                              add on : org.openhab.binding.serial_1.6.0.201411271703.jar
                              String Arduino "Arduino" { serial="/dev/ttyUSB0" }

                              As you see there are "fails" but nodes are working.

                              015-03-09 12:37:51.725 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                              2015-03-09 12:37:56.726 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
                              52;255;0;0;18;1.4.1
                              0;0;3;0;9;read: 52-52-0 s=255,c=3,t=6,pt=1,l=1:0
                              52;255;3;0;6;0

                              2015-03-09 12:37:58.768 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=3,t=11,pt=0,l=14:Relay & Button
                              52;255;3;0;11;Relay & Button
                              0;0;3;0;9;read: 52-52-0 s=255,c=3,t=12,pt=0,l=3:1.0
                              52;255;3;0;12;1.0
                              0;0;3;0;9;read: 52-52-0 s=1,c=0,t=3,pt=0,l=5:1.4.1
                              52;1;0;0;3;1.4.1
                              0;0;3;0;9;read: 52-52-0 s=2,c=0,t=3,pt=0,l=5:1.4.1
                              52;2;0;0;3;1.4.1

                              2015-03-09 12:37:59.700 [INFO ] [runtime.busevents ] - S2 received command ON
                              2015-03-09 12:37:59.822 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

                              2015-03-09 12:38:00.106 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

                              2015-03-09 12:38:00.546 [INFO ] [runtime.busevents ] - S2 received command OFF
                              2015-03-09 12:38:00.661 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

                              2015-03-09 12:38:00.967 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                              2015-03-09 12:38:01.161 [INFO ] [runtime.busevents ] - S2 received command ON
                              2015-03-09 12:38:01.339 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

                              2015-03-09 12:38:01.649 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

                              2015-03-09 12:38:01.782 [INFO ] [runtime.busevents ] - S2 received command OFF
                              2015-03-09 12:38:01.894 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

                              2015-03-09 12:38:02.076 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                              M 1 Reply Last reply
                              0
                              • ChaoticC Offline
                                ChaoticC Offline
                                Chaotic
                                wrote on last edited by
                                #95

                                Just want to make sure I'm understanding this correctly since I feel the MQTT terminology is new to me.

                                The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?

                                I have the ethernet module ordered so I can't test myself yet.

                                M 1 Reply Last reply
                                0
                                • C C.r.a.z.y.

                                  @celonunes @hek
                                  I installed this https://github.com/lurch/rpi-serial-console
                                  pi@raspberrypi ~ $ rpi-serial-console status
                                  Serial console on /dev/ttyAMA0 is disabled

                                  Now my nodes are working perfect when i use manual button or ui but my logs are not correct

                                  My config:

                                  add on : org.openhab.binding.serial_1.6.0.201411271703.jar
                                  String Arduino "Arduino" { serial="/dev/ttyUSB0" }

                                  As you see there are "fails" but nodes are working.

                                  015-03-09 12:37:51.725 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                                  2015-03-09 12:37:56.726 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
                                  52;255;0;0;18;1.4.1
                                  0;0;3;0;9;read: 52-52-0 s=255,c=3,t=6,pt=1,l=1:0
                                  52;255;3;0;6;0

                                  2015-03-09 12:37:58.768 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=3,t=11,pt=0,l=14:Relay & Button
                                  52;255;3;0;11;Relay & Button
                                  0;0;3;0;9;read: 52-52-0 s=255,c=3,t=12,pt=0,l=3:1.0
                                  52;255;3;0;12;1.0
                                  0;0;3;0;9;read: 52-52-0 s=1,c=0,t=3,pt=0,l=5:1.4.1
                                  52;1;0;0;3;1.4.1
                                  0;0;3;0;9;read: 52-52-0 s=2,c=0,t=3,pt=0,l=5:1.4.1
                                  52;2;0;0;3;1.4.1

                                  2015-03-09 12:37:59.700 [INFO ] [runtime.busevents ] - S2 received command ON
                                  2015-03-09 12:37:59.822 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

                                  2015-03-09 12:38:00.106 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

                                  2015-03-09 12:38:00.546 [INFO ] [runtime.busevents ] - S2 received command OFF
                                  2015-03-09 12:38:00.661 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

                                  2015-03-09 12:38:00.967 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                                  2015-03-09 12:38:01.161 [INFO ] [runtime.busevents ] - S2 received command ON
                                  2015-03-09 12:38:01.339 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

                                  2015-03-09 12:38:01.649 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

                                  2015-03-09 12:38:01.782 [INFO ] [runtime.busevents ] - S2 received command OFF
                                  2015-03-09 12:38:01.894 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

                                  2015-03-09 12:38:02.076 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                                  M Offline
                                  M Offline
                                  marceloaqno
                                  Code Contributor
                                  wrote on last edited by
                                  #96

                                  @C.r.a.z.y. You are using the raspberry serial port to connect the openhab with the arduino and the arduino is running the SerialGateway sketch, is that right?

                                  1 Reply Last reply
                                  0
                                  • ChaoticC Chaotic

                                    Just want to make sure I'm understanding this correctly since I feel the MQTT terminology is new to me.

                                    The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?

                                    I have the ethernet module ordered so I can't test myself yet.

                                    M Offline
                                    M Offline
                                    marceloaqno
                                    Code Contributor
                                    wrote on last edited by
                                    #97

                                    @Chaotic said:

                                    The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?

                                    That's right.

                                    ChaoticC M 2 Replies Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      msebbe
                                      wrote on last edited by msebbe
                                      #98

                                      I have ENC28J60-I/SO connected by ethernetcable to my Asus RT-n66u in LAN 4. But It will not show up in my router... On my ENC28J60 there is a red light on D1 and the ethernet port has a green light and a yellow flashing light.

                                      Serial monitor says "
                                      Started!
                                      0;0;3;0;9;read: 20-20-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
                                      0;0;3;0;9;read: 20-20-0 s=255,c=3,t=6,pt=1,l=1:0
                                      0;0;3;0;9;send: 0-0-20-20 s=255,c=3,t=6,pt=0,l=1,st=ok:M
                                      0;0;3;0;9;read: 20-20-0 s=255,c=3,t=11,pt=0,l=18:Temperature Sensor
                                      0;0;3;0;9;read: 20-20-0 s=255,c=3,t=12,pt=0,l=3:1.0

                                      . But nothing more. I have followed the MQTT gateway guide and set an static ip in the sketch.. DHCP is on in my router.

                                      The only thing I see in my router is : That the cable is connected to something and that its 10 Half duplex.

                                      I have also tried to connect it to other LAN ports but no difference

                                      What could be wrong?

                                      M 1 Reply Last reply
                                      0
                                      • M msebbe

                                        I have ENC28J60-I/SO connected by ethernetcable to my Asus RT-n66u in LAN 4. But It will not show up in my router... On my ENC28J60 there is a red light on D1 and the ethernet port has a green light and a yellow flashing light.

                                        Serial monitor says "
                                        Started!
                                        0;0;3;0;9;read: 20-20-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
                                        0;0;3;0;9;read: 20-20-0 s=255,c=3,t=6,pt=1,l=1:0
                                        0;0;3;0;9;send: 0-0-20-20 s=255,c=3,t=6,pt=0,l=1,st=ok:M
                                        0;0;3;0;9;read: 20-20-0 s=255,c=3,t=11,pt=0,l=18:Temperature Sensor
                                        0;0;3;0;9;read: 20-20-0 s=255,c=3,t=12,pt=0,l=3:1.0

                                        . But nothing more. I have followed the MQTT gateway guide and set an static ip in the sketch.. DHCP is on in my router.

                                        The only thing I see in my router is : That the cable is connected to something and that its 10 Half duplex.

                                        I have also tried to connect it to other LAN ports but no difference

                                        What could be wrong?

                                        M Offline
                                        M Offline
                                        marceloaqno
                                        Code Contributor
                                        wrote on last edited by
                                        #99

                                        @msebbe Did you try to ping the gateway static IP?

                                        M 1 Reply Last reply
                                        0
                                        • M marceloaqno

                                          @msebbe Did you try to ping the gateway static IP?

                                          M Offline
                                          M Offline
                                          msebbe
                                          wrote on last edited by msebbe
                                          #100

                                          @celonunes

                                          Yes, both from windows cmd and from the router ui with this result:

                                          PING 192.168.1.197 (192.168.1.197): 56 data bytes

                                          --- 192.168.1.197 ping statistics ---
                                          5 packets transmitted, 0 packets received, 100% packet loss

                                          Could be that I have not changed the MAC adress cause I tried to figure out how to do it but I dont understand this part from the MQTT gateway sketch:

                                          *1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.

                                           #define TCP_PORT 1883						// Set your MQTT Broker Listening port.
                                           IPAddress TCP_IP ( 192, 168, 1, 197 );				// Configure your static ip-address here
                                           uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 };	// Mac-address - You should change this! see note *2 above!
                                          
                                          M 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          15

                                          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