10

My wife gifted me this super cute mini miffy diorama from a gachapon. It uses two 1,5V cells and has a tiny led in it. I would really love to to add a 24h timer. ( it should stay on for 4 hours after turning it on then go to "standby" for 20h before turning back on) Do you guys think an attiny85 is the right thing for the job? Sorry of the question is dumb in any way. I am absolutely not an electronics guy.

top 6 comments
sorted by: hot top controversial new old
[-] sokkies@lemmyrs.org 3 points 1 year ago

ATTiny would definitely work. Ive use them for really really long timer systems with some trial and error.

You should maybe just look at a bigger battery depending on what lifetime you would expect? They are not exactly super low power(at least the ones I have used)

[-] P03@lemmy.world 1 points 1 year ago

Is there a more low power alternative?

[-] Saigonauticon@voltage.vn 3 points 1 year 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.

[-] Goodman@discuss.tchncs.de 1 points 1 year ago

You could go with an DS1339 which is an RTC with two programmable time of day alarms. If you only need timing you might as well do that. But if electronics isn't really your thing then just add a bigger battery for the attiny85, make sure to run it at it's lowest clock speed.

[-] elmicha@feddit.de 2 points 1 year ago

If it doesn't matter if it's a few seconds too late or too soon an ATtiny 85 is good. If you need more accuracy you probably need an additional RTC.

[-] cmnybo@discuss.tchncs.de 4 points 1 year ago

You could also use a crystal for the ATtiny and get the same accuracy as the RTC. It should be accurate to about 20-30 seconds per month with a good crystal.

The internal oscillator only has an accuracy of around 1% after you calibrate it. It would be off by over 7 hours after a month. It's also quite sensitive to voltage and temperature changes.

this post was submitted on 17 Aug 2023
10 points (100.0% liked)

Ask Electronics

3173 readers
1 users here now

For questions about component-level electronic circuits, tools and equipment.

Rules

1: Be nice.

2: Be on-topic (eg: Electronic, not electrical).

3: No commercial stuff, buying, selling or valuations.

4: Be safe.


founded 1 year ago
MODERATORS