0

I am trying to set up the low power module for an instance case, I have installed the low power library but when I am using the line

LowPower.powerDown (SlEEP_5S, ADC_OFF, BOD_OFF) ; 

It is throwing an error stating that the 'SLEEP' was not declared in the scope. Any suggestion for that ? Do I have to include a library for sleep too ?

#include "LowPower.h"
  /// DON' t worry about the setup and loop, i have defined all those.

This set of code is in

  void Loop()  
    ...
    else           
    {
       LowPower.powerDown (SLEEP_10S, ADC_OFF, BOD_OFF) ; 
7
  • 1
    SlEEP_5S ... should that be SLEEP_5S ? Feb 15, 2019 at 8:20
  • Sorry ! I didnt get you
    – kaushik
    Feb 15, 2019 at 8:42
  • you can't see the difference between SlEEP and SLEEP? Feb 15, 2019 at 8:47
  • nope i tried that, doesn't work.
    – kaushik
    Feb 15, 2019 at 9:05
  • 1
    Void instead of void? An else without an if? Your program will have many more problems right now. Note that the language is case sensitive. Feb 15, 2019 at 9:49

1 Answer 1

1

There is no 5 or 10 second sleep. You can't just arbitrarily choose how long to sleep for. The watchdog timer only has specific periods (defined by dividing the clock by a set amount) that it can sleep for:

enum period_t
{
    SLEEP_15MS,
    SLEEP_30MS,
    SLEEP_60MS,
    SLEEP_120MS,
    SLEEP_250MS,
    SLEEP_500MS,
    SLEEP_1S,
    SLEEP_2S,
    SLEEP_4S,
    SLEEP_8S,
    SLEEP_FOREVER
};

To sleep for 5 seconds you would need to sleep first for 4 seconds, then wake up, and then sleep for a further 1 second after that. For 10 seconds sleep for 8 seconds followed by 2 seconds.

Note that they aren't exact values, however, since the watchdog oscillator is very crude and varies wildly in frequency with both temperature and power supply voltage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.