From 8dce708fef68008cd245ad3fc61df80451b3bfa0 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 3 Sep 2018 11:13:32 +0100 Subject: [PATCH] Check for both i2c addresses in examples --- examples/indoor-air-quality.py | 5 ++++- examples/read-all.py | 5 ++++- examples/temp-offset.py | 5 ++++- examples/temp-press-hum.py | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/indoor-air-quality.py b/examples/indoor-air-quality.py index 760cce9..0a60643 100755 --- a/examples/indoor-air-quality.py +++ b/examples/indoor-air-quality.py @@ -12,7 +12,10 @@ Press Ctrl+C to exit """) -sensor = bme680.BME680() +try: + sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY) +except IOError: + sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY) # These oversampling settings can be tweaked to # change the balance between accuracy and noise in diff --git a/examples/read-all.py b/examples/read-all.py index fe24da1..1c23ed0 100755 --- a/examples/read-all.py +++ b/examples/read-all.py @@ -8,7 +8,10 @@ Press Ctrl+C to exit """) -sensor = bme680.BME680() +try: + sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY) +except IOError: + sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY) # These calibration data can safely be commented # out, if desired. diff --git a/examples/temp-offset.py b/examples/temp-offset.py index fba26c7..2ccd73d 100755 --- a/examples/temp-offset.py +++ b/examples/temp-offset.py @@ -4,7 +4,10 @@ import bme680 print("""Display Temperature, Pressure and Humidity with different offsets. """) -sensor = bme680.BME680() +try: + sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY) +except IOError: + sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY) # These oversampling settings can be tweaked to # change the balance between accuracy and noise in diff --git a/examples/temp-press-hum.py b/examples/temp-press-hum.py index af32ad8..8a2702d 100755 --- a/examples/temp-press-hum.py +++ b/examples/temp-press-hum.py @@ -10,7 +10,10 @@ Press Ctrl+C to exit """) -sensor = bme680.BME680() +try: + sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY) +except IOError: + sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY) # These oversampling settings can be tweaked to # change the balance between accuracy and noise in