Every device with an integrated i2c protocol has an address associated with it. Many devices such as OLED i2C display screen usually utilize the default address of 0x27 where 0x shows the hex format of the numbers. But the address can be different in some cases. This address depends on the position of pins correlated with A0, A1, and A2 on the I2C controller on this device.

The Raspberry Pi PICO i2C

The Raspberry Pi integrates i2C controller this controller is accessible through GPIO pins of RPI-PICO. See the below schematics for the pin location. However, this connection of the master controller can be configured through multiple GPIO pins set by your code, and each i2c device that attaches to the GPIO pins should have a unique communication address, using the code below we can search and look which i2c address communicates to our i2c master controller

Scanning the i2C address with MicoPython

You just have to copy the code below and upload it to your favorite development board that supports MicroPython make sure that your i2c-supported devices and modules are already hooked to your development board such Raspberry Pi PICO. The code will scan all any i2c supported devices connected to your development board and it will determine the number of devices utilizing an i2C address on the console.

Source Code

Downloads

 

How to Identify i2C Address in MicroPython
Facebooktwitterredditpinterestmail
Tagged on:                     

JLCPCBPCBgogoPCBway4pcb

6 thoughts on “How to Identify i2C Address in MicroPython

  • at
    Permalink

    I’ve tried the code and the result is wrong:

    Scan i2c bus…
    14CORE – i2c Finder / Scanner
    i2c devices found: 112
    i2C Address: 0x8
    i2C Address: 0x9
    i2C Address: 0xa
    i2C Address: 0xb
    ……

    and so on.

    I’ve only one device connected, how is it possible?

    Reply
    • at
      Permalink

      Which device you attach to your host? some devices/ sensor has multiple address to talk.

      Reply
  • at
    Permalink

    I think it’s an hardware problem, with a different Pico it works.

    Reply
  • at
    Permalink

    Sie müssen nur den folgenden Code kopieren und auf Ihr bevorzugtes Entwicklungsboard hochladen, das MicroPython unterstützt. Stellen Sie sicher, dass Ihre i2c-unterstützten Geräte und Module bereits an Ihr Entwicklungsboard wie Raspberry Pi PICO angeschlossen sind.

    Reply
    • at
      Permalink

      Plötzlicher Verbindungsabbruch, Fehler beim Verbindungsaufbau, evtl. Verkabelungsfehler

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *