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