rocketscream / Low-Power

Low Power Library for Arduino
www.rocketscream.com
1.26k stars 345 forks source link

Define the sleep time. #98

Closed alessandrolecce closed 4 years ago

alessandrolecce commented 4 years ago

Is it possible to define sleep time? I need to sleep the Arduino for 5 minutes. How can I implement it in LowPower.idle() ?

Adrian363 commented 4 years ago

Hi, I want to make the same thing as you. Have you found a solution to increase sleeping time?

alessandrolecce commented 4 years ago

Not, yet, I will work on it by the end of this month

Inviato da Outlook Mobilehttps://aka.ms/blhgte


From: AdrianCs notifications@github.com Sent: Wednesday, May 6, 2020 4:48:46 PM To: rocketscream/Low-Power Low-Power@noreply.github.com Cc: alessandrolecce alessandro.pagliara@hotmail.it; Author author@noreply.github.com Subject: Re: [rocketscream/Low-Power] Define the sleep time. (#98)

Hi, I want to make the same thing as you. Have you found a solution to increase sleeping time?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/rocketscream/Low-Power/issues/98#issuecomment-624660506, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFSLKLI3B77L3XVQU3CUUO3RQFTD5ANCNFSM4L5MKEUA.

ziplock9000 commented 4 years ago

This is exactly what I was coming to request too :)

zvoniimiir commented 4 years ago

Have you tried powerDown? sleepCounter represents 8s periods (due to SLEEP_8S). So 5 minutes would be sleepCounter = 38

for (int sleepCounter = 38; sleepCounter > 0; sleepCounter--) { LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); }

ziplock9000 commented 4 years ago

Have you tried powerDown? sleepCounter represents 8s periods (due to SLEEP_8S). So 5 minutes would be sleepCounter = 38

for (int sleepCounter = 38; sleepCounter > 0; sleepCounter--) { LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); }

That still means it's wakes up every multiple of 8 seconds. While this would be sufficient for most use cases, but it does not have a single defined sleep time with no wakes like the title mentions.

rocketscream commented 4 years ago

The timer is based on the watchdog timer which has discrete period that cannot be changed. Using the for loop is the only way here without any external RTC IC or upgrade to the newer megaAVR 0-series MCU that has real time counter.