Inky pHAT i2c communication via multiplexer (TC9548a)

Hi all

Wondering if anyone has managed to communicate with an Inky pHAT via a multiplexer for the i2c? My RPi has a few other i2c devices connected as well, so I’d like to use a TCA9548a multiplexer for i2c communication.

Inky pHAT appears to be at address 0x50 by default, and I think I’ve found the section of code needed to be changed in the eeprom.py file.

def read_eeprom(i2c_bus=None):
    """Return a class representing EEPROM contents, or none."""
    try:
        if i2c_bus is None:
            try:
                from smbus2 import SMBus
            except ImportError:
                raise ImportError('This library requires the smbus2 module\nInstall with: sudo pip install smbus2')
            i2c_bus = SMBus(1)
        i2c_bus.write_i2c_block_data(EEP_ADDRESS, 0x00, [0x00])
        return EPDType.from_bytes(i2c_bus.read_i2c_block_data(EEP_ADDRESS, 0, 29))
    except IOError:
        return None

In this function, I think the communication part looks for 0x50 (thats the defined value of the variable EEP_ADDRESS). My question is how to change these two lines below so that instead of looking up 0x50 (EEP_ADDRESS), they look at the multiplexer address (0x70, channel 2).

i2c_bus = SMBus(1)
        i2c_bus.write_i2c_block_data(EEP_ADDRESS, 0x00, [0x00])
        return EPDType.from_bytes(i2c_bus.read_i2c_block_data(EEP_ADDRESS, 0, 29))

If anyone has any experience with a similar change, that would be most appreciated :) I’m a bit new to messing around with bus communications, so my apologies if this is a rather simple problem or if it’s been answered elsewhere on he forum :)

Cheers

Just FYI, if no two of your i2c devices share the same address, you don’t need the multiplexer. If that is your issue, check to see if one of the two devices can be set to use an alternate address.

1 Like

Thank you for the heads up here! This was such an oversight by me…I didn’t realise multiple i2c devices could literally be all chained along the same two wires with no multiplexer. I was massively overcomplicating this! I I now have the Inky pHAT and my sensors all going into the same two GPIO pins and its all working nicely :) For any other newbies to i2c this article helped me understand a little bit more!

Learning about i2c

Thanks again!

I was hoping you would say that.
Running
sudo i2cdetect -y 1
will list all the addresses used.

1 Like