Hi,
I am planning on sleeping 8sec twice, and then doing a sensor check.
Every hour, give or take a few minutes, I want to check another sensor.
I understand Milis() is not updated when asleep, so are there any simple patterns for this?
Do I need to manually track time with milis() when awake, and just add the sleep amount on to get now?
Any example code?
You can adjust base on the amount of time you sleep.
You can count the # of 8s sleep cycles and figure out when you got to 1hour etc.
Quote from: Felix on June 13, 2016, 08:18:47 AM
You can adjust base on the amount of time you sleep.
You can count the # of 8s sleep cycles and figure out when you got to 1hour etc.
I am doing the latter.
In the former, and you talking about running a different variable, that gets updated from millis() and sleep periods?
I have multiple examples where millis is still used while sleeping the MCU, one such example is the mailbox notifier where I do try to update the time passed.
If you sleep for 8s then add 8000 to your millis counter.
Thanks
Missed that in the mailbox notifier. Will look again.
Yeah, it's basically just a matter of keeping track of the time you sleep.
If you just need to wake every 1 hour, sleep for 450 cycles, then send your messages, repeat, etc, no need to mess with millis() at all.
Just doing counts of cycles is fine for most things
But at certain points I go an do things that may take variable time (like GPS fix or send an SMS) and hence it can get a bit out of whack.
I could get that back by either accurate millis measuring or not hard coding the count cycles and rejigging those as required.
Will check your millis example