M5Core2 for AWS のI2Cに接続しているデバイスを調べてみた。

シリーズ別状況

 出典1:M5LiteのI2C周りを考える
 M5StackとCore2でも、内蔵のI2Cクラスが違うなど機種毎に微妙に異なっているので注意が必要。

M5Stack Core2 M5StickC ATOM
内蔵I2C GPIO 21, 22 21, 22 21, 22 21, 25
内蔵I2C クラス Wire Wire1 Wire1 Wire1
Wireクラス 初期GPIO 21, 22 32, 33 32, 33 26, 32
GROVEポートGPIO 21, 22 32, 33 32, 33 26, 32
HAT GPIO 0, 26

機種別 I2C Address Table

 出典2:I2C Table

NO Product Name I2C Address
1 M5Core 0x75(IP5306)
0x68(MPU6886)
0x6C(SH200Q)
0x10(BMM150)
2 M5Core2 0X34(AXP192)
0x68(MPU6886)
0x38(FT6336U)
0x51(BM8563)
3 M5StickT2 0X34(AXP192)
0x6C(SH200Q)
0x68(MPU6886)
4 Tough 0X34(AXP192)
0x68(MPU6886)
0x2E(CHSC6540)
0x51(HY8563)
5 ATOM Matrix 0x68(MPU6886)
6 CoreInk 0x51(BM8563)
7 M5Paper 0x51(BM8563)
0x14(GT911)
0x44(SHT30)

M5Core2用I2Cスキャナ

 実際に下のコードでI2Cに接続しているデバイスを調べてみると、確かに上の表通り0X34、0x38、0x51、0x68の4つだった。 ただ、何のデバイスなのかまでは分からない、出典2の公式ドキュメントには書いてあるので良しとすることに。

main.cpp
#include <M5Core2.h>
#include <Wire.h>
void setup(){
  M5.begin();
  Wire1.begin();
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setTextColor(GREEN , BLACK); 
  M5.Lcd.setTextSize(3);
  M5.Lcd.setCursor(0, 20);
  M5.Lcd.printf("I2C Device Search\n");
  M5.Lcd.setTextSize(2);
  byte error, address;
  int nDevices;
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();
    if (error == 0){
      M5.Lcd.printf("I2C device : %#x\n", address);
      nDevices++;
    }
    else if (error==4){
      M5.Lcd.printf("Unknown error at address 0x");
    }    
  }
  if (nDevices == 0)
    M5.Lcd.printf("No I2C devices found\n");
  else
    M5.Lcd.printf("done\n");
}

void loop(){
}