hux0
hux0

Reputation: 207

i2cdetect does not recognize VL6180X sensors behind TCA9548A I2C multiplexer

I have 2 VL6180X Distance Sensors properly connected to a TCA9548A Multiplexer, however it only recognizes the Multiplexer itself and not the 2 sensors as you can see with the 0x70. Is there any way to configure the i2c adresses?

i2cdetect -y 1

gives me the following output

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

Ofc, I did already search the web to find a solution for it:

I installed

sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools

I enabled i2c in the kernel (https://raspberrypi.stackexchange.com/questions/66145/raspberry-pi-3-not-detecting-i2c-device)

Added everything to config.txt as in here: I2C not detecting ? issues in hardware or any other?

Upvotes: 1

Views: 1495

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207650

Luca's answer is better than this, though this should still work.

It doesn't work like that. You can't "see" the attached devices through the multiplexer.

Instead, you open the multiplexer and write a "control byte" to it, to tell it which device it should forward the following data to.

Upvotes: 1

Luca Ceresoli
Luca Ceresoli

Reputation: 1661

In order to have the VL6180X properly instantiated behind a mux in Linux you should describe them in device tree. Have a look at the I2C MUX documentation.

Thus you should describe the whole setup (I2C mux + 2x VL6180X) like this:

&i2c1 { // the SoC bus controller
    mux@70 {
        compatible = "nxp,pca9548";
        reg = <0x70>;
        #address-cells = <1>;
        #size-cells = <0>;

        i2c@3 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <3>;

            gpio1: gpio@29 {
                compatible = "st,vl6180";
                reg = <0x29>;
            };
        };

        i2c@4 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <4>;

            gpio1: gpio@29 {
                compatible = "st,vl6180";
                reg = <0x29>;
            };
        };
    };
};

This will instantiate two new busses (list them with i2cdetect -l) and one vl6180 sensor will appear under each of them and be described as regular IIO devices.

The above code is a simple mix of device tree binding documentation for i2c-mux and for the VL6180X sensor, available in the kernel sources.

Upvotes: 3

Related Questions