Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI instead of I2C? #27

Open
oxboxer opened this issue Nov 10, 2019 · 3 comments
Open

SPI instead of I2C? #27

oxboxer opened this issue Nov 10, 2019 · 3 comments

Comments

@oxboxer
Copy link

oxboxer commented Nov 10, 2019

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?

@Gadgetoid
Copy link
Member

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.

@oxboxer
Copy link
Author

oxboxer commented Nov 13, 2019

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

@tristanCB
Copy link

tristanCB commented Oct 1, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants