Feed on
Posts
Comments

Ever wanted to know how to reduce the power consumption of your Atmel microcontroller when it’s not doing anything? The 2 videos below will step you though how you can reduce the power consumption of your Atmel microcontroller (in this case the ATtiny85) by using the power down sleep mode with the Watchdog timer.

The beauty of the watchdog timer is it allows us to not require an external interrupt to wake up the microcontroller, instead it wakes up after a certain amount of time by itself.

Link to the modified example for ATtiny85: ATtiny85_watchdog_example
Power consumption calculator: http://oregonembedded.com/batterycalc.htm
ATmega168 Sleep Watchdog website: http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/

5 Responses to “Reduce ATtiny power consumption by sleeping with the Watchdog Timer”

  1. James Printer says:

    Hi

    How did you get your ATTiny to work with the Arduino IDE? I’ve been using AVR Studio for this, but I’d love to use Arduino IDE as I’m used to it from using my Duemilanove/ATMega328.

    Thanks

  2. James Printer says:

    Awesome, thanks! Saves me buying an ISP programmer.
    I think I may have to use AVR Studio as I have a ATTiny13. I suppose I could try and modify the ATTiny45/85 ZIP file too, I expect they are very similar both having 8 pins. I’d gain the advantage of not having to learn hex codes to do everything like in AVR Studio :)

  3. Ben says:

    This is an awesome tutorial. I will be making an auto filling water bowl for my dogs. I was looking at the code and was wondering if I can make the attiny85 sleep longer than 8sec. I really only need to check the level once a minute. I see, in setup_watchdog, that if ii>9 it will be set to 9. Can this number only be a single digit?

    • Alex says:

      Hi Ben,

      The maximum sleep time for the watchdog timer is 8 seconds (9 value), this is taken from the ATtiny25/45/85 datasheet on page 32.

      Potentially you could just have a counter variable which would count to 7 or thereabouts (7 x 8sec sleep = 56sec) which is incremented/compared and once it reaches 7 it runs your water level check code. The downside is that it will always wake up every 8 seconds however the power consumption used when waking up, checking the counter variable and then going back to sleep would be small, it would probably only last 50ms. An example is shown in Standalone Temperature Logger Part 7.

      However if really sleeping for 1 second is required, then the ATmega168/328 might be the way to go, it costs more and is larger. On page 39 of the ATmega168/328 data sheet it shows that it can be woken up by timer2 so potentially you could configure timer2 to count up to exactly 1 second by selecting the right prescaler and/or enabling the compare. I think a separate clock source is needed though.

      So the easiest solution is to use a counter and watchdog timer if exact timing isn’t that important and extreme battery life isn’t needed.

Leave a Reply