🛠 Ajouter une horloge temps réel sur le bus I2C des capes

BeagleBone Black (TI Sitara AM3358) · intermediaire · Schéma : IMG-beaglebone-black-intermediaire-2-horloge-rtc-i2c-bus-cape.svg — module RTC DS3231 avec pile bouton câblé sur P9_19 (SDA) et P9_20 (SCL) + 3,3 V/GND de la BeagleBone Black, bus I2C2 partagé avec les EEPROM de capes (0x54-0x57) en médaillon.

Objectives

Wire and configure an I2C real-time clock (DS3231/DS1307 class) on the BeagleBone Black's I2C2 bus — the historical bus for capes, where addresses 0x54 to 0x57 are occupied by identification EEPROMs. You will learn how to probe the bus, declare the module to the kernel, and synchronize the system clock so that the date persists through a complete power loss without network access.

Hardware

Complete code

sudo apt install i2c-tools
sudo i2cdetect -l                 # repérer le numéro du bus I2C2
sudo i2cdetect -y -r 2            # le DS3231 répond en 0x68

# Déclaration à la volée pour tester (le module noyau existe déjà) :
sudo modprobe rtc-ds1307
echo ds1307 0x68 | sudo tee /sys/bus/i2c/devices/i2c-2/new_device

# Quelle RTC est laquelle ?
ls /sys/class/rtc/ ; cat /sys/class/rtc/rtc1/name

# Régler puis lire l'horloge RTC
sudo date -s "2026-10-14 09:00:00"
sudo hwclock -f /dev/rtc1 -w      # système -> RTC
sudo hwclock -f /dev/rtc1 -r      # RTC -> système

# Relire après un redémarrage complet (sans réseau)
sudo reboot

Expected verification

i2cdetect shows address 0x68; after running hwclock -w and rebooting with the network cable DISCONNECTED, the date is preserved (the kernel restores the RTC at boot). The name file of rtc1 contains "ds1307" or "ds3231".

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials