{"id":276,"date":"2014-02-18T02:31:17","date_gmt":"2014-02-17T17:31:17","guid":{"rendered":"http:\/\/blog.ymyzk.com\/?p=276"},"modified":"2015-02-13T12:07:37","modified_gmt":"2015-02-13T03:07:37","slug":"raspberry-pi-i2c","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2014\/02\/raspberry-pi-i2c\/","title":{"rendered":"Raspberry Pi \u306e I2C \u3092\u6709\u52b9\u5316\u3059\u308b\u65b9\u6cd5 (\u65e7\u7248)"},"content":{"rendered":"

Raspberry Pi \u304c\u6271\u3048\u308b\u4f4e\u30ec\u30d9\u30eb\u5468\u8fba\u6a5f\u5668\u306e\u4e00\u3064\u306b I2C<\/a> \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\u30ab\u30fc\u30cd\u30eb\u304b\u3089\u65b9\u6cd5\u304c\u5909\u308f\u3063\u3066\u3044\u307e\u3059. \u8a73\u3057\u304f\u306f\u65b0\u3057\u3044\u8a18\u4e8b<\/a>\u3092\u5fa1\u89a7\u304f\u3060\u3055\u3044.<\/p>\n

<\/p>\n

\u30d1\u30c3\u30b1\u30fc\u30b8<\/h2>\n

\u30d1\u30c3\u30b1\u30fc\u30b8 i2c-tools<\/a> \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059.<\/p>\n

\r\nsudo apt-get install i2c-tools\r\n<\/pre>\n

\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb<\/h2>\n

\u30c7\u30d5\u30a9\u30eb\u30c8\u3067 I2C \u306e\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30d6\u30e9\u30c3\u30af\u30ea\u30b9\u30c8\u306b\u5165\u3063\u3066\u3044\u3066\u3044\u308b\u305f\u3081, \u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u3053\u308c\u3092\u5916\u3057\u307e\u3059.<\/p>\n

\r\n# blacklist spi and i2c by default (many users don't need them)\r\n\r\nblacklist spi-bcm2708\r\n#blacklist i2c-bcm2708\r\n<\/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.<\/p>\n

\r\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

\u4e00\u5ea6\u518d\u8d77\u52d5\u3057\u3066, 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

\r\n$ lsmod\r\nModule                  Size  Used by\r\nrfcomm                 32939  0\r\nbnep                   10792  2\r\nbluetooth             221259  10 bnep,rfcomm\r\nrfkill                 19138  2 bluetooth\r\nevdev                   9419  1\r\nuinput                  6574  1\r\nfuse                   76145  1\r\nlirc_rpi                7238  3\r\nlirc_dev               10115  1 lirc_rpi\r\ni2c_dev                 5557  0\r\nsnd_bcm2835            16165  0\r\nsnd_soc_bcm2708_i2s     5474  0\r\nregmap_mmio             2806  1 snd_soc_bcm2708_i2s\r\nsnd_soc_core          131268  1 snd_soc_bcm2708_i2s\r\nregmap_spi              1897  1 snd_soc_core\r\nsnd_pcm                81593  2 snd_bcm2835,snd_soc_core\r\nsnd_page_alloc          5156  1 snd_pcm\r\nregmap_i2c              1645  1 snd_soc_core\r\nsnd_compress            8076  1 snd_soc_core\r\nsnd_seq                53769  0\r\nsnd_timer              20133  2 snd_pcm,snd_seq\r\nsnd_seq_device          6473  1 snd_seq\r\nleds_gpio               2059  0\r\nled_class               3688  1 leds_gpio\r\nsnd                    61291  7 snd_bcm2835,snd_soc_core,snd_timer,snd_pcm,snd_seq,snd_seq_device,snd_compress\r\ni2c_bcm2708             3997  0\r\n<\/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 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

\u53c2\u8003<\/h2>\n