🛠 La première RTC des Compute Modules : câbler et vérifier la VBAT du CM5

Raspberry Pi Compute Module 5 (compute-module-5) · debutant · Schéma : IMG-compute-module-5-debutant-2-rtc-vbat-cr2032-cm5.svg — CM5 sur CM5IO Board ; une pile bouton CR2032 est insérée dans le porte-pile RTC de l'IO Board, reliée à la broche VBAT (2,5–3,5 V) du module ; une horloge affiche l'heure conservée après coupure du secteur.

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials