-
Notifications
You must be signed in to change notification settings - Fork 776
/
Copy pathcode.py
executable file
·34 lines (27 loc) · 1.07 KB
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-FileCopyrightText: 2022 Carter Nelson for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
import board
from adafruit_bme280 import basic as adafruit_bme280
# Get the board's default I2C port
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
#--------------------------------------------------------------------
# NOTE!!! This is the "special" part of the code
#
# Create each sensor instance
# If left out, the default address is used.
# But also OK to be explicit and specify address.
bme1 = adafruit_bme280.Adafruit_BME280_I2C(i2c, 0x77) # address = 0x77
bme2 = adafruit_bme280.Adafruit_BME280_I2C(i2c, 0x76) # address = 0x76
#--------------------------------------------------------------------
print("Two BME280 Example")
while True:
# Access each sensor via its instance
pressure1 = bme1.pressure
pressure2 = bme2.pressure
print("-"*20)
print("BME280 #1 Pressure =", pressure1)
print("BME280 #2 Pressure =", pressure2)
time.sleep(1)