• Äɲ䵤줿¹Ô¤Ï¤³¤Î¿§¤Ç¤¹¡£
  • ºï½ü¤µ¤ì¤¿¹Ô¤Ï¤³¤Î¿§¤Ç¤¹¡£
#contents

*¤Ï¤¸¤á¤Ë [#o219512a]
Raspberry Pi¤Çµ¡´ï¤òºî¤Ã¤Æ¤¤¤ë¤È¡¢ÃÏÌ£¤Ëº¤¤ë¤Î¤¬»þ·×¹ç¤ï¤»¤Ç¤¹¡£
¤È¤¯¤Ë¥Í¥Ã¥È¥ï¡¼¥¯¤Ë¤Ä¤Ê¤²¤é¤ì¤Ê¤¤¤È¡¢NTP¤Ç»þ¹ï¼èÆÀ¤¬¤Ç¤­¤Ê¤¤¤Î¤Ç¡¢
¥Ç¡¼¥¿¤Î¥í¥°¤ò¼è¤ë¤È¤­¤Ë¡¢±³¤Ã¤Ñ¤Á¤Î»þ¹ï¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£

¤³¤³¤Ç¤Ï¡¢³°ÉÕ¤±¤Î¥ê¥¢¥ë¥¿¥¤¥à¥¯¥í¥Ã¥¯¥æ¥Ë¥Ã¥È¤ò»È¤Ã¤Æ¡¢´Êñ¤Ë»þ¹ï¤òÊÝ»ý¤¹¤ëµ¡Ç½¤òÄɲä·¤Þ¤¹¡£

NÈÖÀù¤¸´¶¤Ï¤¢¤ê¤Þ¤¹¤¬¡¢³Ð¤¨½ñ¤­¤ÈI2CÄÌ¿®¤ÎÊÙ¶¯¤Ä¤¤¤Ç¤Ë¡¦¡¦¡¦


*¼Â¸³´Ä¶­ [#n78b3ba7]


*RTC¥æ¥Ë¥Ã¥È¤ÎÀ½ºî [#j02fbb7c]

½©·îÅŻҤǰìÈְ²Á¤Ë¹ØÆþ¤Ç¤­¤ëIC¡ÖDS1307¡×¤òÁªÄꤷ¤Þ¤·¤¿¡£
DS1307¤Î¥Ç¡¼¥¿¥·¡¼¥È¤ò»²¹Í¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
|&ref("01_circuit.png",,70%,);|
|&ref("01_circuit.png",,80%,);|


-»îºî¤·¤¿´ðÈĤγ°´Ñ
|&ref("02_Board_a.jpg",,50%,);|&ref("02_Board_b.jpg",,50%,);|
|¼ÂÁõ¡¦É½|¼ÂÁõ¡¦Î¢|


*Raspberry Pi¤È¤ÎÀܳ [#ue74e479]

|||
|&ref("pi3_gpio.png",,30%,);|


|Raspberry Pi ¥Ô¥óÈÖ¹æ[µ¡Ç½]||RTC ¥æ¥Ë¥Ã¥ÈÀܳÀè|h
|Pin03 [SDA1, I2C] |¢ª|SDA|
|Pin05 [SDA1, I2C] |¢ª|SDA|
|Pin04 [GND] |¢ª|GND|
|Pin06 [+5V] |¢ª|Vcc|


*Raspbian¤Î½é´üÀßÄê [#nf7dbf66]

-£±¡¥I2C¥Ä¡¼¥ë¤Î¥¤¥ó¥¹¥È¡¼¥ë
 $ sudo apt-get install i2c-tools

-£²¡¥Raspberri Pi Config¤ÎÀßÄê¤òÊѹ¹
 $ sudo raspi-config
 
+¡Ö9 Advanced Options Configure advanced settings¡×¤òÁªÂò
+¡ÖA7 I2C             Enable/Disable automatic loading of I2C kernel module¡×¤òÁªÂò
+¡ÖWould you like the ARM I2C interface to be enabled?¡×¢ª''¡ÖYES¡×¤òÁªÂò''
+¡ÖWould you like the I2C kernel module to be loaded by default?¡×¢ª''¡ÖYES¡×¤òÁªÂò''
++'''¡Ö9 Advanced Options Configure advanced settings¡×'''¤òÁªÂò
++'''¡ÖA7 I2C             Enable/Disable automatic loading of I2C kernel module¡×'''¤òÁªÂò
++'''¡ÖWould you like the ARM I2C interface to be enabled?¡×'''¢ª''¡ÖYES¡×¤òÁªÂò''
++'''¡ÖWould you like the I2C kernel module to be loaded by default?¡×'''¢ª''¡ÖYES¡×¤òÁªÂò''


-£³¡¥/etc/modules ¤Ë¡¢ÀßÄê¤òÄɵ­
 $ 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
¤³¤ì¤Çµ¯Æ°»þ¤Ë¡¢¼«Æ°Åª¤Ë¥â¥¸¥å¡¼¥ë¤¬¥í¡¼¥É¤µ¤ì¤Þ¤¹¡£

-£´¡¥µ¯Æ°»þ¤Ë¡¢ds1307¤òI2C¥Ç¥Ð¥¤¥¹¤È¤·¤ÆÍ­¸ú¤Ë¤¹¤ëµ­½Ò¤òÄɵ­
 $ 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

-£µ¡¥ºÆµ¯Æ°¤¹¤ë


*RTC¤ÈÄÌ¿®¤·¤Æ¤ß¤ë [#t70ec231]

''Ãí°Õ¡§¥Ü¥¿¥óÅÅÃÓ¤ò¤Ä¤Ê¤²¤Æ¤¤¤Ê¤¤¾õÂ֤Ǥϡ¢I2C¤ÎÄÌ¿®¤Î±þÅú¤¬¤¢¤ê¤Þ¤»¤ó¡£É¬¤º¥Ü¥¿¥óÅÅÃÓ¤ò¤Ä¤Ê¤²¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤''
 pi@raspberrypi:~ $ sudo hwclock
 hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Input/output error
¢¬¤³¤ó¤Ê¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤¬½Ð¤Þ¤¹¡£


-£±¡¥¤Þ¤º¡¢DS1307¤Î¥É¥é¥¤¥Ð¤¬ÁȤ߹þ¤Þ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¡£
 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 0x68
DS1307¤¬¡¢0x68¤Ë¸¡½Ð¤Ç¤­¤Æ¤¤¤Þ¤¹¡£

-£²¡¥I2CÄÌ¿®·Ðͳ¤Ç¡¢DS1307¤òǧ¼±¤·¤Æ¤¤¤ë¤«³Îǧ¡£
 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ǯ¤Î¤Þ¤Þ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤¬²ò¤ê¤Þ¤¹¡£

-£µ¡¥¥·¥¹¥Æ¥à¥¯¥í¥Ã¥¯¤ò¡¢RTC¤ØƱ´ü¤·¤Þ¤¹¡£
 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¤Ë»þ¹ï¤òÀßÄ괰λ¤Ç¤¹¡£


*¤½¤Î¾ [#j057b21f]

**¥Ð¥Ã¥¯¥¢¥Ã¥×ÅÅÃӤμ÷Ì¿ [#a10444b1]
-http://www.edaboard.com/thread34325.html
¤³¤Á¤é¤Î¹Í»¡¤Ë¤è¤ë¤È¡¢Ä̾ï¤Î¥ê¥Á¥¦¥à¥Ü¥¿¥óÅÅÃӤǡ¢¤¶¤Ã¤È£±£°Ç¯ÄøÅÙ»ý¤Ä¤è¤¦¤Ç¤¹¡£


*»²¹Í [#n73a3270]
-https://mynotebook.h2np.net/post/1085
-http://qiita.com/key/items/06c2915de55d6155aa54


RIGHT:2016-09-24 (ÅÚ) 07:54:13
----
[[Elec]]


¥È¥Ã¥×   ¿·µ¬ °ìÍ÷ ¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS