LoginSignup
49
53

More than 5 years have passed since last update.

I2Cとは?

Last updated at Posted at 2016-01-10

I2Cとは

I2Cとはアイ・スクエア・シーの略で、1980年代にPhilips Semiconductor社により開発されたシリアルバス規格。I2Cは、現在 50以上のメーカーの1000以上のICで採用されるにいたっている。Philips Semiconductor社は、再編の末にNXP Semiconductor社に社名が変更され、現在はNXP Semiconductor社よりI2Cバス仕様およびユーザーマニュアルが発行されている。

I2Cの配線

シリアル・データラ イ ン(SDA)とシリアル・ クロックライン(SCL)の 2 本のバスラインで構成されている。

I2Cの配線例

I2Cの通信には、SDAとSCLの2本のバスラインと、VCCとGNDにより通信が可能になる。I2CでMEMSのセンサーと通信する場合、メーカー指定のデカップリング用のコンデンサを配置することで、MEMS Sensorで発生するノイズを除去することが可能になる。 

MEMS Sensorとの配線例)
mems2.png

MEMS SensorとMicro processorで電圧が違う場合は、I2C専用のレベルコンバータを入れる必要がある。
例えば、Texas Instruments製のPCA9306など。

MasterとSlave

転送の開始と終了や転送時のクロック信号を出力を行うマスタと、マスタからアドレス指定されるデバイスであるスレーブにより構成される。1つのマスタに対して複数のスレーブが接続可能である。ただし、1つのバス上で、複数のスレーブのアドレスが異なるようにする必要がある。スレーブデバイスによっては、アドレスが可変できるものがある。

master_slave.png

通信速度

通信速度は、双方向通信が可能なStandard-Mode, Fast-Mode, Fast-Mode Plus, High-speedと、単方向通信のみのUltra Fast-modeの通信が定義されている。

speed.png

I2C Slaveアドレスを自動検索するプログラム(Arduinoサンプル)

http://playground.arduino.cc/Main/I2cScanner

i2c_scanner
// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknow error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

I2Cを採用しているMEMSセンサ

カラーセンサー

気圧センサ

UV Index

Ambient Light

Proximity

Accelerometer

Gyroscope

Magnetic

eCompass

IMU

6AXIS(6軸加速度センサー)

9AXIS(9軸加速度センサ)

Gas(ガス)

Air Quality(空気品質)

Temperature(温度)

Environment(環境センサ)

Thermopile

SensorHUB

Bio

操作系デバイス

Joystick

TouchScreen

LED

LED Driver

NFC

NFC

GPIO

GPIO

ADC

Programmable OCXO

49
53
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
53