How to check battery level on a RTC DS1307 ?

Hi there,

Just wondering if this possible ?

I am currently using the RTC1307 from Sparkfun (https://www.sparkfun.com/products/99).

Is it possible reading the battery value from a custom made RTC 1307, as per described in the post below ?

http://forum.arduino.cc/index.php/topic,8833.0.html

Thanks in advance for any reply.

Yes. You can do an analog read of the battery voltage. A coin cell battery used for time keeping should last several years.

Thanks!

Could you describe (or give some references) on how to exactly read and interpret the values ?

Thanks again,

batteryVoltageRead = analogRead (A0);

float batteryVoltage =float( batteryVoltageRead * (5/1023.) ); // format might need some tweaking

Serial.println (batteryVoltage, 2); // same here, not sure how to specify how many decimal points are shown

Thanks a lot!

I am going to try that now.

That is agreat idea, but would that notdrain the battery too fast? Do i need to add a big resistor inline?

Interesting point!

I would also like to know that...

Yes it would. The measurement won’t be accurate either.

Liudr, i apologise, i'm not understanding that reference (i really tried), how does that answer the question on battery drain, or the need of a resistor?

The battery needs to charge a capacitor through a 10Kohm resistor so it will consume about 0.1 mA current while being tested. I don't know if the capacitor is still connected after the analog read.

Ok, thanks for the explanation. Keeping it connected (and checking the level automatically) is useless then.

You are asking if the 50 nA of current from the DS1307 battery to charge the ADC sample & hold cap will drain the RTC battery? I supposed a little. 50nA * 24 hr/day * 365 day/yr = 0.438mAH/yr

My eyes must totally fail me, but where did the 50nA come from? I found on the ds3231 datasheet that the data retention current was 100uA (micro). Thanks

The diagram I posted depicts an ATMEGA328 analog input that charges a capacitor through 1 resistor that is typically 10Kohm against Vcc/2 (so 2.5V by default). Take the battery voltage to be 3.5V (full battery) then we have 1V to charge the capacitor at peak current of 1V/10Kohm so 0.1mA or 100nA. CrossRoads uses 50nA possibly considering the whole charging process won't keep current at 100nA but follows an exponential decay instead. So yes if you keep polling the battery voltage, you drain it about as fast as the RTC drains it (100nA).

Ok, so if i understand correctly, if i do not do a analogRead() it won’t use up any amps? (Except for keeping the cap filled).

Very interesting!

Hi, I find the CR2032 cells on a DS1307 last for years, why do you want to test it!! in fact to save space I now use a CR1220, but the holders are no so easy to get.... CPC here in the UK are offering a rechargable CR2032 for 89p +vat.

Hope it helps. Regards Mel.

Cr1220 holders, how many do youneed? http://www.ebay.com/itm/New-CR1220-Battery-Socket-Holder-20PCS-/321089177319?pt=LH_DefaultDomain_0&hash=item4ac26806e7

Unfortunately, they are rated (only) 20mAH, while the 2032 average at 210 mAH, so thats the difference between yearly replacement or once every ten years.

Ironically i get a 5% battery warning on my iPad.. So i gotta go.

RobvdVeer: Ok, so if i understand correctly, if i do not do a analogRead() it won't use up any amps? (Except for keeping the cap filled).

Yes and no.

There is some (considerable) confusion here.

The 50 nA figure CrossRoads quotes is not related to charging the ADC capacitor (because firstly, 1V across 10k is 100 *micro*amps, not *nano*amps), but the maximum notional input leakage current of the ATmega input itself.

Other than this, the ADC only consumes power to charge that integrator capacitor, each time to perform a read. And since it is actual charge (nanoCoulombs or such) that is required, the value of the series resistor is irrelevant, only changing how long it takes for that charge to be transferred.

The real trick of this arrangement, is that the input leakage current of the ATmega is only meaningful whilst it is powered up. Remove the supply voltage, and all inputs are pulled down to 0.5V by the protection diodes.

Remove the supply voltage, and all inputs are pulled down to 0.5V by the protection diodes.

Unless the pullup resistors are enabled - then the pins sit high. So enable the pullup resistor on the analog input - battery will not source any current, and might even recharge some thru the 20K to 50K pullup.

Paul__B: 1V across 10k is 100 *micro*amps, not *nano*amps)

My mistake!

the value of the series resistor is irrelevant, only changing how long it takes for that charge to be transferred.

Again, my mistake.