summaryrefslogtreecommitdiff
path: root/dev_scripts/bme280_sensor.py
diff options
context:
space:
mode:
authorars <asav1410@gmail.com>2020-06-17 15:59:52 +0100
committerars <asav1410@gmail.com>2020-06-17 15:59:52 +0100
commitf665f78155047838dc924634ebe4128f7add5542 (patch)
treefa0b6d2fd4a7b26d7fac2d557066044384d33010 /dev_scripts/bme280_sensor.py
Initial commitHEADmaster
Diffstat (limited to 'dev_scripts/bme280_sensor.py')
-rw-r--r--dev_scripts/bme280_sensor.py26
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)
+"""