Skip to content

RTC Backup Battery ​

The Raspberry Pi 5 has a built-in real-time clock. With the official RTC battery (a rechargeable coin cell on a connector) plugged in, the Pi keeps correct time across power outages — without waiting for NTP after boot, which matters for a home-automation box whose automations and history are time-based.

Charging is disabled by default ​

The RTC includes a constant-current (3 mA), constant-voltage charger, but battery charging is off by default — it must be enabled explicitly (official docs).

Current state can be inspected through sysfs:

sh
cat /sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/battery_voltage
cat /sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/charging_voltage
cat /sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/charging_voltage_max
cat /sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/charging_voltage_min

Example output before enabling (voltages in µV — battery at ~2.71 V, charging off, allowed range 1.3–4.4 V):

2711963
0
4400000
1300000

Enabling charging ​

Add to /boot/firmware/config.txt (that's 3.0 V — six zeros):

ini
dtparam=rtc_bbat_vchg=3000000

Reboot, then re-check the sysfs files to confirm the charging voltage is set.

Doing this on HAOS ​

HAOS gives no easy shell onto the boot partition, so the config.txt edit is done by mounting the boot partition of the installed disk on another Linux machine (source: HA community thread, verified on the haos_rpi5-64-13.1 image):

  1. Connect the HAOS disk (NVMe in a USB adapter, or SD card) to a Linux machine.
  2. As root, mount the boot partition — e.g. mount /dev/nvme0n1p1 /mnt/boot (device name varies; it's the small FAT partition containing config.txt).
  3. Edit config.txt and add dtparam=rtc_bbat_vchg=3000000.
  4. sync, unmount, safely remove the disk.
  5. Put the disk back in the Pi, power up, and verify from an SSH add-on shell:
sh
[core-ssh ~]$ cat /sys/devices/platform/soc/soc\:rpi_rtc/rtc/rtc0/charging_voltage
3000000
[core-ssh ~]$ cat /sys/devices/platform/soc/soc\:rpi_rtc/rtc/rtc0/battery_voltage
2886321

No Linux machine at hand?

A Linux VM works too if the disk can be passed through to it. Collected notes on that: SD cards in VirtualBox, a VirtualBox forum thread, and raw disk access in VirtualBox.