Changing the default i2c address of IO Expander breakout

I’ve tried seti2cAdr (not found) and set_address (does nothing). How do I change the default address of this device on a pico?


Is it detected if you do an i2c scan?

import machine
sda=machine.Pin(4) # Explorer 20 Breakout 4
scl=machine.Pin(5) # Explorer 21 Breakout 5
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
print('Scan i2c bus...')
devices = i2c.scan()
if len(devices) == 0:
  print("No i2c device !")
  print('i2c devices found:',len(devices))
  for device in devices:  
    print("Decimal address: ",device," | Hex address: ",hex(device))

Thanks for your reply. I can connect to the device just fine by the default address of 0x18, but I cannot change it. It always turns up as 0x18. I even tried directly writing to it, like this:

i2c.writeto_mem(0x18, 0xfd, bytearray([0x19]))

OK, just wanted to make sure it was being detected.
I have one but haven’t tried to change its address, no need to so far.
Can you post a link to the procedure, so I can have a look see as to how its done?

Well, the problem is that I don’t understand how i can access the pimoroni library for this, only the examples. I’m a total noob when it comes to Python. I’ve just found the library for the python version:

So normally, with other devices, you just do this:
ioe = BreakoutIOExpander(i2c, address=0x18)

The Pico Micro Python examples are here.
pimoroni-pico/micropython/examples/breakout_ioexpander at main · pimoroni/pimoroni-pico (

@hel Hel Gibbons should be able to help you out.

Ok thanks, yeah I see the examples, but there is no example on how to change address :(

Hopefully @hel knows what’s up… :)

She has posted how to do it a few times, I couldn’t find it with a search though?

Ahoy! To change the I2C address using Python and the ioexpander library it’s:

import ioexpander

ioe = ioexpander.IOE(CURRENT_I2C_ADDRESS)


or you can do it from a Linux command line with

i2cset -y 1 0x18 0xFE 0x10  
i2cset -y 1 0x18 0xFD 0x19

(where 0x18 is the existing address and 0x19 is the address you want to change it to).

To see if it’s worked, it’s i2cdetect -y 1 at the command line to list all I2C devices.

@hel , So you need to do it on a Pi in Python?

You can either do it in Python (if you’ve got the library installed) or using your Pi’s command line / terminal.

Yes, this is micropython and the device is advertised as being able to change the address on the pico. But thanks to your codes and i2c it is pretty simple:

i2c.writeto_mem(0x18, 0xFE, bytearray([0x10]))
i2c.writeto_mem(0x18, 0xFD, bytearray([0x19]))

I was just missing the first upcode. You should change your documentation or add this to the examples, as i’m running more than 8 adc’s and your board is a great option, just ordered a bunch more.

Oh sorry, I missed that you were using a Pico and not a Pi - glad to hear that you figured it out!

I’ll see if I can make the shop page a little more helpful with regard to changing the address.

Looks like you can do it using the MicroPython ioexpander module too, I’ve dropped an example into pimoroni-pico showing that:

1 Like

Yeah, something wasn’t right for sure, as set_address didn’t yield an error, but didn’t do anything either. I encountered the same problem with the rgb rotaty encoder btw, I don’t know if your pull request will fix that or not. Thanks for your help!

Btw, is there a way to look inside the libraries? I’m such a noob when it comes to micropython lol.