AtTiny85 sleep + counter

407 views
Skip to first unread message

Shival Wolf

unread,
Sep 5, 2012, 7:56:36 PM9/5/12
to connected-commu...@googlegroups.com
Hi All.
Looking for some info/advise if  anyone knows the details.

I want to build a little medication reminder. 
All i want it to do is turn and hold on a bright LED every 24 hours.
I will be shutting off the LED by checking if the box that all the stuff is in has been opened(either using a LDR or just a contact plate on the edge of the box).

Does anyone know how accurate the attiny85's sleep watchdog timer is?
If i was to put the chip to sleep at its max watchdog timer setting of 8 seconds.
if each time i woke it up i added 8 seconds to the counter and check if its been 24 hours would this end up being accurate over 24 hours?
i don't need 100% accuracy but would it end up drifting more then 10 minutes?

I plan on testing this but if anyone knows the details or has any suggestions that would be great.

James Muraca

unread,
Sep 5, 2012, 8:11:33 PM9/5/12
to connected-commu...@googlegroups.com

I think over time it will drift an unacceptable amount (i havent check the numbers but id assume an internal crystal would drift a fair bit over this time).
Another option would be to use a real time clock with an alarm interrupt? Check out the ds3232 real time clock module at jaycar stores, this should suffice and be fair more accurate with a lot less drift

--
You received this message because you are subscribed to the Google Groups "Connected Community HackerSpace" group.
To post to this group, send an email to connected-commu...@googlegroups.com.
To unsubscribe from this group, send email to connected-community-h...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msg/connected-community-hackerspace/-/cgKe70cT6M4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Scott Penrose

unread,
Sep 5, 2012, 9:19:03 PM9/5/12
to connected-commu...@googlegroups.com
My experience recently with sleeping, using maximum watchdog of about 8 seconds, on a Atmega 2560 is that it is very roughly somewhere between 7.6 and 8.1 seconds !!! Very inaccurate.

Easy but more expensive solution would be a RTC. Or if power isn't an issue leave the external crystal on, which is far more accurate. Or use a crystal to trigger a counter - which is really how an RTC works anyway.

BTW. The way I solved my issue, where I needed to sleep for 2.5 hours, was to wake up after about 2.1 hours, and recheck the GPS, adjust my 8 seconds time and re-sleep until closer. This meant on average I only had to check my GPS 2 or 3 times each 3 hours period, and due to the VBAT connection (about 100 uA) it would often only take about 10 seconds to get an accurate fix.

Scott

Robert Stürzbecher

unread,
Sep 5, 2012, 10:57:28 PM9/5/12
to connected-commu...@googlegroups.com
The sleep timer is not all you need to think about, you also need to account for the program execute time (between sleeps) 
For 24 hours you will need about 10800 sleeps so over this number of loops per day even a few ms will turn into minutes. 

Ken Ihara

unread,
Sep 6, 2012, 8:38:05 AM9/6/12
to connected-commu...@googlegroups.com
Another idea:

Hack a $1.50 alarm clock from Ikea.
http://www.ikea.com/au/en/catalog/products/60196594/ Take off the
face and make a contact with the hour hand.

Connect that to a flip flop from Jaycar ($1).
http://www.jaycar.com.au/productView.asp?ID=ZC4027

Attached is a schematic that should enable you to make LED turn on every
24 hours (instead of 12 hours)

Not a pretty solution, but perhaps an alternative to a $30 RTC module.

Cheers,
Ken
24hrclock.JPG
Reply all
Reply to author
Forward
0 new messages