Raspberry Pi¤Çµ¡´ï¤òºî¤Ã¤Æ¤¤¤ë¤È¡¢ÃÏÌ£¤Ëº¤¤ë¤Î¤¬»þ·×¹ç¤ï¤»¤Ç¤¹¡£ ¤È¤¯¤Ë¥Í¥Ã¥È¥ï¡¼¥¯¤Ë¤Ä¤Ê¤²¤é¤ì¤Ê¤¤¤È¡¢NTP¤Ç»þ¹ï¼èÆÀ¤¬¤Ç¤¤Ê¤¤¤Î¤Ç¡¢ ¥Ç¡¼¥¿¤Î¥í¥°¤ò¼è¤ë¤È¤¤Ë¡¢±³¤Ã¤Ñ¤Á¤Î»þ¹ï¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
¤³¤³¤Ç¤Ï¡¢³°ÉÕ¤±¤Î¥ê¥¢¥ë¥¿¥¤¥à¥¯¥í¥Ã¥¯¥æ¥Ë¥Ã¥È¤ò»È¤Ã¤Æ¡¢´Êñ¤Ë»þ¹ï¤òÊÝ»ý¤¹¤ëµ¡Ç½¤òÄɲä·¤Þ¤¹¡£
NÈÖÀù¤¸´¶¤Ï¤¢¤ê¤Þ¤¹¤¬¡¢³Ð¤¨½ñ¤¤ÈI2CÄÌ¿®¤ÎÊÙ¶¯¤Ä¤¤¤Ç¤Ë¡¦¡¦¡¦
½©·îÅŻҤǰìÈְ²Á¤Ë¹ØÆþ¤Ç¤¤ëIC¡ÖDS1307¡×¤òÁªÄꤷ¤Þ¤·¤¿¡£ DS1307¤Î¥Ç¡¼¥¿¥·¡¼¥È¤ò»²¹Í¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
Raspberry Pi ¥Ô¥óÈÖ¹æ[µ¡Ç½] | RTC ¥æ¥Ë¥Ã¥ÈÀܳÀè | |
Pin03 [SDA1, I2C] | ¢ª | SDA |
Pin05 [SDA1, I2C] | ¢ª | SDA |
Pin04 [GND] | ¢ª | GND |
Pin06 [+5V] | ¢ª | Vcc |
$ sudo apt-get install i2c-tools
$ sudo raspi-config
$ sudo nano /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. snd-bcm2835 i2c-dev rtc-ds1307¤³¤ì¤Çµ¯Æ°»þ¤Ë¡¢¼«Æ°Åª¤Ë¥â¥¸¥å¡¼¥ë¤¬¥í¡¼¥É¤µ¤ì¤Þ¤¹¡£
$ sudo nano /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device exit 0
Ãí°Õ¡§¥Ü¥¿¥óÅÅÃÓ¤ò¤Ä¤Ê¤²¤Æ¤¤¤Ê¤¤¾õÂ֤Ǥϡ¢I2C¤ÎÄÌ¿®¤Î±þÅú¤¬¤¢¤ê¤Þ¤»¤ó¡£É¬¤º¥Ü¥¿¥óÅÅÃÓ¤ò¤Ä¤Ê¤²¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤
pi@raspberrypi:~ $ sudo hwclock hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Input/output error
¢¬¤³¤ó¤Ê¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤¬½Ð¤Þ¤¹¡£
pi@raspberrypi:~ $ dmesg | grep -i ds1307 [ 15.326130] rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc0 [ 15.326196] rtc-ds1307 1-0068: 56 bytes nvram [ 15.332385] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68DS1307¤Î¥É¥é¥¤¥Ð¤òǧ¼±¤·¤Æ¤Þ¤¹¡£
pi@raspberrypi:~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --0x68¤Ë¸¡½Ð¤Ç¤¤Æ¤¤¤Þ¤¹¡£
pi@raspberrypi:~ $ sudo hwclock hwclock: Timed out waiting for time change. hwclock: The Hardware Clock registers contain values that are either invalid (e.g. 50th day of month) or beyond the range we can handle (e.g. Year 2095).¤³¤Î»þÅÀ¤Ç¤Ï¡¢¤Þ¤ÀRTC¤Ë»þ¹ï¤ò½ñ¤¹þ¤ó¤Ç¤ª¤é¤º¡¢»þ¹ï¤Î¤º¤ì¤¬°Û¾ï¤ËÂ礤¤¤¿¤á¡¢·Ù¹ð¤¬½Ð¤Æ¤¤¤Þ¤¹¡£
pi@raspberrypi:~ $ timedatectl status Local time: Fri 2016-09-23 22:54:24 JST Universal time: Fri 2016-09-23 13:54:24 UTC RTC time: Sat 2000-01-01 00:00:00 Time zone: Asia/Tokyo (JST, +0900) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: n/a¤³¤Î»þÅÀ¤Ç¤Ï¡¢¡ÖRTC time¡×¤¬2000ǯ¤Î¤Þ¤Þ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤¬²ò¤ê¤Þ¤¹¡£
pi@raspberrypi:~ $ sudo hwclock -w hwclock: Timed out waiting for time change. pi@raspberrypi:~ $ sudo hwclock -w°ì²ó¤Ç¤Ï¾å¼ê¤¯¤¤¤«¤Ê¤¤¤Î¤Ç¡¢Ê£¿ô²ó¡¢Æ±¤¸¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£
pi@raspberrypi:~ $ timedatectl status Local time: Fri 2016-09-23 22:54:38 JST Universal time: Fri 2016-09-23 13:54:38 UTC RTC time: Fri 2016-09-23 13:54:38 Time zone: Asia/Tokyo (JST, +0900) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: n/a¡ÖUniversal time¡×¤È¡¢¡ÖRTC time¡×¤¬°ìÃפ·¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤ÇRTC¤Ë»þ¹ï¤òÀßÄ괰λ¤Ç¤¹¡£