🛠 La première RTC des Compute Modules : câbler et vérifier la VBAT du CM5
Objectives
The CM5 is the first Compute Module with an embedded RTC: the VBAT pin (2.5–3.5 V, typically a CR2032) maintains the time when powered off, with a consumption of 1.7 µA when powered / 6 µA when unpowered — the datasheet states “a typical CR2032 lasts more than 3 years unpowered”. The CM4, on the other hand, had no RTC on the module. This tutorial covers: installing the battery, setting the time, writing it to the RTC, and verifying that it survives a total power cut — an essential practice for any offline or enclosed setup.
Hardware
- 1 × CM5 on a CM5IO Board (the RTC battery holder is provided on the IO Board)
- 1 × new CR2032 coin cell battery (respect the +/− orientation of the battery holder)
- Display or SSH session
- 5 minutes of mains power disconnection for the retention test
Full code
# 1) Insérer la CR2032, démarrer, vérifier la présence de la RTC
ls -l /dev/rtc*
cat /sys/class/rtc/rtc0/name
dmesg | grep -i rtc | head -3
# 2) Régler l'heure système puis l'écrire dans la RTC
timedatectl # état courant (NTP activé ou non)
sudo timedatectl set-ntp false
sudo date -s '2026-10-14 08:30:00'
sudo hwclock -w -f /dev/rtc0 # système -> RTC
sudo hwclock -r -f /dev/rtc0 # relecture : doit correspondre
# 3) Test de conservation : couper l'alimentation 5 minutes (pas le porte-pile),
# rallumer SANS réseau, et vérifier :
timedatectl | head -3
# 4) Remettre la synchro réseau une fois en ligne
sudo timedatectl set-ntp true
Expected verification
/dev/rtc0 exists and hwclock -r reads back the written time; after 5 minutes without network, timedatectl displays a consistent time (drift on the order of a second); the kernel logs the RTC at boot (dmesg | grep -i rtc). For battery-powered designs, note the quiescent load of a few µA that VBAT imposes permanently (note on pin 76).
Common errors
- Setting
datewithout runninghwclock -w: the system time is lost when power is cut; only writing to the RTC preserves it. - Forgetting to disable NTP during the test: network synchronization “corrects” the time and masks a dead or incorrectly wired RTC.
- Battery inserted backwards or oxidized contact: the time resets to the kernel build date on every cold boot.
- Comparing with the CM4: the CM4 has no RTC at all (it is the carrier board that adds one, e.g., PCF8523 on I2C);
hwclockscripts inherited from the CM4 may target a different device.
Other tutorials for this board
- Alimenter un CM5 comme il faut : USB-C PD 5 V / 5 A et bouton d'alimentation
- Accès distant sans VPN : enregistrer un CM5 dans Raspberry Pi Connect
- GPIO du CM5 côté RP1 : force de conduite, budget 50 mA et broches pièges
- Refroidir le CM5 : ventilateur PWM sur le connecteur JST-SH et tachymétrie
- Deux ports USB 3.0 simultanés : le CM5 fait du stockage rapide, pas sur une carte CM4
- Démarrer le CM5 sur un SSD NVMe dans le socket M.2 de la CM5IO
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash