Friday, 27 October 2017

avr - Switching Arduino/ATMega to sleep mode when on battery


I'm trying to make a small clock but want to ditch the need for a separate RTC chip with battery backup. What I would like to do, instead, is keep track of the time completely on the ATMega using the watchdog timer to generate a roughly 1Hz signal to count the seconds with. Not super accurate, but good enough for what I need.


The key though is that I would like to still have a battery backup. So, what I need it to do is detect that it no longer has 5V power (probably from USB) and switch into low power mode (running off a 3V CR2032 or similar) only waking when the watchdog timer ticks in order to increment the seconds. I'm guessing also dynamically decrease the clock speed (switch to internal or something) to save power.


I'm a bit stumped... How would I actually do the hardware for this? I vaguely remember something about "diode ORing" the backup battery... no idea what that means. And bonus points for the software side of things.




No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...