Mysensors MQTT gateway
-
@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%)
@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?
-
Hello
MQTT Gateway for mysensors.
https://github.com/Damme/MyMQTT
Requires mysensors lib 1.4b
//Daniel
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 -
@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%)
@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.
-
@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.
@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. -
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? -
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?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. -
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. -
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.
-
Its made for 1.4b
-
Link
https://github.com/Damme/MyMQTT
broken