I am designing an ESP32 based board using two ADCs (ADS1110) having the same Address that communicate with I2C.

For that I need two I2C interfaces. It's mentioned in the datasheet that the ESP32 has two I2C interfaces.

For the first one, I am using the default ones GPIO21 and GPIO22, respectively for SDA and SCL. It appears that most of the people are using those pins.

I am planning to use GPIO32 and GPIO33 for the second interface.

So am wondering if someone could help me with the programming using micropython.

Arduino people are using the called *"Wire" library. But I have no idea how to make it with micropython. Is it possible via the the called "machine" library?

  • \$\begingroup\$ Part numbers (e.g. for the ADCs) would help. Also, there are ICs that can switch between multiple I2C buses for exactly the issue where multiple I2C slaves have the same address -- so you'd only need one I2C bus for your master. \$\endgroup\$
    – Null
    Aug 27, 2021 at 14:26
  • \$\begingroup\$ Using the ADS1110 as ADCs \$\endgroup\$ Aug 27, 2021 at 14:41
  • 1
    \$\begingroup\$ In the future please edit that information directly into the question. The ADS1110 datasheet indicates it supports up to 8 I2C addresses -- can't you just order the variants for different addresses if you are only using two? \$\endgroup\$
    – Null
    Aug 27, 2021 at 14:45

2 Answers 2


The machine.I2C constructor

class machine.I2C(id, *, scl, sda, freq=400000)

allows you to specify:

  • the id of the I2C bus to use
  • the pins (scl and sda) to use

So you can just create two instances of the I2C class, one for each I2C bus, and use them separately, to read each of the two ADCs.

The ESP32 and associated MicroPython port does indeed support 2 hardware I2C buses, with ids 0 and 1.

from machine import Pin
from machine import I2C

i2c1 = I2C(id=0, scl=Pin(22), sda=Pin(21), freq=400000)
i2c2 = I2C(id=1, scl=Pin(32), sda=Pin(33), freq=400000)

i2c1.writeto(42, b'123')
i2c2.writeto(42, b'123')


Yes, it is possible, and in my experience - it mostly works.

I say 'mostly' because I have seen some occasional issues with the second bus reporting bogus devices present at start.

An initial i2c2.scan() would falsely 'find' devices with IDs all the way up to the ID of the first I2C device physically present on the bus. After that initial scan everything would function properly, but without it, the real I2C device could not be addressed.

In fairness - I was NOT using pins 32,33 for this second bus, but rather GPIO2,15 which were conveniently accessible on the ESP32 WROOM32 DevKit, so that may have been part of the observed problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.