Skip to content

Commit 8dce708

Browse files
committed
Check for both i2c addresses in examples
1 parent df382a5 commit 8dce708

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

examples/indoor-air-quality.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
1313
""")
1414

15-
sensor = bme680.BME680()
15+
try:
16+
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
17+
except IOError:
18+
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
1619

1720
# These oversampling settings can be tweaked to
1821
# change the balance between accuracy and noise in

examples/read-all.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
99
""")
1010

11-
sensor = bme680.BME680()
11+
try:
12+
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
13+
except IOError:
14+
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
1215

1316
# These calibration data can safely be commented
1417
# out, if desired.

examples/temp-offset.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
print("""Display Temperature, Pressure and Humidity with different offsets.
55
""")
66

7-
sensor = bme680.BME680()
7+
try:
8+
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
9+
except IOError:
10+
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
811

912
# These oversampling settings can be tweaked to
1013
# change the balance between accuracy and noise in

examples/temp-press-hum.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
1111
""")
1212

13-
sensor = bme680.BME680()
13+
try:
14+
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
15+
except IOError:
16+
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
1417

1518
# These oversampling settings can be tweaked to
1619
# change the balance between accuracy and noise in

0 commit comments

Comments
 (0)