adafruit / Adafruit_CircuitPython_BME280

CircuitPython driver for the BME280
MIT License
63 stars 42 forks source link

Support for multiple device I2C addresses #29

Closed alexwhittemore closed 4 years ago

alexwhittemore commented 4 years ago

Per the library,

#    I2C ADDRESS/BITS/SETTINGS
#    -----------------------------------------------------------------------
_BME280_ADDRESS = const(0x77)
# ...

As it happens, the BME280 supports address 0x76 OR 0x77 depending on the state of the SDO pin (tied high or low). The circuit I was testing with defaulted to 0x76. For now, I solved my own problem by switching the jumper physically, but I can imagine others might have an address conflict or want two sensors or what have you.

If init-time support for non-default address sounds like a good idea to you, I can put together a PR. How is this kind of situation handled in other CircuitPython libraries?

EDIT: In fact, I guess the circuitpython BMP280 code already does exactly this. I'll put together a PR and test it physically when I get a chance. https://github.com/adafruit/Adafruit_CircuitPython_BMP280/blob/master/adafruit_bmp280.py

alexwhittemore commented 4 years ago

Alas, I was looking at the wrong "init" the whole time, and missed that everything I want is already there. Nevermind me!