6
\$\begingroup\$

The board which is made with Atmega operates on battery, it should turn on every 6 hours and log some data, then go back to deep sleep to save battery consumption. Atmega32 is used and not Atiny because of complexity of tasks and sensors connected to the circuit.

What I have found so far, is that I can keep track of time using an RTC IC.

I've read datasheets of some RTC IC's but they don't provide any such capability as generating a signal for Atmega's external interrupt at specific intervals, so it can wake up from deep sleep. (Something similar to cron-task in *nix systems is needed, if you are familiar with it.)

And of course search terms like "Atmega scheduled task" and alike did not bring up anything.

How can I efficiently (in terms of power consumption) wake Atmega up from deep sleep periodically?

\$\endgroup\$
6
  • \$\begingroup\$ Searh for RTC chip with an "(time of day) alarm" ouput. Eg. cypress.com/?docID=45855 \$\endgroup\$
    – jippie
    Commented Jul 10, 2014 at 6:40
  • 4
    \$\begingroup\$ How accurate do you need it to be? \$\endgroup\$ Commented Jul 10, 2014 at 6:43
  • \$\begingroup\$ @loolooyyyy This thread on Arduino forum might provide some insight. That thread is fairly agnostic, and it doesn't involve anything Arduino-specific. Also, an important term, which you might look up, is cyclic sleep. \$\endgroup\$ Commented Jul 10, 2014 at 6:52
  • 1
    \$\begingroup\$ I've been doing something similar recently however I'm using the DS1339B that has that feature and might be worth checking out. \$\endgroup\$
    – PeterJ
    Commented Jul 10, 2014 at 7:22
  • \$\begingroup\$ Do you use the internal oscillator? If so, you can hook a watch crystal up to the clock ports and set the fuses for it to drive timer 2 - then use the watchdog time to wake up from deep sleep only a few times per second. Update a counter and wake up 'for real' when 6 hours have passed. \$\endgroup\$
    – RJR
    Commented Jul 10, 2014 at 12:58

3 Answers 3

3
\$\begingroup\$

I am working on a very similar project, that operates once every hour for about 15 seconds, and sleeps for the rest of the time. In an effort to conserve battery power (the device is deployed in the field for an average of 6 months at a time), using WDT interrupts was impractical because constantly counting interrupts was a huge battery draw.

My system uses a Microchip MCP7940M RTC, which has a multifunction pin, that allows you to directly connect to the hardware interrupt. The chip communicates with the processor using I2C.

The only issue is that the Alarm output, which would trigger the interrupt, can only be set for minutely, hourly, daily, weekly, monthly or yearly. To get to every six hours you would still have to count interrupts, but the power draw would be significantly less because you can put the device to sleep in between interrupts.

\$\endgroup\$
4
\$\begingroup\$

You can use the Watchdog timer to issue an interrupt instead of reseting the chip. The chip will wake up even from the deepest sleep mode on the watchdog interrupt.

You will want to set the biggest prescaler for the Watchdog timer (8 seconds) and count interrupts. If the counter has not yet reached the predefined amount, immediately go back to sleep, otherwise, execute logging code.

\$\endgroup\$
1
\$\begingroup\$

Some RTCs have this function and some don't.

The popular DS1307 doesn't while the slightly more expensive DS3234 does. The DS3234 has "two programmable time-of-day alarms" that can be wired to the Arduino interrupt pins to wake up your uController.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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