I am using the function in the topic to sleep until the pin wiggles or the sleep times out with the given duration. What I want to know when the system awakes is how much time has elapsed in sleep mode?
I discovered several interesting things while experimenting with this to see if I can figure this question out.
- You can immediately on waking query the state of the wakeUpPin to determine if it, or the timeout was the cause of your waking. It seems to work very fast, and even just a millisecond or two pulse is correctly queried.
- If you have attached your own interrupt to the pin that is used as wakeUpPin , not only does it wake you up, but your ISR is called too.
- It appears that “millis()” gets frozen in time during the sleep period, and that when you awaken it is as if 0 time has elapsed on that timer. I haven’t tried “micros()”
I know that I could connect to the network, wait for the network time to synchronize and then use the real-world time to get a good guess. However, there must be a timer that is counting down for the timeout feature of this to work, so I was hoping there is some way to read out the current value of that timer when you awaken.
A suggestion would be that this system call just return the value of the timer when you awaken … this could simultaneously tell you how much time is left, and if 0 that you were awaken by the timer, not the pin.
Thanks for any help.