fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

When RTC battery dies

Thu Oct 29, 2015 2:20 pm

I have a number of Pis with added RTC modules, mostly DS1307 I think.

Most, if not all, of these modules come with a warning not to use without first installing an appropriate button cell.
Fine, no problem with that, but after two or three years these may become depleted.

Is there then a chance that a depleted battery might damage the module in the same way as no battery at all?

I'm wondering if I should check them periodically.

I haven't been able to find anything specific to this from a search

gordon77
Posts: 5077
Joined: Sun Aug 05, 2012 3:12 pm

Re: When RTC battery dies

Thu Oct 29, 2015 2:27 pm

Sorry I don't know the answer, I would assume it's no problem as you only need the battery to keep the time,

but can you get your RTC to work with Jessie ?

If so how ?

Thanks

Gordon

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Re: When RTC battery dies

Thu Oct 29, 2015 2:45 pm

Mm... well some speak of damage to the RTC IC - hence my question.

WRT jessie, I am just setting up a new Pi2 with a fresh jessie install and hoping my new 1-wire + RTC module will arrive later today so no idea yet whether I can get it work.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: When RTC battery dies

Thu Oct 29, 2015 2:48 pm

If you write some data to the NVRAM on your DS1307 you can read it back every day. When the data disappears your battery has gone flat.

cat /sys/bus/i2c/devices/1-0068/nvram
sudo sh -c 'echo "Kilroy was here "`date +"%F"` > /sys/bus/i2c/devices/1-0068/nvram'
cat /sys/bus/i2c/devices/1-0068/nvram


BTW, on Jessie with the 4.1.12 kernel rtc-ds1307 isn't getting loaded by the device tree, so my RTC doesn't work until I use
sudo modprobe rtc-ds1307;sudo modprobe i2c-bcm2708
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
jojopi
Posts: 3274
Joined: Tue Oct 11, 2011 8:38 pm

Re: When RTC battery dies

Thu Oct 29, 2015 2:54 pm

fruit-uk wrote:Is there then a chance that a depleted battery might damage the module in the same way as no battery at all?
I do not think the module will be damaged without a battery, it just will not work reliably.

The datasheet says that if you do not want battery backup, Vbat must be grounded. Internally the chip compares Vcc to 1.25×Vbat to determine when the power is failing. Having Vbat floating makes this comparison nonsense, so the I²C interface may shut down spuriously. The module will not respond correctly to commands if no battery is fitted.

A flat battery is more like a short to ground than a high impedance, so it should not be a problem. Of course the device will forget the time if the power fails and the battery is also dead.

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Re: When RTC battery dies

Thu Oct 29, 2015 3:24 pm

DougieLawson wrote:If you write some data to the NVRAM on your DS1307 you can read it back every day. When the data disappears your battery has gone flat.
Indeed and that is something I consider doing.
BTW, on Jessie with the 4.1.12 kernel rtc-ds1307 isn't getting loaded by the device tree, so my RTC doesn't work until I use
sudo modprobe rtc-ds1307;sudo modprobe i2c-bcm2708
I saw that in a previous post of yours.
I assume it's OK to add to /etc/modules - which I've done, they are all loaded - just need the RTC now :)
jojopi wrote:I do not think the module will be damaged without a battery, it just will not work reliably.
Odd they have worded the warning in that way then - perhaps they have all copied and pasted each other ;)

Thanks both

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Re: When RTC battery dies

Thu Oct 29, 2015 6:31 pm

Well, my 1-wire module with RTC arrived but getting it to work across a boot was a pain and as yet there is nothing definitive and in one place for jessie on the forum (and now here's another one!) - other than that your specific RTC module should be compiled in the kernel!

At the moment I have it working by following this page http://afterthoughtsoftware.com/products/rasclock and commenting out

Code: Select all

if [ -e /run/systemd/system ] ; then
    exit 0
fi
in /lib/udev/hwclock-set - after saving a good copy of course.

Need to enable appropriate parameters as listed in /boot/overlays/README in config.txt
and add appropriate modules to /etc/modules of course


So far it has survived several reboots :)

Return to “HATs and other add-ons”