RASP-PCF8523-Fixer-Heure

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Introduction

Now that we have the module wired up and verified that you can see the module with i2cdetect, we can set up the module.

Raspbian Jessie (Systemd)

You can add support for the RTC by adding a device tree overlay. Run

sudo nano /boot/config.txt

to edit the pi configuration and add whichever matches your RTC chip:

dtoverlay=i2c-rtc,ds1307

or

dtoverlay=i2c-rtc,pcf8523

or

dtoverlay=i2c-rtc,ds3231

to the end of the file

 
Crédit: AdaFruit Industries www.adafruit.com

Save it and run sudo reboot to start again. Log in and run sudo i2cdetect -y 1 to see the UU show up where 0x68 should be

 
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.