gw.request - how is it done?
-
Okay. Did that already, of course. :)
Let's start from something known. I've used the demo code for
the EnergyMeterPulseSensor Example. All I changed is the Node_ID
(to 123). Did this in:gw.begin(incomingMessage, NODE_ID, false);
And I am sending a demo value to V_VAR1:
gw.send(pcMsg.set(123456));
This does get sent obviously. In the Domoticz.db file I can find that value
in the "MySensorsVar" table. After having sent the value I remove this line.And this is what I get (b.t.w.: how do I decipher those messages? This is
not the format that is used in the MySensors SerialProtocol document):send: 123-123-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
send: 123-123-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
sensor started, id=123, parent=0, distance=1
send: 123-123-0-0 s=255,c=3,t=11,pt=0,l=12,sg=0,st=ok:Energy Meter
send: 123-123-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
send: 123-123-0-0 s=0,c=0,t=13,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
read: 12-13-0 s=0,c=1,t=1,pt=7,l=5,sg=0:46.6
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:
send: 123-123-0-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok:and so on.
Some of this I understand (I think). What about the lonesome "read" line?
As I already wrote: it doesn't look like the routine...void incomingMessage(const MyMessage &message)
... is ever entered.
What else can I tell You?
Christoph
-
Hi,
this is my workaround for my problem:
Ive added a 1F goldcap capacitor as an emergency power supply.
If my powersupply voltage drops a routine is called which stores
the current counter value via gw.setState() and then enters an
endless loop. And an LED is switched on to empty the capacitor.
Next time the sensor boots up, first thing it'll do is to retrieve the
old value for the pulsecount from the EEPROM.With this I can use the setstate function in case it's necessary
but I don't have to write to the EEPROM continuously which
wouldn't work for long (100k write cycle limit).It's probably not failsafe. For example: what happens if there
are multiple reboots because the brownout watchdog "barks"
and the final power cut happens while the EEPROM is written to?But for now it seems to work. Dah!
:)
Christoph -
I have made a sketch requesting VVAR1 from Domoticz. It didnt work with the stable version but better with the beta.
But as i wrote in this post im still having issues with getting the request back: http://forum.mysensors.org/topic/2116/hard-to-grab-time-and-value-sent-from-controllerThe sketch is in the link, but its a rain gauge.
-
@Mediacj sure. It's not cleaned up. And a hack of various sources.
I guess You won't mind ;)
EnergyMeterPulseSensorGrace.inoThe fun stuff happens in the void graceful() routine.
First of all You'll have to run this line once to set Your startup value:
pulseCount = ((1912810 * PULSE_FACTOR / 10) + 5) / 10; graceful();After that You can comment this out and hopefully won't ever need it again :)
With the next booting of the sensor the value will be read from the EEPROM:pulseCount = 0;
pulseCount += gw.loadState(GRACE + 3); // get highest byte
pulseCount *= 256;
pulseCount += gw.loadState(GRACE + 2);
pulseCount *= 256;
(and so on).If the pre-voltage-regulator voltage drops the gold cap will still hold enough power
to save the current value to the EEPROM.Still. I'd much prefer the software solution ...
Christoph
-
I have made a sketch requesting VVAR1 from Domoticz. It didnt work with the stable version but better with the beta.
But as i wrote in this post im still having issues with getting the request back: http://forum.mysensors.org/topic/2116/hard-to-grab-time-and-value-sent-from-controllerThe sketch is in the link, but its a rain gauge.
@sundberg84 I'll have a look at that.
I've just tried the TimeAwareSensor example mentioned and it doesn't work.
But I DO get some reads, as far as I could see I got them from those
sensors that are repeater enabled.
But NEVER anything from "GW". WHat's it's address anyway?Christoph
-
Gizmocuz has a working sketch example
I have successfully used it.