How to find out what triggered a wake up

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

How to find out what triggered a wake up

#1 Post by ewaldharmsen » 07 Oct 2019, 12:05

I have enabled deep sleep.
The device auto wakes every 10 minutes for 30 seconds.

But I also have attached a rain gauge which wakes the device.

How can I see what has waked the device? The timer or the gauge?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to find out what triggered a wake up

#2 Post by grovkillen » 07 Oct 2019, 12:30

Not currently, you could open a new request on GitHub though.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: How to find out what triggered a wake up

#3 Post by TD-er » 07 Oct 2019, 15:01

Not sure if I can "see" what caused the wake-up, since both are seen as "boot after going to sleep".
What may be a clue is keeping track of the time when going to sleep and waking up.
If that's less than the set sleep time, then it is likely something other than the sleep timer.
You may want to store just the nr. of seconds of "today" and not the unix timestamp.
The Unix timestamp uses more bits than a float can store, so you cannot store it in a dummy variable.
Nr. of seconds in a day is max. 86400, which does fit in 17 bits.

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: How to find out what triggered a wake up

#4 Post by ewaldharmsen » 07 Oct 2019, 15:05

Sounds like a plan!
How do I do that?
In rules?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: How to find out what triggered a wake up

#5 Post by TD-er » 07 Oct 2019, 15:40

Maybe it is the easiest to trigger a rule on the timeset event and then compare it.
This will make this information available almost immediately after time is known from NTP.

Just take into account that the sleep timer starts as soon as you go to sleep, so the computed sleep time may be a few seconds lower than your set sleep time.
If you let the node go to sleep from within the rules you may store the time right before going to sleep.
As long as you keep in mind that there can always be a false positive in this method.
Also starting from a cold boot (power lost) will set the dummy plugin values to 0.

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: How to find out what triggered a wake up

#6 Post by ewaldharmsen » 07 Oct 2019, 16:02

Thanks,

will try something like this:

Code: Select all

on System#Sleep do
  Let,1,%unixday_sec%
endon 
  
on Time#Initialized do
  if %unixday_sec% - %v1% < 600
    WAKE FROM EVENT
  else
    WAKE FROM timer
endif

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to find out what triggered a wake up

#7 Post by grovkillen » 07 Oct 2019, 16:40

You cannot do if and formula at the same time/line.

Code: Select all

on System#Sleep do
  Let,1,%unixday_sec%
endon 

Time#Initialized Do
 Let,2,%unixday_sec%-%v1%
 Event,timeisset
EndOn

on timeisset do
  if %v2% < 600
    //WAKE FROM EVENT
  else
    //WAKE FROM timer
endif
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: How to find out what triggered a wake up

#8 Post by kimot » 23 Oct 2019, 21:50

Connect rain sensor to other GPIO too and after wake up check this GPIO.
If your sensor send only short pulse, which resets and wake ups ESP, you can extend pulse time, so it will be active some time after reboot on other GPIO.
Use NE555 timer for example.
GPIO active = wake up by pulse
GPIO no active = wake up by timer

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests