PymoTube
A python module for logging data from an AtmoTube via bluetooth. Very much in development.
PymoTube is currently just a set of helper classes for taking bytearrays returned by the AtmoTube and turning it into a basic struct. Over time I plan on adding some additional helpers for using Bleak. In the meantime a minimal example of connecting to an AtmoTube and logging results into an asynchronous queue is shown here
Packets
Status Packet
The StatusPacket class takes a bytearray returned from the Status GATT characteristic and an optional timestamp and creates a data structure with fields corresponding to the different status flags:
from atmotube import StatusPacket
example_status = bytearray(b'Ad')
packet = StatusPacket(example_status)
print(packet)
# StatusPacket(pm_sensor_status=True, error_flag=False, bonding_flag=False, charging=False, charging_timer=False, pre_heating=True, battery_level=100%)SPS30 Packet
The SPS30Packet takes a bytearray returned from the SPS30 GATT characteristic with an optional timestamp and creates a data structure with fields corresponding to the PM measurements in ug/m^3
from atmotube import SPS30Packet
example_sps30 = bytearray(b'd\x00\x00\xb9\x00\x00J\x01\x00o\x00\x00')
packet = SPS30Packet(example_sps30)
print(packet)
# SPS30Packet(pm1=1.0µg/m³, pm2_5=1.85µg/m³, pm10=3.3µg/m³, pm4=1.11µg/m³)BME280 Packet
The BME280Packet takes a bytearray returned from the BME280 GATT characteristic with an optional timestamp and creates a datastructure with fields corresponding the temperature, pressure, and humidity.
from atmotube import BME280Packet
example_bme280 = bytearray(b'\x0e\x17\x8ao\x01\x00\x1a\t')
packet = BME280Packet(example_bme280)
print(packet)
# BME280Packet(humidity=14%, temperature=23.3°C, pressure=940.9mbar)SGPC3 Packet
The SGPC3Packet takes a bytearray returned from the SGPC3 GATT characteristic with an optional timestamp and creates a datastructure with a single field for the VOC.
from atmotube import SGPC3Packet
example_sgpc3 = bytearray(b'\x02\x00\x00\x00')
packet = SGPC3Packet(example_sgpc3)
print(packet)
# SGPC3Packet(tvoc=0.002ppb)