Skip to content

サンプル I2C – デバイススキャン

TakeoTakahashi2020 edited this page Sep 21, 2021 · 4 revisions

image

  • I2Cバスをスキャンして、接続されているデバイスのアドレスを表示します。
  • RA4M1 Clickerの例:
import machine

i2c = machine.I2C(scl=machine.Pin.cpu.P205, sda=machine.Pin.cpu.P206)

print('Scan i2c bus...')
devices = i2c.scan()

if len(devices) == 0:
  print("No i2c device !")
else:
  print('i2c devices found: ', len(devices))

for device in devices:
  print("Decimal address: ", device, " | Hexa address: ", hex(device))

image

  • EK-RA6M2では、scl(P100), sda(P206), VCC, GND の4ピンを接続します。
  • RA4M1 Clickerでは、scl(P205), sda(P206), VCC, GND の4ピンを接続します。
  • ソフトウェアI2Cなので、別のピンでも接続できます。

Home

ホーム

Clone this wiki locally