Hey guys, the forum search is not working for me (Internal Server Error) so forgive me if there have been previous posts on this topic.
I have a project here that is using a 6V battery for backup power when/if the primary external AC power supply goes down. The battery is charged or maintained by the external power supply until the external power goes down at which point the battery takes over. My 5V regulator is a LDO and my plan is to only let the battery drain to about 5.3 V before shutting everything else down and putting the Arduino to sleep. This is project involves a GSM module so in between loss of external power and putting everything to sleep, I'd like to send out a SMS alert stating whether the external power was lost and/or regained. I have a resistor type voltage divider to bring the 6.8V down to about the 5V limit of the analog input.
I'd like to get some suggestions from you guys about how to develop the software to detect the voltage drop or rise on the battery when the external power is lost or resumed. My tests here show that within 20 secs of disconnecting my external power, the battery voltage drops at least 0.08 volts and it rises about the same when reapplying the external power. So my thoughts are that if the analog reading is dropping, it needs to compare that value to the recent high and when that difference exceeds my 0.08V threshold, send the "power is down" alert. At the same time, if external power is resumed and the battery voltage starts rising, the software needs to remember the recent low analog reading and compare that to the current reading to determine when it has actually begun charging again.
Thanks