diff options
Diffstat (limited to 'dev_scripts/bme280_sensor.py')
-rw-r--r-- | dev_scripts/bme280_sensor.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dev_scripts/bme280_sensor.py b/dev_scripts/bme280_sensor.py new file mode 100644 index 0000000..c117a40 --- /dev/null +++ b/dev_scripts/bme280_sensor.py @@ -0,0 +1,26 @@ +import bme280 +from smbus import SMBus +import time +port = 1 +address = 0x76 # BME280 address +bus = SMBus(port) +bme280.load_calibration_params(bus,address) +altitude = 97 + + +def bme280Read(): + bme280_data = bme280.sample(bus,address) + humidity = bme280_data.humidity + relPressure = bme280_data.pressure + ambient_temperature = bme280_data.temperature + absPressure = relPressure + (altitude/8.3) + #print(humidity, pressure, ambient_temperature) + # TODO calculate air pressure at sea level + return bme280_data.humidity, bme280_data.pressure, bme280_data.temperature, absPressure + +# test loop +""" +while True: + bme280Read() + time.sleep(1) +""" |