Comment on Attiny85 the right choice for 24h led timer?

<- View Parent
Saigonauticon@voltage.vn ⁨10⁩ ⁨months⁩ ago

I use the Attiny10 in this context. At 3.5V operation and using the Watchdog timer + deep sleep… that should cost you about 4.5 uA when the lamp is off. Then a bit more when it is on (about 40uA assuming whatever the GPIO is connected to is high impedance), as you have to enable the I/O clock (but most things and peripherals can stay off). So an average consumption of 10.4 uA, or 31 years of operation off two 1.5V cells – of course they’re not rated for this long and the actual light will consume far far more power. The point is that the current consumption of the system is absolutely dominated by the light-producing component, in other words the control system is highly efficient.

You can implement as a state machine, e.g. something vaguely like:

Set WDT to trigger an interrupt instead of the RESET vector. Then set WDT to trigger after 8s. Then on wake increment a register (you will need 2 registers, 8 bits isn’t enough). Compare these registers to constants that set the timer duration. On compare match, change the machine state.

Machine state 1: GPIO HIGH, timer duration 4h, I/O clock enabled. CPU sleep mode IDLE. Machine state 2: GPIO LOW, timer duration 20h, sleep mode POWER DOWN.

I think in assembly language but should be a similar process in C++. I’ve successfully implemented very similar (night-light timing) algorithms on this chip. I can’t give you power consumption metrics as none have ever run out of power over the past 6 months.

source
Sort:hotnewtop