kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.94k stars 492 forks source link

Running 2 BME680 on 1 i2c bus with master/slave address - second sensor not initializing #1390

Open bigfoot996 opened 1 month ago

bigfoot996 commented 1 month ago

Describe the problem/bug

I'm trying to run 2 BME680 on the same i2c bus via master/slave (both sensors recognized by Pi on adresses 0x76 and 0x77). Set up 2 inputs with the respective adresses in mycodo, but the slave sensor is not giving any measurments. The logs are showing the following:

2024-07-18 12:53:31,680 - ERROR - mycodo.utils.inputs - Error: Cannot add input modules because it does not have a unique name: BME680 2024-07-18 12:53:31,723 - ERROR - mycodo.inputs.bme680_backup_b737f7ce - Error initializing, trying again in 5 seconds: [Errno 121] Remote I/O error Traceback (most recent call last): File "/var/mycodo-root/mycodo/abstract_base_controller.py", line 57, in try_initialize self.initialize() File "/home/admin/Mycodo/mycodo/inputs/bme680_backup.py", line 363, in initialize self.sensor = bme680.BME680( ^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/bme680/__init__.py", line 25, in __init__ self.chip_id = self._get_regs(CHIP_ID_ADDR, 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/bme680/__init__.py", line 296, in _get_regs return self._i2c.read_byte_data(self.i2c_addr, register) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/smbus2/smbus2.py", line 433, in read_byte_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error 2024-07-18 12:53:36,725 - ERROR - mycodo.inputs.bme680_backup_b737f7ce - Error initializing, trying again in 5 seconds: [Errno 121] Remote I/O error Traceback (most recent call last): File "/var/mycodo-root/mycodo/abstract_base_controller.py", line 57, in try_initialize self.initialize() File "/home/admin/Mycodo/mycodo/inputs/bme680_backup.py", line 363, in initialize self.sensor = bme680.BME680( ^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/bme680/__init__.py", line 25, in __init__ self.chip_id = self._get_regs(CHIP_ID_ADDR, 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/bme680/__init__.py", line 296, in _get_regs return self._i2c.read_byte_data(self.i2c_addr, register) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/smbus2/smbus2.py", line 433, in read_byte_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error 2024-07-18 12:53:41,726 - ERROR - mycodo.inputs.bme680_backup_b737f7ce - Initialization errored 3 times; giving up. Maybe the following traceback can help diagnose the issue. Traceback (most recent call last): File "/var/mycodo-root/mycodo/abstract_base_controller.py", line 57, in try_initialize self.initialize() File "/home/admin/Mycodo/mycodo/inputs/bme680_backup.py", line 363, in initialize self.sensor = bme680.BME680( ^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/bme680/__init__.py", line 25, in __init__ self.chip_id = self._get_regs(CHIP_ID_ADDR, 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/bme680/__init__.py", line 296, in _get_regs return self._i2c.read_byte_data(self.i2c_addr, register) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/mycodo-root/env/lib/python3.11/site-packages/smbus2/smbus2.py", line 433, in read_byte_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error 2024-07-18 12:53:41,727 - DEBUG - mycodo.controllers.controller_input_b737f7ce - get_measurement() found 2024-07-18 12:53:41,727 - DEBUG - mycodo.controllers.controller_input_b737f7ce - listener() not found 2024-07-18 12:53:41,727 - INFO - mycodo.controllers.controller_input_b737f7ce - Activated in 10128.4 ms 2024-07-18 12:53:41,727 - ERROR - mycodo.inputs.bme680_backup_b737f7ce - Error 101: Device not set up. See https://kizniche.github.io/Mycodo/Error-Codes#error-101 for more info.

Versions:

Mycodo Version: 8.5.13
Raspberry Pi Version: [e.g. 3B+] Raspberry Pi 5 8 GB
Raspbian OS Version: Debian 12 - 6.6.31+rpt-rpi2712

Reproducibility

always the same if you deactivate/activate it.

Expected behavior

Since the logs show something regarding the slave sensor doesn't get a unique name and probably that's the reason it can't be used probably, I would expect that "the logic" gives it a unique name in the initialization process for it to run properly.

Thanks and best greetings :)