Up i2c-tools 作成: 2021-03-22
更新: 2021-03-22


  • Raspbian for robots では,i2c-tools, python-smbus がはじめからインストールされている:
      $ dpkg -l | grep i2c-tools ii i2c-tools 3.1.2-3 armhf heterogeneous set of I2C tools for Linux pi@dex:~ $ dpkg -l | grep python-smbus ii python-smbus:armhf 3.1.2-3 armhf Python bindings for Linux SMBus access through i2c-dev

  • i2c-tools の内容
      i2cget
      i2cset
      i2cdetect
      i2ctransfer
      i2cdump


  • i2c-tool は,/dev/i2c-1 にアクセスする。
    /dev/i2c-1 のアクセス権限は,root と i2cグループ。
    i2c グループには pi が含まれている。
    よって,i2c-tool コマンドは sudo をつけなくてよい。


    $ i2cdetect -l

    $ i2cdetect -y 1
      0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- 08 -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

    $ i2cdetect -F 1
      Functionalities implemented by /dev/i2c-1: Functionalities implemented by /dev/i2c-1: I2C yes SMBus Quick Command yes SMBus Send Byte yes SMBus Receive Byte yes SMBus Write Byte yes SMBus Read Byte yes SMBus Write Word yes SMBus Read Word yes SMBus Process Call yes SMBus Block Write yes SMBus Block Read no SMBus Block Process Call no SMBus PEC yes I2C Block Write yes I2C Block Read yes