Pi 5 RTC with battery > clock stops when powered off

Hi All,

EDIT: Yes the connector’s seated correctly, and I’ve unplugged and re-plugged it to no avail.

Am I doing something wrong or fundamentally misunderstanding the role the Pi 5 RTC backup battery is meant to be performing?

I have a Pi 5 that has no network connectivity: it’s a standalone Wi-Fi AP to which clients can connect. An accurate RTC that survives and keeps ticking when the Pi is powered off (e.g. in a padded bag on its way to a site) is crucial, so I’ve added one of these:

Raspberry Pi 5 Real-Time Clock (RTC) Battery | Buy in Australia | CE09774 | Core Electronics

Its product description says “Keep your Raspberry Pi 5 on time even when the power is disconnected with the Real-Time Clock (RTC) Battery.”

My problem is that it doesn’t. Whenever I power the Pi off, the clock stops.

I’ve added the config shown at the bottom of the product page (linked above), and also enabled battery charging:
Raspberry Pi hardware - Raspberry Pi Documentation

Alas, no deal. I can set the time (sudo date -s '2024-12-18 07:56:00 AEDT'), turn the pi off, turn it back on later and the time was frozen whilst off, resuming now power’s on.

What am I missing here??

Thanks.

Just to let you know, I have a Pi 5 with the RTC battery and the clock keeps running when powered off and no internet access. So it does work.

I followed the Pi documentation page to set it up. If you have done the same it should work.

“The RTC is equipped with a constant-current (3mA) constant-voltage charger.” Not a fast charge. When I connected it I left it powered up for a few hours before testing to see if the RTC clock kept running. You could leave it powered for a while and then check the battery voltage, if it is not around 4.2V then the battery could be the problem.

Cheers
Jim

Thanks Jim. I hadn’t even considered that the battery might be flat!

I’ve since had a little win (of sorts). This command has kept the clock running without power:

sudo hwclock --systohc

(I found that on this Pi forum post).

Although now it seems I have two different, slightly disagreeing clocks.

I set the correct time with date, but the hwclock is an hour behind, whilst at the same time thinking it’s in the same timezone:

pi@captureKNX:~ $ sudo date -s '2024-12-18 11:44:00 AEDT'
Wed 18 Dec 11:44:00 AEDT 2024 Australia/Sydney'
pi@captureKNX:~ $ date
Wed 18 Dec 11:44:11 AEDT 2024
pi@captureKNX:~ $ date
Wed 18 Dec 11:44:52 AEDT 2024
pi@captureKNX:~ $ sudo hwclock
2024-12-18 10:45:05.111894+11:00
pi@captureKNX:~ $

I’ve just powered it down. I’ll wake it up in half an hour and see what (if anything) has changed.

Back soon.

2 Likes

Hey @Greig63365,

I can second what Jim is saying. Ensuring that your battery is working as expected and outputting an acceptable voltage is a good idea to make sure it’s not contributing to any issues.

hwclock won’t account for daylight saving adjustments automatically which looks to me like the reason behind this 1 hour time difference.

when you run sudo hwclock --systohc do the outputs from date and sudo hwclock sync up?

Hi @Samuel,

I’ve just powered it back up again and the time reported by date is “accurate” - in so far as it’s been clocking whilst powered down - but alas, it’s gone back an hour to the GMT+10 time, so the two clocks align:

pi@captureKNX:~ $ date
Wed 18 Dec 12:21:38 AEDT 2024
pi@captureKNX:~ $ sudo hwclock
2024-12-18 12:21:45.009177+11:00

The Pi thinks the battery is at 2.95V:

pi@captureKNX:~ $ cat /sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/battery_voltage
2959826

I’ll let it run the rest of the afternoon, just in case it’s some weird battery voltage thing, although that doesn’t explain how the hwclock is telling me it’s GMT+11 when it’s displaying GMT+10, and then (presumably?) copying that into the system clock on bootup.

Or did I maybe originally just have a flat battery, and by running sudo hwclock --systohc I’ve since given myself a different problem?

1 Like

Hey @Greig63365,

Looks like the battery is doing okay then, that’s great.

I would try to set the date again but have a play around with the timezone, trying both AEDT and AEST. I’m not sure exactly whats going on but it does seem like some daylight savings adjustment is happening in the background when you don’t want it to.

Maybe setting the time initially to the correct time with the timezone as AEST before using sudo hwclock --systohc will give you a different outcome?

Good idea @Samuel.

Strangely enough though, it doesn’t like AEST or AET:

pi@captureKNX:~ $ sudo date -s '2024-12-18 16:30:00 AEST'
date: invalid date ‘2024-12-18 16:30:00 AEST’
pi@captureKNX:~ $ sudo date -s '2024-12-18 16:30:30 AET'
date: invalid date ‘2024-12-18 16:30:30 AET’

This post gave me the below, which seems to have worked:

pi@captureKNX:~ $ sudo hwclock --set --date="2024-12-18 16:45:30"
pi@captureKNX:~ $ sudo hwclock --hctosys
pi@captureKNX:~ $ date
Wed 18 Dec 16:45:45 AEDT 2024
pi@captureKNX:~ $
pi@captureKNX:~ $ sudo hwclock -r
2024-12-18 16:45:56.920929+11:00

So i think the hwclock command I first tried was the wrong way 'round, copying system to hardware, where in the snippet above I’m setting the HW clock, THEN copying it to sys.

I subsequently gave the Pi a 15 minute snooze and it came up with the right time, so I think my issue is resolved.

I have a spare battery and I’ll pay more attention next time I build a Pi 5 and deploy it, making sure I first enable the on-board charger and give the battery time to charge up before I start relying on it to maintain the time when it’s powered off.

Thanks @James46717 & @Samuel for the reassurances and thoughts.


- Greig.

3 Likes

Hi Greig

Great to hear that your issue managed to get resolved!

1 Like