1

So I'm trying to power down my ATtiny85 to save power, but for some reason the ATtiny doesn't power down when I'm using the default IDLE mode, but when I start using the SLEEP_MODE_PWR_DOWN the ATtiny appears to go to sleep.

I'm testing it by calling a checkPower() method that blinks an LED after the sleepNow() method. In other words, if the ATtiny goes to sleep then the checkPower() method should not be reached and the LED should not blink. Here is the code:

void loop() 
{ 
 doStuff();
 sleepNow();
 checkPower();
}
void sleepNow()
{
 // Choose our preferred sleep mode:
 set_sleep_mode(SLEEP_MODE_IDLE);
 // Set sleep enable (SE) bit:
 sleep_enable();
 // Put the device to sleep:
 sleep_mode();
 // Upon waking up, sketch continues from this point.
 sleep_disable();
}
void checkArrays()
{
 for(i = 0; i < 15; i++)
 {
 digitalWrite(1, HIGH);
 delay(1000);
 digitalWrite(1, LOW);
 delay(1000);
 }
}

Any idea why my LED would continue to blink when using the IDLE mode but no the PWR_DOWN mode?

asked Jun 21, 2016 at 17:08

1 Answer 1

1

In IDLE mode the timers still run. Arduino uses timer0 for millis. So when timer0 overflows the ATTiny will wake up and call the ISR.

So the ATTiny will go to 'sleep' but wake up a number of microseconds later.

answered Jun 21, 2016 at 17:19
4
  • So what can I use besides IDLE? If I try PWR_DOWN I won't be able to use an interrupt to wake the microprocessor. Is there an alternatice. Also how long does IDLE make the ATtiny sleep? Commented Jun 21, 2016 at 17:44
  • 1
    You can wake from power down using either a pin change interrupt or a watchdog timer interrupt. Commented Jun 21, 2016 at 18:30
  • @IsabelAlphonse: IDLE is fine. You just have to check, whenever you wake up, if there is job to do. If not, just go back to sleep. Commented Jun 21, 2016 at 19:29
  • As bigjosh said, pin change and watchdog timer interrupts will wake the processor from power-down. See my page about power - not specifically about the Attiny85, but the same processor family. Commented Jun 21, 2016 at 21:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.