vitormhenrique / OctoPrint-Enclosure

OctoPrint Enclosure Plugin
GNU General Public License v3.0
399 stars 203 forks source link

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

Open lpla opened 3 years ago

lpla commented 3 years ago

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

ddB0515 commented 3 years ago

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 3 years ago

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 1 year ago

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 %