Using 2 BME280

How to pass the I2C address to Python code, so I can use 2 x BME280 or 2 x BME680?

I’m pretty sure that’s been asked and answered on the forum, but I’ll be darned if I can find it?
It goes something like
bme2801 = BME280(i2c_dev=bus)
bme2802 = BME280(i2c_dev=alt_add) < not sure on that one?
If you figure it out please post the answer as I may be trying this at some point to get indoor outdoor temps.

In the library the constructor seems to be:

class BME280:
    def __init__(self, i2c_addr=I2C_ADDRESS_GND, i2c_dev=None):

So you should be able to instantiate it as something like:

from bme280 import BME280

sensor = BME280(i2c_addr=0x77)

bme2802 = BME280(i2c_dev=alt_add) < not sure on that one?

In the module they’re described as


Nice hunting @Shoe. I went looking but my coding skills aren’t anything to brag about so I may have seen the answer and not recognized it. =(
I was hoping if I bumped the thread somebody like you would chime in. ;)

Well hunting for stuff like that is how your skills improve! That’s how I learnt this stuff, that and trying to write my own modules for hardware like this.

Yes, it’s time for me to learn Python.


Initialise the BME280

bus = SMBus(1)
bme280_a = BME280(i2c_dev=bus, i2c_addr=I2C_ADDRESS_VCC)
bme280_b = BME280(i2c_dev=bus, i2c_addr=I2C_ADDRESS_GND)

while True:
temperature_a = bme280_a.get_temperature()
pressure_a = bme280_a.get_pressure()
humidity_a = bme280_a.get_humidity()

    temperature_b = bme280_b.get_temperature()
    pressure_b = bme280_b.get_pressure()
    humidity_b = bme280_b.get_humidity()

@Shoe , that’s why I went looking, hoping I could learn a little more. ;)