bme680-python icon indicating copy to clipboard operation
bme680-python copied to clipboard

SPI instead of I2C?

Open oxboxer opened this issue 6 years ago • 3 comments

I need 3 sensors, but there are unfortunately only 2 I2C addresses. So i have to use SPI instead of I2C. Is there a way to use the same library in SPI?

oxboxer avatar Nov 10 '19 18:11 oxboxer

As much as I hate to say it - since we only provide breakouts that use the i2c interface and this library is strongly i2c focussed - I'm afraid I can't support use over SPI.

You can- however- throw up an additional i2c bus using i2c-gpio (documentation in the overlays readme: https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/overlays/README) on a Raspberry Pi using any two regular GPIO pins and appropriate pull resistors.

Then you can initialise the BME680 library with your new i2c bus like so:

from smbus import SMBus
from bme680 import BME680

bme680 = BME680(i2c_device=SMBus(N))

SPI support is something I would consider reviewing and merging a PR for, however, since I know many people using breakouts not manufactured by us use this library and may want this feature.

Gadgetoid avatar Nov 12 '19 16:11 Gadgetoid

Thanks for the answer. I think i'm gonna buy an i2c multiplexer und use this.

oxboxer avatar Nov 13 '19 10:11 oxboxer

This scenario happened to me too. I ended up using the TCA9548A I2C Multiplexer to get this accomplished. Worked like a charm. If you are quick pintch in a hurry you can use a GPIO to power the sensor (it requires really low current so a gpio pin set to high is enough) and just cycle them from high to low sequentially to get all measurements.

tristanCB avatar Oct 01 '20 02:10 tristanCB