Skip to content

Commit bcf3704

Browse files
Tidied up examples a little.
1 parent 9922274 commit bcf3704

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55

66
sensor = bme680.BME680()
77

8+
# These calibration data can safely be commented
9+
# out, if desired.
10+
811
print("Calibration data:")
912
for name in dir(sensor.calibration_data):
13+
1014
if not name.startswith('_'):
1115
value = getattr(sensor.calibration_data, name)
16+
1217
if isinstance(value, int):
1318
print("{}: {}".format(name, value))
1419

20+
# These oversampling settings can be tweaked to
21+
# change the balance between accuracy and noise in
22+
# the data.
1523

1624
sensor.set_humidity_oversample(bme680.OS_2X)
1725
sensor.set_pressure_oversample(bme680.OS_4X)
@@ -22,6 +30,7 @@
2230
print("\n\nInitial reading:")
2331
for name in dir(sensor.data):
2432
value = getattr(sensor.data, name)
33+
2534
if not name.startswith('_'):
2635
print("{}: {}".format(name, value))
2736

@@ -38,16 +47,15 @@
3847
try:
3948
while True:
4049
if sensor.get_sensor_data():
41-
42-
output = "{0:.2f} degC {1:.2f} hPa {2:.3f} %rH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
50+
output = "{0:.2f} C,{1:.2f} hPa,{2:.2f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
4351

4452
if sensor.data.heat_stable:
45-
print("{0} {1} ohms".format(output, sensor.data.gas_resistance))
53+
print("{0},{1} Ohms".format(output, sensor.data.gas_resistance))
54+
4655
else:
4756
print(output)
4857

4958
time.sleep(1)
5059

5160
except KeyboardInterrupt:
5261
pass
53-
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
sensor = bme680.BME680()
1515

16+
# These oversampling settings can be tweaked to
17+
# change the balance between accuracy and noise in
18+
# the data.
19+
1620
sensor.set_humidity_oversample(bme680.OS_2X)
1721
sensor.set_pressure_oversample(bme680.OS_4X)
1822
sensor.set_temperature_oversample(bme680.OS_8X)
@@ -23,7 +27,8 @@
2327
while True:
2428
if sensor.get_sensor_data():
2529

26-
output = "{0:.2f} degC {1:.2f} hPa {2:.3f} %rH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
30+
output = "{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
31+
2732
print(output)
2833

2934
except KeyboardInterrupt:

0 commit comments

Comments
 (0)