RGB Encoder Breakout Address Change

I have just purchased 2 * RGB Encoder Breakout boards, the shop says it is possible to change the address to avoid conflicts but I cannot find any instructions to do so.

Any help?

The product page it says it can be changed in software, rather than the usual solder-bridging.

Taking a look at the provided example it seems like you might be able to specify the address when you instantiate the device?

ioe = io.IOE(i2c_addr=0x18, interrupt_pin=4)

Thanks major_tom,

So at boot up I have two RGB rotary encoders plugged in both on 0x0F, how do I set one of them to for example 0x0E so I can differentiate between them, furthermore how do I set this address in flash memory?

The shop page says:-
“The default I2C address is 0x0F, but it’s possible to change this in software if you’d like to use multiple RGB Encoder Breakouts, or avoid conflicts with other I2C devices. The new address will be saved in flash memory, so will persist if unpowered.”


That bit sounded a bit like magic to me as well.

I can only guess that you’d be able to plug one in and change the address? The next time you tried to use it, it would still be on that new address? Then you could plug the second one in?

Ahah, here’s the magic function:

 def set_i2c_addr(self, i2c_addr):
    """Set the IOE i2c address."""
    self.set_bit(REG_CTRL, 4)
    self.i2c_write8(REG_ADDR, i2c_addr)
    self._i2c_addr = i2c_addr
    time.sleep(0.25)  # TODO Handle addr change IOError better
    # self._wait_for_flash()
    self.clr_bit(REG_CTRL, 4)

Hi major_tomm,

Sorry for the incorrect name last time.

My encoders have not arrived yet but I hope they will this week.

We are obviously on the same page. It has to be done one at a time.

Where did you get that code from?


From the example linked on the product page I had a bit of a click through the git repository.

This page contains all the functions available in the library.

The IOE class is the one we’re interesting in I think.


My encoders have arrived, they are both set on 0x0F (no surprise there) I can drive one of them quite happily but I cant drive both . My challenge is that I write normally in Javascript (Node Red) I now have two rotary encoders both on 0x0F and want to change one of them to 0x0E.

I have looked at the set_i2c_addr(self, i2c_addr) function you sent me but dont really know how to use it.

#!/usr/bin/env python3
import time
import ioexpander as io

ioe = io.IOE(i2c_addr=0x0f, interrupt_pin=4)

A simple example would set me on my way, any chance of some help, what am I doing wrong?

Kind regards,

My guess would be something like this:

import time
import ioexpander as io

ioe = io.IOE(i2c_addr=0x0f, interrupt_pin=4)

Your a bloody genius!!!

1 Like

I don’t know about that, I just work with Python a bit as part of my day job :)

Glad it’s working.

I am struggling to get my head around the “self” bit, to me the function “def set_i2c_addr(self, i2c_addr):” requires two parameters one for self and one for i2c_addr.
If I had dropped off the ioe parameter in “ioe.set.addr(ioe,0x0e)” I would have got it right.
How can a function specifying two parameters require only one?
Thanks for all your help.

self represents an instance of the IOE class. When you call set_addr from an instance of the class that parameter gets automatically filled in for you.

I’m not quite sure why that’s the case, someone else might have a better answer.