MAX 44009 环境光传感器运行期间 I2C 地址变化

I2C address changing during operation for MAX 44009 ambient light sensor

我部署了一个 raspberry pi 项目并且 运行 其中包括 Maxim Integrated MAX 44009 环境光传感器。使用默认的 I2C 地址 0x4A 运行 没问题。

我停止了 运行 python 程序并重新启动程序,立即开始看到“输入输出错误 errno = 5”。

Traceback (most recent call last):
  File "lumi.py", line 6, in <module>
    max44009 = MAX44009()
  File "/home/pi/max/MAX44009.py", line 48, in __init__
    self.write_config()
  File "/home/pi/max/MAX44009.py", line 53, in write_config
    bus.write_byte_data(MAX44009_DEFAULT_ADDRESS, MAX44009_REG_CONFIG, CONFIG)
OSError: [Errno 5] Input/output error

我 运行 i2cdetect -y 1 发现它的地址从默认的 0x4A 变成了 0x4B !将程序更改为使用 0x4B 并再次运行。

所以我的问题是这可能是什么原因造成的?

在查看这个问题的数据时,我意识到我没有连接引脚 A0,这意味着它是浮动的。将 A0 拉高选择地址 0x4B;并将 A0 拉低选择地址 0x4A。

我假设这是在配置期间采样的,因此为什么它仅在重新启动程序后才更改。

PIN NAME PIN DESCRIPTION
1 VCC Power Supply
2 GND Ground
3 A0 Address Select. Pull high to select address 1001 011x or low to select address 1001 010x.
4 INT Interrupt Output. Use an external pullup resistor.
5 SCL I2C Clock Bus
6 SDA I2C Data Bus
— EP Exposed Pad. Connect EP to ground.