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.
  • 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
                • M msebbe

                  @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 Offline
                  M Offline
                  marceloaqno
                  Code Contributor
                  wrote on last edited by
                  #101

                  @msebbe Which library your are using for the ENC28J60? The UIPEthernet has some examples you could try to test if your module is working.

                  M 1 Reply Last reply
                  1
                  • M marceloaqno

                    @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 Offline
                    ChaoticC Offline
                    Chaotic
                    wrote on last edited by
                    #102

                    @celonunes
                    Just wanted to say I was able to get this working.

                    Also found a nice little MQTT utility that makes it easy to see the messages being sent from the broker/openhab.

                    I'm sure I'll have more questions but most of my hardware is still on a boat from china so will be a little while till I discover them.

                    1 Reply Last reply
                    0
                    • M marceloaqno

                      @msebbe Which library your are using for the ENC28J60? The UIPEthernet has some examples you could try to test if your module is working.

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

                      @celonunes In the Mqtt broker sketch, Ethernet.h was included. I suppose it should be UIPEthernet.h for me? So I tried that but nothing.

                      I had better luck with the UIPEthernet examples, there my arduino shows up with an ip and mac adress.. Hmmm.

                      edit:

                      So after using UIPEthernet "Advanced chat server" sketch, the MAC and IP showed up in my router. When I then tried with the MQTT sketch with UIPEthernet.h it would not work. So then I tried to copy the MAC and IP I used in the chat server sketch into the Mqtt sketch and bom! I can now ping it, so I guess it works now?

                      edit2: Should it say anything more then "Started!" on serial monitor? Like "on ip 192.168.1.197" or something like that? Since Im now trying the MQTT in pidome as I know how to use pidome better. Pidome states;
                      Connected: Yes, with 192.168.1.197:1883 at topic: MyMQTT/# (without subscribe promise)
                      Last receive time: 00-00-0000 00:00
                      Last send time: 00-00-0000 00:00

                      This is what Serial monitor says http://i61.tinypic.com/i252kn.png

                      But when I use device discovery it cannot find the temperature sensor that could be found using the serial gateway :/

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

                        Hi everyone,

                        Finally got this working but had a couple of quetions

                        Does the MQTT Broker gateway not handle requests for time? I currently have a node that I'm using as an alarm clock which has a RTC module. I had hoped to be able to update the time via the gateway and polling the time from one of my computers which are connected to NTP servers but the message never seems to get put on a MQTT message so I can't have a computer respond to it.

                        M 1 Reply Last reply
                        0
                        • M msebbe

                          @celonunes In the Mqtt broker sketch, Ethernet.h was included. I suppose it should be UIPEthernet.h for me? So I tried that but nothing.

                          I had better luck with the UIPEthernet examples, there my arduino shows up with an ip and mac adress.. Hmmm.

                          edit:

                          So after using UIPEthernet "Advanced chat server" sketch, the MAC and IP showed up in my router. When I then tried with the MQTT sketch with UIPEthernet.h it would not work. So then I tried to copy the MAC and IP I used in the chat server sketch into the Mqtt sketch and bom! I can now ping it, so I guess it works now?

                          edit2: Should it say anything more then "Started!" on serial monitor? Like "on ip 192.168.1.197" or something like that? Since Im now trying the MQTT in pidome as I know how to use pidome better. Pidome states;
                          Connected: Yes, with 192.168.1.197:1883 at topic: MyMQTT/# (without subscribe promise)
                          Last receive time: 00-00-0000 00:00
                          Last send time: 00-00-0000 00:00

                          This is what Serial monitor says http://i61.tinypic.com/i252kn.png

                          But when I use device discovery it cannot find the temperature sensor that could be found using the serial gateway :/

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

                          @msebbe It doesn't print your ip, those numbers after "Started!" is related to mqtt packages showing that PiDome is connected.
                          For the device discovery, there are probably a lot of other people who can help you with that because I don't know much about PiDome.

                          1 Reply Last reply
                          1
                          • ChaoticC Chaotic

                            Hi everyone,

                            Finally got this working but had a couple of quetions

                            Does the MQTT Broker gateway not handle requests for time? I currently have a node that I'm using as an alarm clock which has a RTC module. I had hoped to be able to update the time via the gateway and polling the time from one of my computers which are connected to NTP servers but the message never seems to get put on a MQTT message so I can't have a computer respond to it.

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

                            @Chaotic MQTT Broker gateway doesn't handle time requests.

                            1 Reply Last reply
                            0
                            • M marceloaqno

                              @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.

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

                              @celonunes Ok, thanks! I got the discovery working by just rebuilding the same sensor from scratch!

                              Sorry for so many questions.. But I have now changed to Openhab and got it working with my MQTT gateway. Now Another problem appear:

                              http://i60.tinypic.com/2d2eqzk.png[/IMG

                              I would like to display the temperature in °C like in your guide sketch (wich I am using) but instead it looks like in the picture. Same thing about humidity, why is it like this?

                              Edit: For anyone wondering, I solved the issue with the degree symbol not showing up properly by replacing "°C" with "& deg;C" without space between & deg

                              1 Reply Last reply
                              0
                              • Brett JenkinsB Offline
                                Brett JenkinsB Offline
                                Brett Jenkins
                                wrote on last edited by
                                #108

                                Hi Folks,

                                New to mysensors and am impressed. I've been playing with OpenHAB and MQTT so this sounds like an interesting project. My question though, which might have been answered but I'm finding it hard to find the answer, is - is this bidirectional? As in if I had a 'sensor' on the Arduino network and that went over the radio network, hit the gateway and then got picked up by OpenHAB, could I then, if I had a 'actuator' or a 'do-er' node on the network, send a message to MQTT from OpenHAB to change the status of that actuator device? So for instance to start a motor controlling blinds for instance? Or is it a read only system?

                                Thanks

                                ChaoticC 1 Reply Last reply
                                0
                                • Brett JenkinsB Brett Jenkins

                                  Hi Folks,

                                  New to mysensors and am impressed. I've been playing with OpenHAB and MQTT so this sounds like an interesting project. My question though, which might have been answered but I'm finding it hard to find the answer, is - is this bidirectional? As in if I had a 'sensor' on the Arduino network and that went over the radio network, hit the gateway and then got picked up by OpenHAB, could I then, if I had a 'actuator' or a 'do-er' node on the network, send a message to MQTT from OpenHAB to change the status of that actuator device? So for instance to start a motor controlling blinds for instance? Or is it a read only system?

                                  Thanks

                                  ChaoticC Offline
                                  ChaoticC Offline
                                  Chaotic
                                  wrote on last edited by
                                  #109

                                  @Brett-Jenkins

                                  It works both ways.

                                  1 Reply Last reply
                                  0
                                  • Brett JenkinsB Offline
                                    Brett JenkinsB Offline
                                    Brett Jenkins
                                    wrote on last edited by
                                    #110

                                    Thanks :)

                                    1 Reply Last reply
                                    0
                                    • K Offline
                                      K Offline
                                      kunall
                                      wrote on last edited by kunall
                                      #111

                                      How can I implement MQTT for MQ-2 Gas sensor the correct way? In the mysensor sketch there is only one child ID and one V_VAR1 but 3 different outputs: LPG, CO and Smoke? I'm only receiving CO value and not all 3 in openhab.

                                      ChaoticC 1 Reply Last reply
                                      0
                                      • K kunall

                                        How can I implement MQTT for MQ-2 Gas sensor the correct way? In the mysensor sketch there is only one child ID and one V_VAR1 but 3 different outputs: LPG, CO and Smoke? I'm only receiving CO value and not all 3 in openhab.

                                        ChaoticC Offline
                                        ChaoticC Offline
                                        Chaotic
                                        wrote on last edited by
                                        #112

                                        @kunall There is V_VAR1-5 actually

                                        V_VAR1	24	Custom value
                                        V_VAR2	25	Custom value
                                        V_VAR3	26	Custom value
                                        V_VAR4	27	Custom value
                                        V_VAR5	28	Custom value
                                        

                                        Personally I would set up each value you want as a S_CUSTOM if you can't figure out another sensor type that fits.

                                        For smoke you can use S_SMOKE
                                        For Air Quality S_AIR_QUALITY
                                        Not sure what you'd want to use for CO2 through

                                        http://www.mysensors.org/download/serial_api_14

                                        K 1 Reply Last reply
                                        0
                                        • ChaoticC Chaotic

                                          @kunall There is V_VAR1-5 actually

                                          V_VAR1	24	Custom value
                                          V_VAR2	25	Custom value
                                          V_VAR3	26	Custom value
                                          V_VAR4	27	Custom value
                                          V_VAR5	28	Custom value
                                          

                                          Personally I would set up each value you want as a S_CUSTOM if you can't figure out another sensor type that fits.

                                          For smoke you can use S_SMOKE
                                          For Air Quality S_AIR_QUALITY
                                          Not sure what you'd want to use for CO2 through

                                          http://www.mysensors.org/download/serial_api_14

                                          K Offline
                                          K Offline
                                          kunall
                                          wrote on last edited by kunall
                                          #113

                                          @Chaotic Thanks! I will try this and get back with result.

                                          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.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