code.py
1 # SPDX-FileCopyrightText: 2022 Carter Nelson for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import time 6 import board 7 from adafruit_bme280 import basic as adafruit_bme280 8 9 # Get the board's default I2C port 10 i2c = board.I2C() 11 12 #-------------------------------------------------------------------- 13 # NOTE!!! This is the "special" part of the code 14 # 15 # Create each sensor instance 16 # If left out, the default address is used. 17 # But also OK to be explicit and specify address. 18 bme1 = adafruit_bme280.Adafruit_BME280_I2C(i2c, 0x77) # address = 0x77 19 bme2 = adafruit_bme280.Adafruit_BME280_I2C(i2c, 0x76) # address = 0x76 20 #-------------------------------------------------------------------- 21 22 print("Two BME280 Example") 23 24 while True: 25 # Access each sensor via its instance 26 pressure1 = bme1.pressure 27 pressure2 = bme2.pressure 28 29 print("-"*20) 30 print("BME280 #1 Pressure =", pressure1) 31 print("BME280 #2 Pressure =", pressure2) 32 33 time.sleep(1)