【问题标题】:i2cdetect does not recognize VL6180X sensors behind TCA9548A I2C multiplexeri2cdetect 无法识别 TCA9548A I2C 多路复用器后面的 VL6180X 传感器
【发布时间】:2020-05-28 04:13:27
【问题描述】:

我有 2 个 VL6180X 距离传感器正确连接到 TCA9548A 多路复用器,但它只能识别多路复用器本身,而不是 0x70 中看到的 2 个传感器。有什么方法可以配置 i2c 地址吗?

i2cdetect -y 1

给我以下输出

     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,我确实已经在网上搜索过它的解决方案:

我安装了

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

我在内核中启用了 i2c (https://raspberrypi.stackexchange.com/questions/66145/raspberry-pi-3-not-detecting-i2c-device)

将所有内容添加到 config.txt 中,如下所示: I2C not detecting ? issues in hardware or any other?

【问题讨论】:

  • 您必须在内核中启用 I2C 多路复用器 驱动程序,然后为您的传感器启用驱动程序。如果没有驱动,你必须写一个。

标签: raspberry-pi i2c multiplexing


【解决方案1】:

Luca 的答案比这更好,尽管这应该仍然有效。

它不是那样工作的。您无法通过多路复用器“看到”连接的设备。

相反,您打开多路复用器并向其写入一个“控制字节”,告诉它应该将以下数据转发到哪个设备。

【讨论】:

  • 好的,很高兴知道这一点。感谢您的帮助!如何发送控制字节?有代码 sn-p 示例吗?
  • 比这更好,这里有一个小教程...learn.adafruit.com/…
【解决方案2】:

为了让 VL6180X 在 Linux 中的多路复用器后面正确实例化,您应该在设备树中描述它们。看看I2C MUX documentation。

因此,您应该像这样描述整个设置(I2C 多路复用器 + 2x VL6180X):

&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>;
            };
        };
    };
};

这将实例化两个新的总线(用i2cdetect -l 列出它们),并且一个 vl6180 传感器将出现在每个总线下并被描述为常规 IIO 设备。

以上代码是i2c-mux 和VL6180X sensor 的设备树绑定文档的简单组合,可在内核源代码中找到。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-29
    • 1970-01-01
    • 2018-12-06
    • 2019-11-16
    • 2018-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多