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. Mysensors MQTT gateway

Mysensors MQTT gateway

Scheduled Pinned Locked Moved Development
17 Posts 5 Posters 8.7k Views 2 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.
  • DammeD Damme

    @Yveaux Yes this is correct.

    I have not considerd MQTT tree yet, The only program I've tested MQTT on is openhab and it dont really care.
    I could have a fixed defined string in the code, and separating the node and sensor with /
    so, [FixedString]/04/01 for sensor 1 on node 4. I am thinking of just ignoring the Messagetype and subtype (command) (just using 1, C_SET).
    The only data that uses more messagetypes on one sensor gw.sendSketchInfo("Test Sensor", "1.0"); what I know of. They have subtype 3(C_INTERNAL) (could be ignored because they sends on sensor 255) and then only send I_SKETCH_NAME to MQTT, I_SKETCH_VERSION could be ignored and if this is important we could just move 1.0 onto the sketch name.
    ofcorse we could use MessageType and SubType also, something like "[FixedString]/04/01/01/01"

    are there any other MQTT client software's out there easy to use to check communication with the MQTTGateway?

    //Daniel

    YveauxY Offline
    YveauxY Offline
    Yveaux
    Mod
    wrote on last edited by
    #4

    @Damme said:

    are there any other MQTT client software's out there easy to use to check communication with the MQTTGateway?

    I have only tried mosquito so far, which is a broker, but come with command line tools mosquitto_pub and mosquitto_sub to resp. publish /subscribe.
    Works like a treat, also with my perl gateway implementation.

    There's also MQTT-sn, a work in progress, which specifically targets sensor networks - like we do.

    http://yveaux.blogspot.nl

    DammeD 1 Reply Last reply
    0
    • YveauxY Yveaux

      @Damme said:

      are there any other MQTT client software's out there easy to use to check communication with the MQTTGateway?

      I have only tried mosquito so far, which is a broker, but come with command line tools mosquitto_pub and mosquitto_sub to resp. publish /subscribe.
      Works like a treat, also with my perl gateway implementation.

      There's also MQTT-sn, a work in progress, which specifically targets sensor networks - like we do.

      DammeD Offline
      DammeD Offline
      Damme
      Code Contributor
      wrote on last edited by
      #5

      @Yveaux I forgot to mention that this is also a Broker (Server) and openhab is the client.

      1 Reply Last reply
      0
      • DammeD Damme

        @Yveaux Yes this is correct.

        I have not considerd MQTT tree yet, The only program I've tested MQTT on is openhab and it dont really care.
        I could have a fixed defined string in the code, and separating the node and sensor with /
        so, [FixedString]/04/01 for sensor 1 on node 4. I am thinking of just ignoring the Messagetype and subtype (command) (just using 1, C_SET).
        The only data that uses more messagetypes on one sensor gw.sendSketchInfo("Test Sensor", "1.0"); what I know of. They have subtype 3(C_INTERNAL) (could be ignored because they sends on sensor 255) and then only send I_SKETCH_NAME to MQTT, I_SKETCH_VERSION could be ignored and if this is important we could just move 1.0 onto the sketch name.
        ofcorse we could use MessageType and SubType also, something like "[FixedString]/04/01/01/01"

        are there any other MQTT client software's out there easy to use to check communication with the MQTTGateway?

        //Daniel

        YveauxY Offline
        YveauxY Offline
        Yveaux
        Mod
        wrote on last edited by
        #6

        @Damme said:

        something like "[FixedString]/04/01/01/01"

        I would definitely split the address like you suggest. This is in line with MQTT hierarchical structure and allows subscription to subtrees etc.
        Using names instead of values also allows subscribing to e.g. all 'TEMP' values in a single run, which might be beneficial, depending on the application. It also helps in decoupling from MySensors details.
        If you find a way (manage to fit it in the atmega's memory) to translate the sensor types etc to textual presentations then please do so.

        http://yveaux.blogspot.nl

        DammeD 1 Reply Last reply
        0
        • YveauxY Yveaux

          @Damme said:

          something like "[FixedString]/04/01/01/01"

          I would definitely split the address like you suggest. This is in line with MQTT hierarchical structure and allows subscription to subtrees etc.
          Using names instead of values also allows subscribing to e.g. all 'TEMP' values in a single run, which might be beneficial, depending on the application. It also helps in decoupling from MySensors details.
          If you find a way (manage to fit it in the atmega's memory) to translate the sensor types etc to textual presentations then please do so.

          DammeD Offline
          DammeD Offline
          Damme
          Code Contributor
          wrote on last edited by Damme
          #7

          @Yveaux To include textual presentation:
          String PROGMEM s_presentation[] = {"S_DOOR", "S_MOTION", "S_SMOKE", "S_LIGHT", "S_DIMMER", "S_COVER", "S_TEMP", "S_HUM", "S_BARO", "S_WIND",
          "S_RAIN", "S_UV", "S_WEIGHT", "S_POWER", "S_HEATER", "S_DISTANCE", "S_LIGHT_LEVEL", "S_ARDUINO_NODE",
          "S_ARDUINO_REPEATER_NODE", "S_LOCK", "S_IR", "S_WATER", "S_AIR_QUALITY"};
          eats exacly 1592 extra bytes just for the definition (a bit more if we are going to write "S_TEMPERATURE" insted of only "S_TEMP")..
          My thought was almost to just skip those completly and just use [FixedString]/NodeID/SensorID .. In openhab I group stuff in the items-conf and can make groups like I wish, but other programs might work differently.. maybe I should install mosquito and see how they do..

          edit: should be "PROGMEM const char *string_table[] =" or something instead.. but the size shouldn't be much different, we are talking 1.5-2kB extra program size (5-7%)

          YveauxY Z 2 Replies Last reply
          0
          • DammeD Damme

            @Yveaux To include textual presentation:
            String PROGMEM s_presentation[] = {"S_DOOR", "S_MOTION", "S_SMOKE", "S_LIGHT", "S_DIMMER", "S_COVER", "S_TEMP", "S_HUM", "S_BARO", "S_WIND",
            "S_RAIN", "S_UV", "S_WEIGHT", "S_POWER", "S_HEATER", "S_DISTANCE", "S_LIGHT_LEVEL", "S_ARDUINO_NODE",
            "S_ARDUINO_REPEATER_NODE", "S_LOCK", "S_IR", "S_WATER", "S_AIR_QUALITY"};
            eats exacly 1592 extra bytes just for the definition (a bit more if we are going to write "S_TEMPERATURE" insted of only "S_TEMP")..
            My thought was almost to just skip those completly and just use [FixedString]/NodeID/SensorID .. In openhab I group stuff in the items-conf and can make groups like I wish, but other programs might work differently.. maybe I should install mosquito and see how they do..

            edit: should be "PROGMEM const char *string_table[] =" or something instead.. but the size shouldn't be much different, we are talking 1.5-2kB extra program size (5-7%)

            YveauxY Offline
            YveauxY Offline
            Yveaux
            Mod
            wrote on last edited by Yveaux
            #8

            @Damme drop the 'S_' prefix saves you 2 bytes per item. I just managed to squeeze it In...

            That's when I figured I still have to do some 'glueing' somewhere on a more capable device (rpi, server,...) which could just as well directly talk to the unmodified ethernet or serial gateway from MySensors... So why go through all the hassle to squeeze it all in a small arduino?

            http://yveaux.blogspot.nl

            1 Reply Last reply
            0
            • DammeD Damme

              Hello

              MQTT Gateway for mysensors.

              https://github.com/Damme/MyMQTT

              Requires mysensors lib 1.4b

              //Daniel

              DammeD Offline
              DammeD Offline
              Damme
              Code Contributor
              wrote on last edited by
              #9

              Made some major changes, Too tired to write them down. It should be working to be tested out atleast. I have not implemented any auto node id designation yet. I have the code but have a bug to sort out first.

              new address is (openhab): {mqtt="<[my:MyMQTT/042/001/Temperature:state:default]"}

              and openhab supports wildcard ; {mqtt="<[my:MyMQTT/042/#/Humidity:state:default]"}
              for example.
              Definition is in MyMQTT.cpp

              1 Reply Last reply
              0
              • DammeD Damme

                @Yveaux To include textual presentation:
                String PROGMEM s_presentation[] = {"S_DOOR", "S_MOTION", "S_SMOKE", "S_LIGHT", "S_DIMMER", "S_COVER", "S_TEMP", "S_HUM", "S_BARO", "S_WIND",
                "S_RAIN", "S_UV", "S_WEIGHT", "S_POWER", "S_HEATER", "S_DISTANCE", "S_LIGHT_LEVEL", "S_ARDUINO_NODE",
                "S_ARDUINO_REPEATER_NODE", "S_LOCK", "S_IR", "S_WATER", "S_AIR_QUALITY"};
                eats exacly 1592 extra bytes just for the definition (a bit more if we are going to write "S_TEMPERATURE" insted of only "S_TEMP")..
                My thought was almost to just skip those completly and just use [FixedString]/NodeID/SensorID .. In openhab I group stuff in the items-conf and can make groups like I wish, but other programs might work differently.. maybe I should install mosquito and see how they do..

                edit: should be "PROGMEM const char *string_table[] =" or something instead.. but the size shouldn't be much different, we are talking 1.5-2kB extra program size (5-7%)

                Z Offline
                Z Offline
                Zeph
                Hero Member
                wrote on last edited by
                #10

                @Damme said:

                String PROGMEM s_presentation[] = {"S_DOOR", "S_MOTION", "S_SMOKE", "S_LIGHT", "S_DIMMER", "S_COVER", "S_TEMP", "S_HUM", "S_BARO", "S_WIND",
                "S_RAIN", "S_UV", "S_WEIGHT", "S_POWER", "S_HEATER", "S_DISTANCE", "S_LIGHT_LEVEL", "S_ARDUINO_NODE",
                "S_ARDUINO_REPEATER_NODE", "S_LOCK", "S_IR", "S_WATER", "S_AIR_QUALITY"};
                eats exacly 1592 extra bytes just for the definition (a bit more if we are going to write "S_TEMPERATURE" insted of only "S_TEMP").

                I don't get why it would be that high - at a quick guess those 24 strings should use less than 300 bytes including the pointers and nul terminators. Are they being repeated many times or is there some additional library which gets pulled in when you use them?

                By the way, if you want the strings themselves in progmem (and not just the array of pointers to strings), I think you may need to use different techniques. http://arduino.cc/en/Reference/PROGMEM

                But that's about how much RAM you use; I still don't understand why those two dozen strings would take up 1.5 KBytes of flash.

                DammeD 1 Reply Last reply
                0
                • Z Zeph

                  @Damme said:

                  String PROGMEM s_presentation[] = {"S_DOOR", "S_MOTION", "S_SMOKE", "S_LIGHT", "S_DIMMER", "S_COVER", "S_TEMP", "S_HUM", "S_BARO", "S_WIND",
                  "S_RAIN", "S_UV", "S_WEIGHT", "S_POWER", "S_HEATER", "S_DISTANCE", "S_LIGHT_LEVEL", "S_ARDUINO_NODE",
                  "S_ARDUINO_REPEATER_NODE", "S_LOCK", "S_IR", "S_WATER", "S_AIR_QUALITY"};
                  eats exacly 1592 extra bytes just for the definition (a bit more if we are going to write "S_TEMPERATURE" insted of only "S_TEMP").

                  I don't get why it would be that high - at a quick guess those 24 strings should use less than 300 bytes including the pointers and nul terminators. Are they being repeated many times or is there some additional library which gets pulled in when you use them?

                  By the way, if you want the strings themselves in progmem (and not just the array of pointers to strings), I think you may need to use different techniques. http://arduino.cc/en/Reference/PROGMEM

                  But that's about how much RAM you use; I still don't understand why those two dozen strings would take up 1.5 KBytes of flash.

                  DammeD Offline
                  DammeD Offline
                  Damme
                  Code Contributor
                  wrote on last edited by
                  #11

                  @Zeph Using progmem already, made one custom function to read out the data and get length at the same time from a string array using index.

                  I have been looking a ittle inside the mysensors lib and there are plenty of optimizations to be done.. I might put some time to clean stuff out!
                  The exact size differance with and without the strings is ~880bytes, (I put som extra in there) but there are som functions inserted to handle them.

                  1 Reply Last reply
                  0
                  • DammeD Offline
                    DammeD Offline
                    Damme
                    Code Contributor
                    wrote on last edited by
                    #12

                    Omfg, I've spent the last week trying to figure out why some messages got sent and others didn't...
                    I forgot the frekin "gw.process();" on the receiving end! D'oh!! :| >.< :p
                    Well, While dissecting the code I found some bugs I think I've sorted out now..

                    So now I'll try to clean code up a bit and then I'll call it beta 0.1
                    Anyone tried it?

                    DammeD 1 Reply Last reply
                    0
                    • DammeD Damme

                      Omfg, I've spent the last week trying to figure out why some messages got sent and others didn't...
                      I forgot the frekin "gw.process();" on the receiving end! D'oh!! :| >.< :p
                      Well, While dissecting the code I found some bugs I think I've sorted out now..

                      So now I'll try to clean code up a bit and then I'll call it beta 0.1
                      Anyone tried it?

                      DammeD Offline
                      DammeD Offline
                      Damme
                      Code Contributor
                      wrote on last edited by
                      #13

                      And there we have it, beta 0.1
                      should work. Please test it! :)
                      I'll try to write better documentation as time comes. I'll answer any questions.

                      DammeD 1 Reply Last reply
                      0
                      • DammeD Damme

                        And there we have it, beta 0.1
                        should work. Please test it! :)
                        I'll try to write better documentation as time comes. I'll answer any questions.

                        DammeD Offline
                        DammeD Offline
                        Damme
                        Code Contributor
                        wrote on last edited by
                        #14

                        @Damme Fail on me, forgot to push the update.. :P Now it's there.

                        1 Reply Last reply
                        0
                        • bjornhallbergB Offline
                          bjornhallbergB Offline
                          bjornhallberg
                          Hero Member
                          wrote on last edited by
                          #15

                          Is this for 1.4 beta or 1.3?

                          Just need another ethernet shield and to figure out how to get MQTT to work in Domoticz.

                          1 Reply Last reply
                          0
                          • DammeD Offline
                            DammeD Offline
                            Damme
                            Code Contributor
                            wrote on last edited by
                            #16

                            Its made for 1.4b

                            1 Reply Last reply
                            0
                            • Y Offline
                              Y Offline
                              yuriyts
                              wrote on last edited by
                              #17

                              Link
                              https://github.com/Damme/MyMQTT
                              broken

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


                              13

                              Online

                              11.7k

                              Users

                              11.2k

                              Topics

                              113.1k

                              Posts


                              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • MySensors
                              • OpenHardware.io
                              • Categories
                              • Recent
                              • Tags
                              • Popular