Go Down

Topic: ATTiny85v and Sleep Functions (Read 5 times) previous topic - next topic

Nick Gammon

There are a lot of things you can do to save power:


Using the watchdog timer to sleep is a reasonable way of allowing time to elapse. Clearly, very exact timing it not important.

If I may suggest, some other blink pattern to indicate the battery power is low? There are ways of self-detecting battery power. I'm not sure about the Attiny85, but a quick look at the datasheet would appear to indicate it does that too.

I am wondering if I can use that to put it to sleep/wake up during the light blinking process.

Yes you can, although as dc42 says, there may not be much point.

Nick Gammon

What about the timers and the USI?

If you use the watchdog, you won't care about the timers.

Nick Gammon

Just out of curiosity (in case I want to make one of these) how are you planning to read the temperature accurately, in a way that is resistant to fluctuating supply (battery) voltage?


Timer0 generates the interrupt which increments millis(), you might need that. Timer1 normally isn't needed (it's used for PWM generation if you do analogWrite()).

Wow! Great info from all! I am not using the millis() function, so I should be good there. I just wanted to make sure the watchdog timer will still work. I use the ADC to read the temperature sensor, and I use the INTERNAL 1.1v reference voltage for that reading as well. But I should be able to turn that all off during sleep and then back on without any serious issues. The datasheet mentions a brief wait time for the internal reference voltage to start back up, so I might add a tiny delay(10) before it begins taking readings. And right now, I have it taking 100 readings and throwing out the highest 20 and lowest 20 readings before averaging. By doing that and using the internal voltage reference,I get pretty steady temperature readings.


I suggest you program the fuses to use the 128kHz internal oscillator instead of the 8MHz one, and program the clock prescaler register to run the processor at the lowest clock frequency that you can manage with. This way, you can get the current consumption of the chip down to a fraction of a millamp while it is awake.

If you do this, then I doubt that it's worth having the device sleep while blinking the IR LED, since the ATtiny current consumption will be tiny compared to the IR LED.

Nice. I have seen some about programming the fuses with avrdude commands. Can anyone provide the correct command to make these recommended settings changes?

How will running it at 128kHz affect my timing? For example, if in my test program I am using a delay(1000) on the Arduino itself to wait 1 second, what does that get translated to on the ATTiny85v running at 128kHz?

Will that change the watchdog timing as well? If I have the watchdog set to wait 8 seconds, will it still be 8 seconds at the slower frequency? Thanks!

Go Up