{"id":791,"date":"2015-02-13T11:00:38","date_gmt":"2015-02-13T02:00:38","guid":{"rendered":"https:\/\/blog.ymyzk.com\/?p=791"},"modified":"2016-12-09T13:02:22","modified_gmt":"2016-12-09T04:02:22","slug":"enable-raspberry-pi-i2c","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2015\/02\/enable-raspberry-pi-i2c\/","title":{"rendered":"Raspberry Pi \u306e I2C \u3092\u6709\u52b9\u5316\u3059\u308b\u65b9\u6cd5 (2015\u5e74\u7248)"},"content":{"rendered":"

Raspberry Pi \u304c\u6271\u3048\u308b\u4f4e\u30ec\u30d9\u30eb\u5468\u8fba\u6a5f\u5668\u306e\u4e00\u3064\u306b\u00a0I2C<\/a>\u00a0\u304c\u3042\u308a\u307e\u3059. I2C \u30d0\u30b9\u306b\u6e29\u5ea6\u30bb\u30f3\u30b5\u306a\u3069\u3092\u63a5\u7d9a\u3059\u308b\u3068\u6bd4\u8f03\u7684\u7c21\u5358\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059. \u3057\u304b\u3057, \u6a19\u6e96\u306e Raspbian \u3067\u306f I2C \u304c\u7121\u52b9\u5316\u3055\u308c\u3066\u3044\u308b\u305f\u3081, \u3053\u308c\u3092\u6709\u52b9\u5316\u3059\u308b\u305f\u3081\u306b\u3044\u304f\u3064\u304b\u306e\u624b\u9806\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059.<\/p>\n

2015 \u5e74\u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305f Linux 3.18.x \u306e\u30ab\u30fc\u30cd\u30eb\u304b\u3089 Device Tree \u3068\u3044\u3046\u4ed5\u7d44\u307f\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5c0e\u5165\u3055\u308c, \u4ee5\u524d\u7d39\u4ecb\u3057\u305f\u8a18\u4e8b<\/a>\u306e\u5185\u5bb9\u3067\u306f I2C \u3092\u6709\u52b9\u5316\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f.<\/p>\n

<\/p>\n

Raspbian \u3068\u30d5\u30a1\u30fc\u30e0\u30a6\u30a7\u30a2\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8<\/h2>\n

Raspbian \u3068 Raspberry Pi \u306e\u30d5\u30a1\u30fc\u30e0\u30a6\u30a7\u30a2\u3092\u6700\u65b0\u7248\u306b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3057, \u30d5\u30a1\u30fc\u30e0\u30a6\u30a7\u30a2\u306e\u66f4\u65b0\u3092\u9069\u7528\u3059\u308b\u305f\u3081\u518d\u8d77\u52d5\u3057\u3066\u304a\u304d\u307e\u3059.<\/p>\n

sudo apt-get update\r\nsudo apt-get upgrade\r\nsudo apt-get dist-upgrade\r\n\r\nsudo rpi-update\r\n\r\nsudo reboot<\/code><\/pre>\n

\u65b9\u6cd51: raspi-config<\/h2>\n

\u6700\u3082\u624b\u8efd\u306a\u8a2d\u5b9a\u65b9\u6cd5\u3068\u3057\u3066, raspi-config \u3092\u7528\u3044\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059. \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066 raspi-config \u3092\u8d77\u52d5\u3057\u307e\u3059.<\/p>\n

sudo raspi-config<\/pre>\n

“8 Advenced Options” -> “A7 I2C” \u306e\u9806\u306b\u30e1\u30cb\u30e5\u30fc\u3092\u9078\u629e\u3057\u3066, I2C \u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059. \u8a2d\u5b9a\u7d42\u4e86\u5f8c, \u518d\u8d77\u52d5\u3092\u4fc3\u3055\u308c\u308b\u306e\u3067\u518d\u8d77\u52d5\u3057\u307e\u3059.<\/p>\n

\u65b9\u6cd52: \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u624b\u52d5\u4fee\u6b63<\/h2>\n

\/boot\/config.txt \u306e\u672b\u5c3e\u306b\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u8a18\u3057\u307e\u3059.<\/p>\n

dtparam=i2c_arm=on<\/pre>\n

\u8d77\u52d5\u6642\u306b\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u81ea\u52d5\u7684\u306b\u8aad\u307f\u8fbc\u3080\u305f\u3081\u306b, \u4ee5\u4e0b\u306e\u3088\u3046\u306b \/etc\/modules \u306b i2c-dev \u3092\u8ffd\u52a0\u3057\u307e\u3059. \u3053\u306e\u624b\u9806\u306f\u4ee5\u524d\u306e\u65b9\u6cd5<\/a>\u3068\u540c\u3058\u3067\u3059.<\/p>\n

# \/etc\/modules: kernel modules to load at boot time.\r\n#\r\n# This file contains the names of kernel modules that should be loaded\r\n# at boot time, one per line. Lines beginning with \"#\" are ignored.\r\n# Parameters can be specified after the module name.\r\n\r\nsnd-bcm2835\r\ni2c-dev\r\n<\/pre>\n

\u8a2d\u5b9a\u304c\u7d42\u4e86\u3057\u305f\u3089, Raspberry Pi \u3092\u518d\u8d77\u52d5\u3057\u307e\u3059.<\/p>\n

\u30c6\u30b9\u30c8<\/h2>\n

\u518d\u8d77\u52d5\u3057\u305f\u5f8c, lsmod \u3092\u5b9f\u884c\u3057\u3066\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30ed\u30fc\u30c9\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059.<\/p>\n

$ lsmod\r\nModule                  Size  Used by\r\nbinfmt_misc             7161  1 \r\ni2c_bcm2708             6200  0 \r\nuio_pdrv_genirq         3666  0 \r\nuio                     9897  1 uio_pdrv_genirq\r\ni2c_dev                 6709  0 \r\nsnd_bcm2835            21342  0 \r\nsnd_pcm                93100  1 snd_bcm2835\r\nsnd_timer              23007  1 snd_pcm\r\nsnd                    67211  3 snd_bcm2835,snd_timer,snd_pcm\r\nfuse                   92121  1 \r\nipv6                  351566  16 <\/pre>\n

\u3053\u308c\u3067, Raspberry Pi \u3067 I2C \u30d0\u30b9\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u6e96\u5099\u304c\u6574\u3044\u307e\u3057\u305f. i2cdetect \u3092\u4f7f\u3063\u3066, \u73fe\u5728 I2C \u30d0\u30b9\u306b\u63a5\u7d9a\u3055\u308c\u3066\u3044\u308b\u30c7\u30d0\u30a4\u30b9\u306e\u60c5\u5831\u3092\u51fa\u529b\u3067\u304d\u307e\u3059.<\/p>\n

\u4ee5\u4e0b\u306f, Raspberry Pi Model B Rev. 2 \u3067 2\u3064\u306e I2C \u30c7\u30d0\u30a4\u30b9\u3092\u63a5\u7d9a\u3057\u305f\u3068\u304d\u306e\u4f8b\u3067\u3059.<\/span><\/p>\n

\r\n$ sudo apt-get install i2c-tools\r\n$ sudo i2cdetect -y 1\r\n     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\r\n00:          -- -- -- -- -- -- -- -- -- -- -- -- --\r\n10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --\r\n50: -- -- -- -- -- -- -- -- -- -- -- -- -- 5d -- --\r\n60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n70: -- -- -- -- -- -- -- --\r\n<\/pre>\n

\u305d\u306e\u4ed6<\/h2>\n

\u5148\u65e5\u767a\u58f2\u3055\u308c\u305f Raspberry Pi 2 Model B \u3067\u3082\u57fa\u672c\u7684\u306a\u624b\u9806\u306f\u540c\u3058\u306a\u3088\u3046\u3067\u3059. \u4f55\u304b\u554f\u984c\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u53c2\u8003\u306e\u8cc7\u6599\u3082\u5f53\u305f\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044.<\/p>\n

Device Tree \u306b\u3064\u3044\u3066\u306f, Raspbian \u5185\u306e \/boot\/overlays\/README \u3092\u8aad\u3080\u3053\u3068\u3082\u304a\u52e7\u3081\u3057\u307e\u3059.<\/p>\n

\u53c2\u8003<\/h2>\n