2018-05-28 23:18:20 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import bme680
|
|
|
|
|
|
|
|
print("""Display Temperature, Pressure and Humidity with different offsets.
|
|
|
|
""")
|
|
|
|
|
2018-09-03 12:13:32 +02:00
|
|
|
try:
|
|
|
|
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
|
|
|
|
except IOError:
|
|
|
|
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
|
2018-05-28 23:18:20 +02:00
|
|
|
|
|
|
|
# These oversampling settings can be tweaked to
|
|
|
|
# change the balance between accuracy and noise in
|
|
|
|
# the data.
|
|
|
|
|
|
|
|
sensor.set_humidity_oversample(bme680.OS_2X)
|
|
|
|
sensor.set_pressure_oversample(bme680.OS_4X)
|
|
|
|
sensor.set_temperature_oversample(bme680.OS_8X)
|
|
|
|
sensor.set_filter(bme680.FILTER_SIZE_3)
|
|
|
|
|
2018-09-02 12:26:04 +02:00
|
|
|
|
2018-06-01 17:10:34 +02:00
|
|
|
def display_data(offset=0):
|
|
|
|
sensor.set_temp_offset(offset)
|
|
|
|
sensor.get_sensor_data()
|
2018-09-02 12:26:04 +02:00
|
|
|
output = '{0:.2f} C, {1:.2f} hPa, {2:.3f} %RH'.format(
|
|
|
|
sensor.data.temperature,
|
2018-12-07 11:26:50 +01:00
|
|
|
sensor.data.pressure / 100.0,
|
2018-09-02 12:26:04 +02:00
|
|
|
sensor.data.humidity)
|
2018-06-01 17:10:34 +02:00
|
|
|
print(output)
|
2018-09-02 12:26:04 +02:00
|
|
|
print('')
|
|
|
|
|
2018-06-01 17:10:34 +02:00
|
|
|
|
2018-09-02 12:26:04 +02:00
|
|
|
print('Initial readings')
|
2018-06-01 17:10:34 +02:00
|
|
|
display_data()
|
2018-05-28 23:18:20 +02:00
|
|
|
|
2018-09-02 12:26:04 +02:00
|
|
|
print('SET offset 4 degrees celsius')
|
2018-06-01 17:10:34 +02:00
|
|
|
display_data(4)
|
2018-05-28 23:18:20 +02:00
|
|
|
|
2018-09-02 12:26:04 +02:00
|
|
|
print('SET offset -1.87 degrees celsius')
|
2018-06-01 17:10:34 +02:00
|
|
|
display_data(-1.87)
|
2018-05-28 23:18:20 +02:00
|
|
|
|
2018-09-02 12:26:04 +02:00
|
|
|
print('SET offset -100 degrees celsius')
|
2018-06-01 17:10:34 +02:00
|
|
|
display_data(-100)
|
2018-05-28 23:18:20 +02:00
|
|
|
|
2018-09-02 12:26:04 +02:00
|
|
|
print('SET offset 0 degrees celsius')
|
2018-06-01 17:10:34 +02:00
|
|
|
display_data(0)
|