I am trying to create an alarm that wakes up at a certain time and does a series of instructions. To set the times that it wakes up, I am going to use the headphone of an Android device to send serial data to the MCU about what time(s) to wake up. I will simply plug it in, make the transfer and unplug the jack. Then the time is set on the MCU. The transfer will also sync the time to set the timer appropriately.

I can set a timer interrupt with a prescaler to give me 4s on each interrupt. Then use 2 bytes as secondary counter of some sort. That would give me 72 hours that I could wait and I only need 24 since I can reset when the day ends.

So my question comes when the device is reset. I can save the current time in the EEPROM and then read it on load but how much overhead does that have on current use? I want the battery to last as long as possible.

My question may need to be elaborated on but I was wondering if there was a better way or if I am going about this the correct way.

  • \$\begingroup\$ Is there a particular reason the device will be reset? When waking from sleep the RAM will be preserved so unless there's another reason it will reset (power removed etc) you should be able to keep your counter in RAM and not use the EEPROM. \$\endgroup\$ – PeterJ Feb 22 '14 at 9:50

Use an RTC that supports an alarm line, eg. DS1375. The chip can drive an interrupt line at a given time/date. You do have to select the appropriate AVR sleep mode that 'listens' to the selected interrupt. No need to use the AVR timers.

  • \$\begingroup\$ This is correct, but hard to say whether it has better or worse battery life than the original proposal. \$\endgroup\$ – Ben Voigt Feb 22 '14 at 1:39

I'm using an internal watch dog timer in attiny44 in similar case. It can be configured to issue an interrupt (not reset) every 8 seconds. What's good is that WDT interrupt can wake up the chip from the deepest "power down" sleep mode.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.