I2C access with Raspberry Pi Connector


#1

Hi everyone,

I’m using the mangOH RED with a WP8548 module. I’m trying to access a sensor with i2c interface by using the Raspberry Pi connector provided with the mangOH but I have encountered some issues.
First of all, I tested the i2c connection and can confirm it works : I managed to read the id register of the BMP280 available at 0x76 i2c address.
I tried the batteryReading example available on the GitHub to have a better understanding on how it works. And this is where the issue occured : the application crashed when trying to write i2c data to the i2c expander at address 0x71. I understand that the ports of this expander must be enabled in order to access the battery charger. This is problematic especially because it is also needed to access Raspberry Pi i2c interface. I ran a scan on the i2c bus 0 with an ssh connection and couldn’t see a device at address 0x71. However, I could see devices at 0x68 and 0x76 (accelerometer and pressure sensor respectively, according to the datasheets).
Is the i2c expander not active by default ? Should I do something to enable its use ?

Thanks in advance,
Best regards,
Alex


#2

I’m not sure exactly what you have loaded on your mangOH Red, so some of this is speculation…

There is a kernel driver (pca954x) available for the I2C switch at address 0x71. If you do i2cdetect -y -r 0 and the entry for 0x71 shows up as UU, then you likely have that kernel module bound to that device. If that’s the case, then you should also have /dev/i2c-1, /dev/i2c-2, /dev/i2c-3, /dev/i2c-4. These are virtual I2C buses created by the pca954x. Bus 1 represents downstream port 1 of the i2c switch. /dev/i2c-0 represents the main i2c bus.

On page 3 of the mangOH Red DV3 schematic we can see the Raspberry Pi header. The I2C lines are labeled SCL_EXP and SDA_EXP. If you click on the label, you will be sent to page 4 of the schematic. You can see that SCL_EXP and SDA_EXP are coming from SD3 and SC3 of the TCA9546A. The hardware ports numbered 0-3 correspond to virtual buses 1-4, so in this case you should access your sensor using /dev/i2c-4. The driver for the TCA9546A automatically takes care of writing to the device to enable/disable the correct port when you access one of the virtual i2c buses.


#3

Thank you David for your answer,

The thing is that I’ve tried to scan i2c busses already by entering the exact command you mentioned and the device at 0x71 doesn’t seem to respond since is written, and not UU. This means that I don’t have any virtual I2C busses and I made sure of that by entering ls /dev/i2c*. The result of this command was /dev/i2c-0 and nothing else.

Alex


#4

Try disconnecting the device from the raspberry pi connector, reboot and try scanning the i2c bus again. If 0x71 still doesn’t show up, then I am worried that the chip is not installed correctly or is damaged.


#5

Thank you David for your help,

After scanning the i2c bus again, 0x71 still doesn’t show up. There might be damage that I will need to investigate.

Alex