|
@@ -6,12 +6,15 @@ import sqlite3
|
|
|
from dotenv import load_dotenv
|
|
from dotenv import load_dotenv
|
|
|
import os
|
|
import os
|
|
|
|
|
|
|
|
-from smbus2 import SMBus
|
|
|
|
|
-from bme280 import BME280
|
|
|
|
|
|
|
+import smbus2
|
|
|
|
|
+import bme280
|
|
|
|
|
|
|
|
# Initialise the BME280
|
|
# Initialise the BME280
|
|
|
-bus = SMBus(1)
|
|
|
|
|
-bme280 = BME280(i2c_dev=bus)
|
|
|
|
|
|
|
+port = 1
|
|
|
|
|
+address = 0x76
|
|
|
|
|
+bus = smbus2.SMBus(port)
|
|
|
|
|
+
|
|
|
|
|
+calibration_params = bme280.load_calibration_params(bus, address)
|
|
|
|
|
|
|
|
load_dotenv()
|
|
load_dotenv()
|
|
|
|
|
|
|
@@ -74,15 +77,12 @@ async def sensor_task():
|
|
|
global indoorValues
|
|
global indoorValues
|
|
|
|
|
|
|
|
while True:
|
|
while True:
|
|
|
- temperature, pressure, humidity = bme280.read_compensated_data()
|
|
|
|
|
- altitude = bme280.altitude
|
|
|
|
|
-
|
|
|
|
|
- #print(_encode_value(pressure/100))
|
|
|
|
|
|
|
+ data = bme280.sample(bus, address, calibration_params)
|
|
|
|
|
|
|
|
- indoorValues["Temperature"] = temperature * 100
|
|
|
|
|
- indoorValues["Pressure"] = pressure * 100
|
|
|
|
|
- indoorValues["Humidity"] = humidity * 100
|
|
|
|
|
- indoorValues["Altitude"] = altitude * 100
|
|
|
|
|
|
|
+ indoorValues["Temperature"] = data.temperature * 100
|
|
|
|
|
+ indoorValues["Pressure"] = data.pressure * 100
|
|
|
|
|
+ indoorValues["Humidity"] = data.humidity * 100
|
|
|
|
|
+ indoorValues["Altitude"] = 0 # * 100
|
|
|
|
|
|
|
|
await asyncio.sleep(1)
|
|
await asyncio.sleep(1)
|
|
|
|
|
|