rocketscream / Low-Power

Low Power Library for Arduino
www.rocketscream.com
1.27k stars 346 forks source link

Sleep for 4 hours #43

Closed josephernest closed 7 years ago

josephernest commented 7 years ago

Congrats for this great library! I'd like to sleep the 328p for 4 hours. How to do that in order to use the least power possible ( < 0.01 mA) ?

rocketscream commented 7 years ago

You can do something like this:

// 4 hours = 60x60x4 = 14400 s
// 14400 s / 8 s = 1800
unsigned int sleepCounter;
for (sleepCounter = 1800; sleepCounter > 0; sleepCounter--)
{
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  
}

Please use the forum next time for questions on the library. The repository is for issues and bug reporting.

josephernest commented 7 years ago

Thanks @rocketscream, I already thought about this, but this will require 1800 sleep / wakeup / sleep / wakup / sleep / ... / operations, and I thought it's not optimal. The goal is to reach < 10 µA as mentioned here during 6 hours.

Isn't there a more level way to do it? i.e. defining LEEP_1HOUR ?

LowPower.powerDown(SLEEP_1HOUR, ADC_OFF, BOD_OFF);
rocketscream commented 7 years ago

No, the time is limited by what the watchdog timer can provide which is 8s maximum. And the wake up time is only a tiny fraction compared to the 8s, in few us. So, will be still very low.

jassing commented 7 years ago

You could use some sort of external trigger to wake the board up. While I am no 555 expert, I'm sure there's some way to use that to generate your sleep duration; but I'm not sure it would use less power than waking the board up every 8 seconds. If I may ask, why the requirement? If you're trying to run off an AA battery, there are some very small lipo batteries that carry a lot more power...

On Sun, Sep 24, 2017 at 3:03 AM, rocketscream notifications@github.com wrote:

No, the time is limited by what the watchdog timer can provide which is 8s maximum. And the wake up time is only a tiny fraction compared to the 8s, in few us. So, will be still very low.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rocketscream/Low-Power/issues/43#issuecomment-331699790, or mute the thread https://github.com/notifications/unsubscribe-auth/ALKu4q8-Ffto-P_uvg9yV63YulHTO_s9ks5slijggaJpZM4PhNZC .

dolanmiu commented 7 years ago

Does this method mess up the Arduino clock at all?

I want it to sleep for 4 hours+, but I also have alarms which must activate at certain times

jassing commented 7 years ago

Sounds like conflicting requirements.

dolanmiu commented 7 years ago

@jassing

This guy manages to sort of do it:

https://github.com/rocketscream/Low-Power/issues/19

Wondering if there is a better, more elegant way

vazquezjm commented 5 years ago

@dolanmiu were you able to sort it out?

dolanmiu commented 5 years ago

Nope never managed to do it

Ended up sleeping for 8 seconds instead

nimasaj commented 5 years ago

You have to define a loop for it to iterate in the loop as long as you want. E.g 4 hours= 14400 seconds and 14400/8=1800. So, your loop should iterate for 1800 times, to be in (almost) sleep mode for 4 hours.

vazquezjm commented 5 years ago

You have to define a loop for it to iterate in the loop as long as you want. Right, as explained here:

https://github.com/rocketscream/Low-Power/issues/43#issuecomment-331614084