BME280 doesn't work if placed in another i2c Bus different than 1 #414
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
I installed a BME280 board through GPIO pins 23 and 24, because i2c standard pins are used by Fan Shim, in my Raspberry Pi 4 using OctoPi. I configured the sensor in the OctoPrint plugin by specifying the i2c Bus as 11, which is the one being detected by
i2cdetect -y 11. I tried running in terminal~/oprint/lib/python3.7/site-packages/octoprint_enclosure $ python3 BME280.py 76and it didn't work until I edited line 14 replacingbus = smbus.SMBus(1)withbus = smbus.SMBus(11). But even that didn't make it work through OctoPrint, showing 0ºC and 0%.EDIT: disabling 'Use SUDO' (Use sudo to run python commands.) in the hidden advanced options now shows the values in Octoprint. But still, editing the file BME280.py is necessary.
To Reproduce
Move a working BME280 from standard i2c bus 1 to another one set up in
/boot/config.txt. Test it with the commands written above and other example scripts from tutorials to check that the BME280 works. Check that OctoPrint is unable to show the module values unless BME280.py is edited.Expected behavior
It should work after defining i2c Bus as 11 in Enclosure Plugin 'Add Input' setup.
Additional context

I had similar issue after update (try go to logs and check what is is saying)
I had to install smbus/smbus2 (both user and sudo)
pip3 install smbuspip3 install smbus2restarted and worked like charm, try and post result or at least log :)
Same problem here, used 2x BME280 and tried first with 2x 1c2 bus and second with TCA9548A. Both times just first bus is used and temperature of first bus is shown for both. Installation of smbus smbus2 is not working in my case.
I am having the same issue, my sensor is on
0x76I tried installing the 2 smbus and still dont have a temperature showing on the enclosure plugin UI, the sensor works because I can get its status, see belowThank-you @lpla and @ddB0515 !!!!! 👍
I have a Piicodev BME280 running off the i2C headers on a Hyperpixel 4.0 touch screen as the i2C headers on the pins are taken by the screen itself.
The install instruction are outdated, so the install command
sudo apt-get install i2c-tools python-pip python-smbusfails.The i2C bus field value in the settings is ignored.
The combo of installing smbus and smbus2, editing the BME280.py file and turning off Use SUDO fixed it.