Using the alternate I2C interface on HyperPixel 4.0

The guidance on ‘Getting Started with HyperPixel 4.0’ doesn’t make it particularly clear how to get I2C to work.

The symlink example hasn’t worked on three different PIs:

By installing i2c-tools, I’ve checked available devices and get these for my latest install -

pi@CM4-2GB:~ $ i2cdetect -l
i2c-20  i2c             fef04500.i2c                            I2C adapter
i2c-21  i2c             fef09500.i2c                            I2C adapter
i2c-22  i2c             i2c@0                                     I2C adapter

So the guidance about i2c-3 redirect doesn’t work… a previous install had devices 10 to 12.

Also it would be helpful to state that i2c must not be enabled in raspi-config.

Hardware used: Pi3A, CM4 on Waveshare Nano Base Board (B) and Mini Base Board (B)
PiOS Bookworm 64bit and 32bit

I2C on the CM4 is not the same as I2C on the normal Pi. So this is not surprising.

There had been some conversations about this topic some time ago. I know that searching in the forums is not easy, but you will find something if you look hard enough. The conclusion was if I remember correctly that you could use the same I2C as the touch-controller, but you must bypass the OS-level access (i.e. /dev/i2c*) and communicate with the I2C-bus directly. For Python this is no problem.

Thanks for the reply bablokb. I have had success using the i2c with Python on all three computers I’ve connected to the display, including the Pi3A - which named it i2c-11. I’m using the non-touch model.

The reason for me posting was to give some feedback that the documentation could be clearer and more explicit.

For example:

To check the assigned address:

~ $ ls /dev/i2c*
/dev/i2c-20  /dev/i2c-21  /dev/i2c-22

The last listed device is the one to use. Check the python driver and utility tools are installed:

~ $ sudo apt install python3-smbus -y
~ $ sudo apt install i2c-tools -y

Then you can check the connected device is attached to the i2c bus:

~ $ i2cdetect -y 22
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Here is some sample Python code to check the bus is accessible.

init        = True
DEVICE_BUS  = 22
DEVICE_ADDR = 0x50

try:
    import smbus
    bus = smbus.SMBus(DEVICE_BUS)
except (ModuleNotFoundError, FileNotFoundError):
    init = False
2 Likes

Thanks for sharing this Chris - a revised Hyperpixel getting started guide has been on my to-do list for a while but it’s been a very busy couple of months for us!

I’ll be sure to include this information when I get to it - is it OK if I link this post from the shop page in the meantime?

1 Like

Absolutely! :-) Information is to be shared

2 Likes