Go Down

### Topic: Use an Attiny85 to make a "torch locator" (Read 1 time)previous topic - next topic

#### nickgammon

##### Feb 25, 2015, 04:32 am
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.

Schematic, more photos, code, and description at: http://www.gammon.com.au/forum/?id=12769

According to my calculations it should last for over 3 years, after which you pop out the battery and put a new one in.
Please post technical questions on the forum, not by personal message. Thanks!

#1

Nice!

#### dtokez

#2
##### Feb 25, 2015, 11:34 am
smart project just out of interest, did you calculate the power with it flashing through the night (I presume it is dark at night in your house?)

thanks for sharing

#### nickgammon

#3
##### Feb 25, 2015, 08:40 pm
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.
Please post technical questions on the forum, not by personal message. Thanks!

#### flyboy

#4
##### Feb 26, 2015, 03:42 pm
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.

#### nickgammon

#5
##### Feb 26, 2015, 08:51 pm
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.
Please post technical questions on the forum, not by personal message. Thanks!

#### flyboy

#6
##### Feb 27, 2015, 07:55 pm
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.

#### larham

#7
##### Apr 26, 2018, 11:31 pm
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?

#### nickgammon

#8
##### Apr 27, 2018, 02:07 am
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.
Please post technical questions on the forum, not by personal message. Thanks!

#### larham

#9
##### Apr 28, 2018, 09:35 pm
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...

#### suicidebattery

#10
##### Sep 10, 2019, 10:56 pm
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.

#### 6v6gt

#11
##### Sep 22, 2019, 09:12 am
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()

Go Up