|
5 | 5 |
|
6 | 6 | sensor = bme680.BME680() |
7 | 7 |
|
| 8 | +# These calibration data can safely be commented |
| 9 | +# out, if desired. |
| 10 | + |
8 | 11 | print("Calibration data:") |
9 | 12 | for name in dir(sensor.calibration_data): |
| 13 | + |
10 | 14 | if not name.startswith('_'): |
11 | 15 | value = getattr(sensor.calibration_data, name) |
| 16 | + |
12 | 17 | if isinstance(value, int): |
13 | 18 | print("{}: {}".format(name, value)) |
14 | 19 |
|
| 20 | +# These oversampling settings can be tweaked to |
| 21 | +# change the balance between accuracy and noise in |
| 22 | +# the data. |
15 | 23 |
|
16 | 24 | sensor.set_humidity_oversample(bme680.OS_2X) |
17 | 25 | sensor.set_pressure_oversample(bme680.OS_4X) |
|
22 | 30 | print("\n\nInitial reading:") |
23 | 31 | for name in dir(sensor.data): |
24 | 32 | value = getattr(sensor.data, name) |
| 33 | + |
25 | 34 | if not name.startswith('_'): |
26 | 35 | print("{}: {}".format(name, value)) |
27 | 36 |
|
|
38 | 47 | try: |
39 | 48 | while True: |
40 | 49 | 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) |
43 | 51 |
|
44 | 52 | 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 | + |
46 | 55 | else: |
47 | 56 | print(output) |
48 | 57 |
|
49 | 58 | time.sleep(1) |
50 | 59 |
|
51 | 60 | except KeyboardInterrupt: |
52 | 61 | pass |
53 | | - |
|
0 commit comments