RASP-PCF8523-Fixer-Heure
En cours de traduction/élaboration. |
Introduction
Maintenant que nous avons un module RTC branché sur le Raspberry-Pi et que nous avons vérifié qu'il est bien présent sur le bus I2C (avec i2cdetect); nous pouvons configurer notre système pour qu'il exploite l'horloge RTC.
Il est essentiel que la configuration I2C soit en ordre de fonctionnement. Assurez-vous d'avoir complété le point précédent! |
Raspbian Jessie (Systemd)
Vous pouvez ajouter le support de la RTC en ajoutant un overlay au device tree.
Exécutez la commande:
sudo nano /boot/config.txt
pour éditer le fichier de configuration et ajouter l'overlay correspondant à la puce RTC:
dtoverlay=i2c-rtc,ds1307
ou
dtoverlay=i2c-rtc,pcf8523
ou
dtoverlay=i2c-rtc,ds3231
à la fin du fichier
Crédit: AdaFruit Industries www.adafruit.com
Savez les modifications et exécutez sudo reboot pour redémarrer le Pi.
Connectez vous et exécutez sudo i2cdetect -y 1 pour voir si le UU s'affiche à l'emplacement 0x68
Crédit: AdaFruit Industries www.adafruit.com
sudo apt-get -y remove fake-hwclock sudo update-rc.d -f fake-hwclock remove
Disable the "fake hwclock" which interferes with the 'real' hwclock
Crédit: AdaFruit Industries www.adafruit.com
Now with the fake-hw clock off, you can start the original 'hardware clock' script.
Run sudo nano /lib/udev/hwclock-set and comment out these three lines:
#if [ -e /run/systemd/system ] ; then # exit 0 #fi
Crédit: AdaFruit Industries www.adafruit.com
Fixer l'heure de la RTC
When you first plug in the RTC module, it's going to have the wrong time because it has to be set once. You can always read the time directly from the RTC with sudo hwclock -D -r
Crédit: AdaFruit Industries www.adafruit.com
You can see, the date at first is invalid! You can set the correct time easily. First run date to verify the time is correct. Plug in Ethernet or WiFi to let the Pi sync the right time from the Internet. Once that's done, run sudo hwclock -w to write the time, and another sudo hwclock -r to read the time
Crédit: AdaFruit Industries www.adafruit.com
Once the time is set, make sure the coin cell battery is inserted so that the time is saved. You only have to set the time once
That's it! Next time you boot the time will automatically be synced from the RTC module
Raspbian Wheezy ou autres systèmes pré-systemd
Si ce point vous intéresse en particulier, vous pouvez poursuivre votre lecture depuis la page "Raspbian Wheezy or other pre-systemd Linux"
Source: Adding real time clock to Rasberry-Pi
Tutoriel créé par Ada pour AdaFruit Industries. Tutorial created by Lady Ada for AdaFruit Industries
Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com
Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : « Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.
L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.