# sleep wakeup 12 hours not accurate

Hello everybody,

I put my arduino to sleep with the codes below and it is not accurate. For example, I program my arduino to sleep for 12 hours and it wakes up after12 hours and 15 minutes.

can it wakeup exactly 12 hours

• why do we divide 43200 / 8s ?

// 12 hours = 60x60x12 =43200 s
// 43200 s / 8 s = 5400

unsigned int sleepCounter;
for (sleepCounter = 5400; sleepCounter > 0; sleepCounter--)

JOHN_1973:
can it wakeup exactly 12 hours

Sometimes it might, but the watchdog timer, used by the lowpower library will produce the sort of variation in times you are seeing.

If you want more accurate sleep times use a real time clock.

JOHN_1973:
I put my arduino to sleep with the codes below and it is not accurate. For example, I program my arduino to sleep for 12 hours and it wakes up after12 hours and 15 minutes.

Is it consistently 12 hours and 15 minutes? If so, calculate:

12 hours = 720 minutes
12 hours + 15 minutes = 735 minutes
720 / 735 = 0.97959...
0.97959 * 5400 = 5290 (approximately)

which tells you to use 5290 iterations instead of 5400.

• why do we divide 43200 / 8s ?

Because the maximum single period of sleep of the watchdog timer is 8 seconds.
Within your loop, it actually wakes up 5400 times, then immediately sleeps again.