|
@@ -18,7 +18,6 @@ oled = ssd1306.SSD1306_I2C(128, 64, i2c)
|
|
|
temperature = 0
|
|
temperature = 0
|
|
|
pressure = 0
|
|
pressure = 0
|
|
|
humidity = 0
|
|
humidity = 0
|
|
|
-altitude = 0
|
|
|
|
|
|
|
|
|
|
#org.bluetooth.service.environmental_sensing
|
|
#org.bluetooth.service.environmental_sensing
|
|
|
_ENV_SENSE_UUID = bluetooth.UUID(0x181A)
|
|
_ENV_SENSE_UUID = bluetooth.UUID(0x181A)
|
|
@@ -28,8 +27,6 @@ _ENV_SENSE_TEMP_UUID = bluetooth.UUID(0x2A6E)
|
|
|
_ENV_SENSE_PRESSURE_UUID = bluetooth.UUID(0x2A6D)
|
|
_ENV_SENSE_PRESSURE_UUID = bluetooth.UUID(0x2A6D)
|
|
|
# org.bluetooth.characteristic.humidity
|
|
# org.bluetooth.characteristic.humidity
|
|
|
_ENV_SENSE_HUMIDITY_UUID = bluetooth.UUID(0x2A6F)
|
|
_ENV_SENSE_HUMIDITY_UUID = bluetooth.UUID(0x2A6F)
|
|
|
-# org.bluetooth.characteristic.altitude
|
|
|
|
|
-_ENV_SENSE_ALTITUDE_UUID = bluetooth.UUID(0x2AB3)
|
|
|
|
|
# org.bluetooth.characteristic.gap.appearance.xml
|
|
# org.bluetooth.characteristic.gap.appearance.xml
|
|
|
_ADV_APPEARANCE_GENERIC_THERMOMETER = const(768)
|
|
_ADV_APPEARANCE_GENERIC_THERMOMETER = const(768)
|
|
|
# How frequently to send advertising beacons.
|
|
# How frequently to send advertising beacons.
|
|
@@ -47,9 +44,6 @@ envsense_service, _ENV_SENSE_PRESSURE_UUID, read=True, notify=True)
|
|
|
humidity_characteristic = aioble.Characteristic(
|
|
humidity_characteristic = aioble.Characteristic(
|
|
|
envsense_service, _ENV_SENSE_HUMIDITY_UUID, read=True, notify=True)
|
|
envsense_service, _ENV_SENSE_HUMIDITY_UUID, read=True, notify=True)
|
|
|
|
|
|
|
|
-altitude_characteristic = aioble.Characteristic(
|
|
|
|
|
-envsense_service, _ENV_SENSE_ALTITUDE_UUID, read=True, notify=True)
|
|
|
|
|
-
|
|
|
|
|
aioble.register_services(envsense_service)
|
|
aioble.register_services(envsense_service)
|
|
|
|
|
|
|
|
# Helper to encode the characteristic encoding
|
|
# Helper to encode the characteristic encoding
|
|
@@ -60,23 +54,21 @@ def _encode_value(value):
|
|
|
|
|
|
|
|
# Get temperature and update characteristic
|
|
# Get temperature and update characteristic
|
|
|
async def sensor_task():
|
|
async def sensor_task():
|
|
|
- global temperature, pressure, humidity, altitude
|
|
|
|
|
|
|
+ global temperature, pressure, humidity
|
|
|
|
|
|
|
|
while True:
|
|
while True:
|
|
|
temperature, pressure, humidity = bme.read_compensated_data()
|
|
temperature, pressure, humidity = bme.read_compensated_data()
|
|
|
- altitude = bme.altitude
|
|
|
|
|
|
|
|
|
|
#print(_encode_value(pressure/100))
|
|
#print(_encode_value(pressure/100))
|
|
|
|
|
|
|
|
temp_characteristic.write(_encode_value(temperature), send_update=True)
|
|
temp_characteristic.write(_encode_value(temperature), send_update=True)
|
|
|
pressure_characteristic.write(_encode_value(pressure/100), send_update=True)
|
|
pressure_characteristic.write(_encode_value(pressure/100), send_update=True)
|
|
|
humidity_characteristic.write(_encode_value(humidity), send_update=True)
|
|
humidity_characteristic.write(_encode_value(humidity), send_update=True)
|
|
|
- altitude_characteristic.write(_encode_value(altitude), send_update=True)
|
|
|
|
|
|
|
|
|
|
await asyncio.sleep_ms(1000)
|
|
await asyncio.sleep_ms(1000)
|
|
|
|
|
|
|
|
async def display_task():
|
|
async def display_task():
|
|
|
- global temperature, pressure, humidity, altitude
|
|
|
|
|
|
|
+ global temperature, pressure, humidity
|
|
|
|
|
|
|
|
while True:
|
|
while True:
|
|
|
oled.fill(0)
|
|
oled.fill(0)
|
|
@@ -84,7 +76,6 @@ async def display_task():
|
|
|
oled.text("{:.2f} C".format(temperature), 0, 0)
|
|
oled.text("{:.2f} C".format(temperature), 0, 0)
|
|
|
oled.text("{:.2f} hPa".format(pressure/100), 0, 10)
|
|
oled.text("{:.2f} hPa".format(pressure/100), 0, 10)
|
|
|
oled.text("{:.2f}%".format(humidity), 0, 20)
|
|
oled.text("{:.2f}%".format(humidity), 0, 20)
|
|
|
- oled.text("{:.2f} m".format(altitude), 0, 30)
|
|
|
|
|
|
|
|
|
|
oled.show()
|
|
oled.show()
|
|
|
await asyncio.sleep_ms(1000)
|
|
await asyncio.sleep_ms(1000)
|