|
@@ -25,20 +25,17 @@ outdoorConnected = 0
|
|
|
TEMP_UUID = "2A6E"
|
|
TEMP_UUID = "2A6E"
|
|
|
PRESSURE_UUID = "2A6D"
|
|
PRESSURE_UUID = "2A6D"
|
|
|
HUMIDITY_UUID = "2A6F"
|
|
HUMIDITY_UUID = "2A6F"
|
|
|
-ALTITUDE_UUID = "2AB3"
|
|
|
|
|
|
|
|
|
|
indoorValues = {
|
|
indoorValues = {
|
|
|
"Temperature": 0,
|
|
"Temperature": 0,
|
|
|
"Pressure": 0,
|
|
"Pressure": 0,
|
|
|
"Humidity": 0,
|
|
"Humidity": 0,
|
|
|
- "Altitude": 0,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
outdoorValues = {
|
|
outdoorValues = {
|
|
|
"Temperature": 0,
|
|
"Temperature": 0,
|
|
|
"Pressure": 0,
|
|
"Pressure": 0,
|
|
|
"Humidity": 0,
|
|
"Humidity": 0,
|
|
|
- "Altitude": 0,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytearray):
|
|
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytearray):
|
|
@@ -66,7 +63,6 @@ async def ble_task():
|
|
|
await client.start_notify(TEMP_UUID, notification_handler)
|
|
await client.start_notify(TEMP_UUID, notification_handler)
|
|
|
await client.start_notify(PRESSURE_UUID, notification_handler)
|
|
await client.start_notify(PRESSURE_UUID, notification_handler)
|
|
|
await client.start_notify(HUMIDITY_UUID, notification_handler)
|
|
await client.start_notify(HUMIDITY_UUID, notification_handler)
|
|
|
- await client.start_notify(ALTITUDE_UUID, notification_handler)
|
|
|
|
|
|
|
|
|
|
while (client.is_connected):
|
|
while (client.is_connected):
|
|
|
await asyncio.sleep(1)
|
|
await asyncio.sleep(1)
|
|
@@ -83,7 +79,6 @@ async def sensor_task():
|
|
|
indoorValues["Temperature"] = round(data.temperature * 100)
|
|
indoorValues["Temperature"] = round(data.temperature * 100)
|
|
|
indoorValues["Pressure"] = round(data.pressure * 100)
|
|
indoorValues["Pressure"] = round(data.pressure * 100)
|
|
|
indoorValues["Humidity"] = round(data.humidity * 100)
|
|
indoorValues["Humidity"] = round(data.humidity * 100)
|
|
|
- indoorValues["Altitude"] = 0 # * 100
|
|
|
|
|
|
|
|
|
|
await asyncio.sleep(1)
|
|
await asyncio.sleep(1)
|
|
|
|
|
|
|
@@ -97,13 +92,11 @@ cursor.execute(
|
|
|
indoorTemp text not null,
|
|
indoorTemp text not null,
|
|
|
indoorPressure text not null,
|
|
indoorPressure text not null,
|
|
|
indoorHumidity text not null,
|
|
indoorHumidity text not null,
|
|
|
- indoorAltitude text not null,
|
|
|
|
|
|
|
|
|
|
outdoorConnected integer not null,
|
|
outdoorConnected integer not null,
|
|
|
outdoorTemp text not null,
|
|
outdoorTemp text not null,
|
|
|
outdoorPressure text not null,
|
|
outdoorPressure text not null,
|
|
|
- outdoorHumidity text not null,
|
|
|
|
|
- outdoorAltitude text not null
|
|
|
|
|
|
|
+ outdoorHumidity text not null
|
|
|
);"""
|
|
);"""
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -112,20 +105,18 @@ conn.commit()
|
|
|
async def write_task():
|
|
async def write_task():
|
|
|
while True:
|
|
while True:
|
|
|
cursor.execute(f"""INSERT INTO data (
|
|
cursor.execute(f"""INSERT INTO data (
|
|
|
- 'indoorTemp', 'indoorPressure', 'indoorHumidity', 'indoorAltitude', 'outdoorConnected', 'outdoorTemp', 'outdoorPressure', 'outdoorHumidity', 'outdoorAltitude'
|
|
|
|
|
|
|
+ 'indoorTemp', 'indoorPressure', 'indoorHumidity', 'outdoorConnected', 'outdoorTemp', 'outdoorPressure', 'outdoorHumidity'
|
|
|
) VALUES (
|
|
) VALUES (
|
|
|
- ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
|
|
|
|
|
+ ?, ?, ?, ?, ?, ?, ?
|
|
|
)""",
|
|
)""",
|
|
|
(
|
|
(
|
|
|
indoorValues["Temperature"],
|
|
indoorValues["Temperature"],
|
|
|
indoorValues["Pressure"],
|
|
indoorValues["Pressure"],
|
|
|
- indoorValues["Humidity"],
|
|
|
|
|
- indoorValues["Altitude"],
|
|
|
|
|
|
|
+ indoorValues["Humidity"],
|
|
|
outdoorConnected,
|
|
outdoorConnected,
|
|
|
outdoorValues["Temperature"],
|
|
outdoorValues["Temperature"],
|
|
|
outdoorValues["Pressure"],
|
|
outdoorValues["Pressure"],
|
|
|
- outdoorValues["Humidity"],
|
|
|
|
|
- outdoorValues["Altitude"]
|
|
|
|
|
|
|
+ outdoorValues["Humidity"]
|
|
|
))
|
|
))
|
|
|
|
|
|
|
|
conn.commit()
|
|
conn.commit()
|