You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
542 B
25 lines
542 B
#!/usr/bin/env python
|
|
|
|
import time
|
|
try:
|
|
from smbus2 import SMBus
|
|
except ImportError:
|
|
from smbus import SMBus
|
|
from bme280 import BME280
|
|
|
|
print("""all-values.py - Read temperature, pressure, and humidity
|
|
|
|
Press Ctrl+C to exit!
|
|
|
|
""")
|
|
|
|
# Initialise the BME280
|
|
bus = SMBus(1)
|
|
bme280 = BME280(i2c_dev=bus)
|
|
|
|
while True:
|
|
temperature = bme280.get_temperature()
|
|
pressure = bme280.get_pressure()
|
|
humidity = bme280.get_humidity()
|
|
print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
|
|
time.sleep(1)
|
|
|