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. Troubleshooting
  3. N00b + MQTT gw + openHAB2

N00b + MQTT gw + openHAB2

Scheduled Pinned Locked Moved Troubleshooting
26 Posts 5 Posters 6.8k Views 5 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.
  • gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by gohan
    #2

    To make things simple I'd start by using the ethernet gateway and Domoticz as controller. Once you have everything running and understood how things work you can move to mqtt and then add openhab.
    Adding relays to gateway is not a problem, you can control the relay just by setting digital pin high or low

    Ps when you add code, use the code tag

    1 Reply Last reply
    0
    • MasMatM Offline
      MasMatM Offline
      MasMat
      wrote on last edited by
      #3

      Thanks, will try. Sorry about the code flood :pensive:
      Should I try to include the code for the two relays or without? I dont have any other sensors yet to test with.
      Also I cant figure if i need to use UDP or not?
      Set the controller IP or not?

      1 Reply Last reply
      0
      • gohanG Offline
        gohanG Offline
        gohan
        Mod
        wrote on last edited by
        #4

        To check mqtt is working you don't need controller, but if you want some easy interaction try first as I suggested: easy steps. I wanted to start with Openhab too, but it was too much complicated for a beginner while domoticz was much simpler to connect to mysensors

        1 Reply Last reply
        0
        • pansenP Offline
          pansenP Offline
          pansen
          wrote on last edited by
          #5

          I do not fully understand why you are using MQTT. Can you quickly sketch your setup in a block diagram?

          If you want a quick setup for starters, go for

          Laptop <-> Serial Gateway Arduino <-> nrf24 ******** nrf24<->Arduino<->Relay

          then get OH2 up and running. If you use pure MQTT you don't need the MySensors binding because everything is going through the MQTT broker (mosquitto). I recently started playing with MQTT and it is way more complex than above suggested setup because you need to manually play with configs etc.

          I remember I had problems with OH2 because some java stuff was missing/not functioning. See the threads on this forum and the OH2 forums.

          Laptop is suitable, just think about the power consumption. If you let it running 24/7 I'd consider getting a (even older) Raspberry Pi. The costs will be amortized quickly. (Let's say 30W * 24h * 365d * 0.25ct/kWh = 66EUR meaning RPi will be amortized in 6 months).

          Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

          gohanG 1 Reply Last reply
          0
          • pansenP pansen

            I do not fully understand why you are using MQTT. Can you quickly sketch your setup in a block diagram?

            If you want a quick setup for starters, go for

            Laptop <-> Serial Gateway Arduino <-> nrf24 ******** nrf24<->Arduino<->Relay

            then get OH2 up and running. If you use pure MQTT you don't need the MySensors binding because everything is going through the MQTT broker (mosquitto). I recently started playing with MQTT and it is way more complex than above suggested setup because you need to manually play with configs etc.

            I remember I had problems with OH2 because some java stuff was missing/not functioning. See the threads on this forum and the OH2 forums.

            Laptop is suitable, just think about the power consumption. If you let it running 24/7 I'd consider getting a (even older) Raspberry Pi. The costs will be amortized quickly. (Let's say 30W * 24h * 365d * 0.25ct/kWh = 66EUR meaning RPi will be amortized in 6 months).

            gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #6

            @pansen he is using mysensors mqtt gateway.

            1 Reply Last reply
            0
            • pansenP Offline
              pansenP Offline
              pansen
              wrote on last edited by
              #7

              @gohan: I understand but what's the incentive? It's more easy to plug the Arduino via USB and do serial gateway than fiddling with MQTT and network stuff.

              Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

              gohanG 1 Reply Last reply
              0
              • pansenP pansen

                @gohan: I understand but what's the incentive? It's more easy to plug the Arduino via USB and do serial gateway than fiddling with MQTT and network stuff.

                gohanG Offline
                gohanG Offline
                gohan
                Mod
                wrote on last edited by
                #8

                @pansen ethernet has better advantages IMHO

                1 Reply Last reply
                0
                • MasMatM Offline
                  MasMatM Offline
                  MasMat
                  wrote on last edited by MasMat
                  #9

                  I ran into NodeRed and thought it would be easy to do mqtt-functions (button press somewhere => do something elsewhere) using that and skipping coding.

                  I thought the serial gateway would be a hassle in terms of testing. Thought NodeRed would ease the early testing part. Plus I want to be able to access the system from the net to check/control everything (I have DNS already). That's prob all the same.

                  Upon @gohan recommendation, I wrote/tuned the ethernet sketch (see couple questions above) and "installed" Domoticz but as the compiling took SO LONG, I didn't have time to test it (weekend getaway house:grinning: ).

                  I had an extra minilaptop lying around, installed Lubuntu on it. Thought it'd have a better life upcycled than thrown out. I have a diy UPS-system (+wind power coming) that powers the whole thing so I didnt want to buy new stuff.
                  Plus, I've built the gateway, so I'd rather get it working.

                  ++ if the controller breaks or locks up, I'd have a way to access & control the system with MQTT.... <= further thought: wont work right?

                  1 Reply Last reply
                  0
                  • gohanG Offline
                    gohanG Offline
                    gohan
                    Mod
                    wrote on last edited by
                    #10

                    If you want to play with node red, at the moment it is not supporting mysensors over mqtt but only serial and ethernet. Then depending on the level of integration and automation you want to have, there are different solutions: if you want some basic control of Arduino IO ports over Internet with a nice app, you could use cayenne, but if you want to have multiple wireless sensors and automation you'd better stay with mysensors and domoticz and start getting some experience; later on you can start looking at more complex scenarios.

                    MasMatM 1 Reply Last reply
                    0
                    • gohanG gohan

                      If you want to play with node red, at the moment it is not supporting mysensors over mqtt but only serial and ethernet. Then depending on the level of integration and automation you want to have, there are different solutions: if you want some basic control of Arduino IO ports over Internet with a nice app, you could use cayenne, but if you want to have multiple wireless sensors and automation you'd better stay with mysensors and domoticz and start getting some experience; later on you can start looking at more complex scenarios.

                      MasMatM Offline
                      MasMatM Offline
                      MasMat
                      wrote on last edited by
                      #11

                      @gohan Totally agree.
                      I'll push forward with your recommendations: ethernet+domoticz. After looking into Domo, I think it could serve me well for my purposes as a whole.
                      Any ideas about the code for the gateway: udp? controller ip? relays?
                      I will build one more Mysensors relay so I can verify radio working etc.

                      1 Reply Last reply
                      0
                      • gohanG Offline
                        gohanG Offline
                        gohan
                        Mod
                        wrote on last edited by
                        #12

                        Your sketch seems ok, just make it ethernet gateway instead of mqtt.
                        UDP and controller IP are nor necessary.

                        1 Reply Last reply
                        0
                        • Q Offline
                          Q Offline
                          Qu3Uk
                          wrote on last edited by
                          #13

                          I use MQTT and Openhab2 - I find it more flexible then the Ethernet GW but yes you need to have a good understanding on all systems I suppose.

                          Somethings to note

                          • MySensors binding doesn't support MQTT gateway as far as I know, you need to use the MQTT binding and configure your OH items accordingly.
                          • MySensors binding is in the IOT market place and not openhab-addons
                          • You'll need to assign node ID to your nodes manually.

                          Not entirely sure what your problem is here but don't think you've got all the right pieces for the puzzle yet.

                          gohanG 1 Reply Last reply
                          0
                          • Q Qu3Uk

                            I use MQTT and Openhab2 - I find it more flexible then the Ethernet GW but yes you need to have a good understanding on all systems I suppose.

                            Somethings to note

                            • MySensors binding doesn't support MQTT gateway as far as I know, you need to use the MQTT binding and configure your OH items accordingly.
                            • MySensors binding is in the IOT market place and not openhab-addons
                            • You'll need to assign node ID to your nodes manually.

                            Not entirely sure what your problem is here but don't think you've got all the right pieces for the puzzle yet.

                            gohanG Offline
                            gohanG Offline
                            gohan
                            Mod
                            wrote on last edited by
                            #14

                            @Qu3Uk I remember that Mysensors binding works both ethernet and MQTT, but anyway ethernet is the best solution for beginners because you can use myscontroller to debug messages while connected to controller.

                            Q E 2 Replies Last reply
                            0
                            • gohanG gohan

                              @Qu3Uk I remember that Mysensors binding works both ethernet and MQTT, but anyway ethernet is the best solution for beginners because you can use myscontroller to debug messages while connected to controller.

                              Q Offline
                              Q Offline
                              Qu3Uk
                              wrote on last edited by
                              #15

                              @gohan Ah really? I've loosely been following last i saw there was a proof of concept mentioned.

                              1 Reply Last reply
                              0
                              • gohanG gohan

                                @Qu3Uk I remember that Mysensors binding works both ethernet and MQTT, but anyway ethernet is the best solution for beginners because you can use myscontroller to debug messages while connected to controller.

                                E Offline
                                E Offline
                                ericvdb
                                wrote on last edited by ericvdb
                                #16

                                @gohan said in N00b + MQTT gw + openHAB2:

                                but anyway ethernet is the best solution for beginners because you can use myscontroller to debug messages while connected to controller.

                                With MQTT you can also debug using MQTT-Spy or MQTTLens or various other MQTT apps.

                                MQTT is easy in interconnecting various systems without they have to know about each-other.

                                As long as you have a MQTT broker (RabbitMQ, Mosquitto, ActiveMQ, ...) you're all set.

                                In OpenHab in conf/services create a file called mqtt.cfg, and past the following:

                                mqtt:broker.url=tcp://ip-address-of-mqttbroker:1883
                                mqtt:broker.clientId=openhab
                                mqtt:broker.retain=true
                                mqtt:broker.async=false
                                

                                Then in your items file you can do:

                                Switch Light_GV_Hall    			"Ceiling"       	(GV_Hall, Lights) {mqtt=">[broker:myhome/room/switch1:command:ON:1],>[broker:myhome/room/switch1:command:OFF:0],<[broker:myhome/room/switch1:state:ON:1],<[broker:myhome/room/switch1:state:OFF:0"}
                                

                                And now you can turn on/off the light from OpenHab as wel as from any other device that publishes to the same toppic (yes, even from MQTT-Spy and MQTTLens)

                                gohanG 1 Reply Last reply
                                0
                                • E ericvdb

                                  @gohan said in N00b + MQTT gw + openHAB2:

                                  but anyway ethernet is the best solution for beginners because you can use myscontroller to debug messages while connected to controller.

                                  With MQTT you can also debug using MQTT-Spy or MQTTLens or various other MQTT apps.

                                  MQTT is easy in interconnecting various systems without they have to know about each-other.

                                  As long as you have a MQTT broker (RabbitMQ, Mosquitto, ActiveMQ, ...) you're all set.

                                  In OpenHab in conf/services create a file called mqtt.cfg, and past the following:

                                  mqtt:broker.url=tcp://ip-address-of-mqttbroker:1883
                                  mqtt:broker.clientId=openhab
                                  mqtt:broker.retain=true
                                  mqtt:broker.async=false
                                  

                                  Then in your items file you can do:

                                  Switch Light_GV_Hall    			"Ceiling"       	(GV_Hall, Lights) {mqtt=">[broker:myhome/room/switch1:command:ON:1],>[broker:myhome/room/switch1:command:OFF:0],<[broker:myhome/room/switch1:state:ON:1],<[broker:myhome/room/switch1:state:OFF:0"}
                                  

                                  And now you can turn on/off the light from OpenHab as wel as from any other device that publishes to the same toppic (yes, even from MQTT-Spy and MQTTLens)

                                  gohanG Offline
                                  gohanG Offline
                                  gohan
                                  Mod
                                  wrote on last edited by
                                  #17

                                  @ericvdb I know, I am talking for a beginner perspective. The more advanced users know how to debug over mqtt and stuff

                                  1 Reply Last reply
                                  0
                                  • MasMatM Offline
                                    MasMatM Offline
                                    MasMat
                                    wrote on last edited by
                                    #18

                                    Update.
                                    After much trying the Ethernet gw would not connect to Domoticz.
                                    Then, tried my mqtt sketch again and presto! I have connection AND I can control the two relays on board the mqtt-gw.
                                    Had a cold one...or four!
                                    Thanks for the recommendations and help. I'm sure I will need more later on. Now I'm going to explore the Domoticz forum for answers.
                                    Unless someone with the same setup can tell me why the lights are crossed (on = off in reality and off=light on)?

                                    1 Reply Last reply
                                    0
                                    • gohanG Offline
                                      gohanG Offline
                                      gohan
                                      Mod
                                      wrote on last edited by
                                      #19

                                      Depends on relay board

                                      1 Reply Last reply
                                      0
                                      • MasMatM Offline
                                        MasMatM Offline
                                        MasMat
                                        wrote on last edited by
                                        #20

                                        I just have the modules. low=relay on.
                                        I think it would be easier to change it in Domoticz or do I have to change it in the sketches (I think this will be more work when I add new sensors and relays)?

                                        1 Reply Last reply
                                        0
                                        • gohanG Offline
                                          gohanG Offline
                                          gohan
                                          Mod
                                          wrote on last edited by
                                          #21

                                          Just do everything in code so you present relay status not pin status

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


                                          12

                                          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