# Echtzeituhr (RTC) Modul DS3231 für Raspberry Pi

Wer FabAccess auf einem Raspberry Pi betreiben möchte und eine Echtzeituhr für genaue und unabhängige Zeitstempel wünscht, kann ein RTC Modul installieren und konfigurieren:

Diese Anleitung basiert auf [https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time](https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time)

[![grafik.png](https://docs.fab-access.org/uploads/images/gallery/2024-12/scaled-1680-/kccCtTZ3neSqAWTE-grafik.png)](https://docs.fab-access.org/uploads/images/gallery/2024-12/kccCtTZ3neSqAWTE-grafik.png)

*Das von uns verbaute Uhrenmodell ist <span data-slate-fragment="JTVCJTdCJTIyaWQlMjIlM0ElMjJmNnVZaVZIWFJNZU5aRi1xcy1MTGFnJTIyJTJDJTIydHlwZSUyMiUzQSUyMmhlYWRlcjIlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMmlkJTIyJTNBJTIySkpQMlBwX0dTMmlza0xtdlZZVUxCdyUyMiUyQyUyMnRleHQlMjIlM0ElMjJEUzMyMzElMjIlN0QlNUQlN0QlNUQ=" style="white-space: pre;">[DS3231](https://funduinoshop.com/elektronische-module/schnittstellen-konverter/rtc/ds3231-uhrzeit-modul-fuer-raspberry-pi)</span>*

Wir fügen in der Boot-Konfiguration folgende Device Tree Overlays (`dtoverlay`) ein:

```bash
sudo vim /boot/config.txt 
```

```bash

# Additional overlays and parameters are documented /boot/overlays/README
dtoverlay=i2c-rtc,ds3231
```

```bash
sudo vim /etc/modules
```

```bash
i2c-bcm2708
i2c_dev
```

Danach starten wir den Pi neu

```bash
sudo reboot
```

Nach dem Restart prüfen wir, ob unsere Echtzeituhr verfügbar ist.

```bash
i2cdetect -y 1 #should be visible at 0x68
```

Wenn ja, dann können wir die standardmäßig installierte "Fake Hardware Clock" deinstallieren:

```bash
sudo apt remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo systemctl disable fake-hwclock
```

Noch etwas nachstellen und dann die Uhr in Betrieb nehmen:

```bash
sudo vim /lib/udev/hwclock-set
```

```bash
#!/bin/sh
# Reset the System Clock to UTC if the hardware clock from which it was copied by the kernel was in localtime.
dev=$1
/sbin/hwclock --rtc=$dev --hctosys
```

```bash
sudo hwclock -r
sudo hwclock --verbose -r
sudo hwclock -w #write the time
sudo hwclock -r #read the time
```