A few nights ago the lights went out (power failure). I have torches scattered around the house, but the trick is to find them in the pitch darkness.
It occurred to me that it would be nice if there was a flashing light on or near a torch, so you could head for the light, and find the torch. Hence this project was born.
Close up:
This sleeps most of the time (lazy thing!) but wakes every two seconds to check the light level. If it is low, it flashes the LED for 2 mS, and then goes back to sleep. The idea is that the flash helps you home in on your torch, switchboard, emergency exit, or whatever.
I don't have any easy way of calculating average power over time, especially when I know the "high drain" intervals are very short (like under a millisecond to measure the light, and two milliseconds to flash the LED). I measured the power consumption when it was off, which agreed with the datasheet. I temporarily extended the flash time so I could measure the power consumed when the LED was on. The rest was just done by calculation.
I made a slightly simpler one in October 2013. That did not measure the light but flashed an LED for one millisecond every two seconds, continuously (ie. during the day as well).
That is still working on the original battery, so that proves that it can run for at least 17 months. Since the original one flashed all day but for half the time, you can probably reckon on 3/2 times the LED consumption compared to my calculation (which was 2.31 µA) so the newer design is probably slightly more efficient.
I bought a light a few years ago that uses PWM to keep the light (LED) on at a minimum level all the time. This is so you can find it in the dark. Pushing the button cycles through Low, High, Strobe, Idle (minimum). It uses an Attiny85 running on a 9V battery. Specs say that it will sit in Idle mode, very low PWM, for up to 2 years on a 9V battery. Nice little light. Unfortunately, the website I bought it from is no longer online.
Interesting idea, although a PWM output of the same consumption as I used (0.002 / 2) would probably be hard to see, especially if the lights just went off and your eyes hadn't adjusted yet.
Yes, it certainly depends on your intended purpose. In my case, I use it in the mornings before the sun comes up. I can find it easily. I also tend to put it in a certain location all of the time. That helps too.
Awesome, I'm trying to do a thing for my friend with a digispark bit I can not get it working. Is ther conflicts with the stuff that is already on board the PCB?
The Digispark has, I think, code to keep the USB port active, so putting it to sleep probably won't be a big success. I suggest just the raw Attiny85 chip.
Ok, I'll try to use a bare attiny85, tnx.
By the way I tested the "simpler" version and that works great. There is something with the LDR and ports I cant figure out, hard to test also...
I love this idea, is it possible to have the led blink at random intervals (say between 10 and 30 mins) when it's dark. My coding skills are basic and I can't seem to work out how to do it.
The Nick Gammon device switched the led on for 2mS every 2 seconds.
If you want a longer interval than 8 seconds, you have the additional problem of chaining together sleep/wakeup operations to overcome the maximum limit of the watchdog timer.
You could make the sketch simpler by using analogRead() instead of using register control of the ADC, although you'd still have to switch the ADC On/Off, as required, for power saving.
Anyway, you could, during a wake period, calculate a random number of seconds the device should sleep for.
See random()