0

I am trying to have my Arduino wait in a low power idle state given by the LowPower library made by rocketscream on an Uno. However, when I try to have it wait for 8 seconds, it seems to not pause at all. Does anyone know how to make it so it waits the full 8 seconds before running the next line of code?

Here is the code:

#include "LowPower.h"

void setup() {
   Serial.begin(9600);
}

void loop() {
   delay(100);
   Serial.println("above");
   delay(100);

   LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_ON, SPI_OFF, USART0_OFF, TWI_OFF);

   delay(100);
   Serial.println("below");
}

I would expect this to print "above", then wait 8 seconds, then print "below", then do it again. But what happens is it runs right through the LowPower.idle without doing anything and the output looks like:

1:12:14.547 -> above

21:12:14.746 -> below

21:12:14.845 -> above

21:12:15.044 -> below

21:12:15.144 -> above

21:12:15.376 -> below

...and so on.

If anyone has any ideas on how to make idle wait, that would be great.

Thanks!

  • Try putting cli(); before LowPower.idle(...). I think timer0 (used for millis and delay) is interrupting your idle time. – Gerben Sep 12 '19 at 9:49
  • Thank you for your response but that does not seem to change anything. – Hayden Sep 13 '19 at 6:44
1

FYI, this issue was brought up nearly 3 years ago, with no response from the author: https://github.com/rocketscream/Low-Power/issues/36

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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