mirror of
https://github.com/cmur2/python-bme680.git
synced 2024-11-14 08:56:20 +01:00
32 lines
706 B
Python
Executable File
32 lines
706 B
Python
Executable File
#!/usr/bin/env python
|
|
import bme680
|
|
import time
|
|
|
|
print("""Display Temperature, Pressure and Humidity
|
|
|
|
If you don't need gas readings, then you can read temperature,
|
|
pressure and humidity quickly.
|
|
|
|
Press Ctrl+C to exit
|
|
|
|
""")
|
|
|
|
sensor = bme680.BME680()
|
|
|
|
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)
|
|
|
|
print("Polling:")
|
|
try:
|
|
while True:
|
|
if sensor.get_sensor_data():
|
|
|
|
output = "{0:.2f} degC {1:.2f} hPa {2:.3f} %rH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
|
|
print(output)
|
|
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|