I have a small circuit using a PIC18F14F50 microcontroller chip which is logging data into an external EEPROM chip over an i2c interface (which I can then read back later over the USB interface). One sample is recorded every 15 minutes and doesn't need to be particualrly accurately timed.
It's ok if samples are missed or mis-timed while batteries are being changed, but it's not great if the batteries expire and no data is recorded for several days until someone notices.
So I'd like to warn the user when the battery is low in plenty of time for them to replace them. The average current is under 2mA and I'm running in from 3 AA alkaline batteries in series to give 4.5volts so I'd expect them to last quite a number of days.
But I'm wondering how to detect that the battery is low? I presume the voltage will drop as the batteries reache the end of life. I'm thinking that this PIC has a 1.024v reference voltage so I can divide down the supply voltage and feed it to an analogue input and when the divided voltage drops below that trigger a warning.
But I don't know enough about batteries to know how well this will work? And I don't know what voltage to choose that would indicate that perhaps 10-20% battery life is left. Will that even work at all? Is there a better approach?
This doesn't need to be at all accurate, I just want to give a good warning in plenty of time without getting people to disard batteries that still have life left in them.
As my current usage is fairly constant, would a simple timer be reasonable if I can work out how long the batteries last on average and then pick 85% of that time before I give the warning? Or does battery life vary more than that?
Any thoughts would be welcome.