BME280 doesn't work if placed in another i2c Bus different than 1 #414

Open
opened 2021-03-18 19:16:44 +00:00 by lpla · 4 comments
lpla commented 2021-03-18 19:16:44 +00:00 (Migrated from github.com)

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 76 and it didn't work until I edited line 14 replacing bus = smbus.SMBus(1) with bus = 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
Captura de Pantalla 2021-03-18 a les 20 17 15

Captura de Pantalla 2021-03-18 a les 20 14 15

Captura de Pantalla 2021-03-18 a les 20 15 21

**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 76` and it didn't work until I edited line 14 replacing `bus = smbus.SMBus(1)` with `bus = 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** ![Captura de Pantalla 2021-03-18 a les 20 17 15](https://user-images.githubusercontent.com/1533393/111684373-f0803180-8826-11eb-8487-1479365d3114.png) ![Captura de Pantalla 2021-03-18 a les 20 14 15](https://user-images.githubusercontent.com/1533393/111684063-85cef600-8826-11eb-97b1-b7726603ca2c.png) ![Captura de Pantalla 2021-03-18 a les 20 15 21](https://user-images.githubusercontent.com/1533393/111684185-ad25c300-8826-11eb-8bb1-03a26ad63622.png)
ddB0515 commented 2021-05-13 18:10:21 +01:00 (Migrated from github.com)

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 smbus
pip3 install smbus2

restarted and worked like charm, try and post result or at least log :)

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 smbus` `pip3 install smbus2` restarted and worked like charm, try and post result or at least log :)
MircoMaker commented 2021-09-12 01:51:49 +01:00 (Migrated from github.com)

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.

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.
EFXPROMedia commented 2023-08-21 10:35:00 +01:00 (Migrated from github.com)

I am having the same issue, my sensor is on 0x76 I 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 below

pi@octopi:~ $ python bme280.py
Chip ID     : 88
Version     : 1
Temperature :  19.04 C
Pressure :  1009.35522279 hPa
Humidity :  0.0 %
I am having the same issue, my sensor is on `0x76` I 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 below ```bash pi@octopi:~ $ python bme280.py Chip ID : 88 Version : 1 Temperature : 19.04 C Pressure : 1009.35522279 hPa Humidity : 0.0 % ```
morphias2004 commented 2025-02-17 01:46:43 +00:00 (Migrated from github.com)

Thank-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-smbus fails.

The i2C bus field value in the settings is ignored.

Image

The combo of installing smbus and smbus2, editing the BME280.py file and turning off Use SUDO fixed it.

Thank-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-smbus` fails. The i2C bus field value in the settings is ignored. ![Image](https://github.com/user-attachments/assets/4031788a-ff51-4254-a00c-8e2f68a28586) The combo of installing smbus and smbus2, editing the BME280.py file and turning off Use SUDO fixed it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#414