Sleep issue
-
Having code with a door sensor and a light.
Because i want to save battery time, ive incoporated a sleep mode.
the sleep mode is called after the door is closed, and will wake up again after a change or time ( to measure temperature).
Sleep mode must not be called when the door is open because of the light which should go out after a radio message from the Gateway.snippet of code:, the 2,5 seconds delay is to make sure the door doesnt open again.
if (gotoSleep == 1) { Serial.print("--==## Door closed, Going to Sleep "); Serial.println(SLEEP_TIME); delay(2500); sleep(digitalPinToInterrupt(DOOR_SWITCH), FALLING, SLEEP_TIME); gotoSleep =0; }
log file shows this:
--==##Door Trigger1 14061 TSF:MSG:SEND,5-5-0-0,s=0,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=OK:1 --## Running Loop --==##Door Trigger0 16822 TSF:MSG:SEND,5-5-0-0,s=0,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=OK:0 --==## Door closed, Going to Sleep 19329 MCO:SLP:MS=300000,SMS=0,I1=0,M1=2,I2=255,M2=255 19333 MCO:SLP:TPD 19385 MCO:SLP:WUP=0
That is so weird, why does it wake again on interrupt (as told by log parser)
CHANGE or FALLING doesn t matter
-
This post is deleted!
-
@Richard-van-der-Plas update to latest MySensors library (2.2.0 beta) and try again please.
-
@Yveaux i dont think i can do that in the online arduino create environment.....
-
@Richard-van-der-Plas probably not, but what you're describing is a known issue in 2.1.x
-
@Yveaux damn is there any other way to fix it besides the 2.2?
-
@Richard-van-der-Plas not that I'm aware of. It's a bug in the library which you cannot fix without touching the library code.
-
@Yveaux Ok went to 2.0 and that indeed works