How quecpython/solution-sensorhub works
Project type and purpose
• This is an IoT “sensor-hub” firmware project written in QuecPython, targeting the Quectel EC200U LTE module.
• Its purpose is to read data from multiple onboard and external sensors, detect significant changes, and upload updates over the cellular network to a cloud backend (which in turn feeds a mobile/web app).
File structure
• Top-level “code” folder holds everything that lives on the module’s filesystem:
• Qth/ – Quectel platform modules (bus, file, OTA, protocol, config, DMP)
• drivers/ – Python drivers for IC sensors (ICM20948, LPS22HB, SHTC3, TCS34725)
• libs/ – utility libraries (I2C abstraction, logging, threading, pub-sub)
• extensions/ – high-level services: sensor_service, gnss_service, lbs_service, qth_client
• _main.py – entry point orchestrating initialization, sensor polling, change detection, and upload
• config.json / config2.json – runtime parameters and thresholds
• Outside code/ you have documentation, hardware schematics, and PC-side tools for flashing and log retrieval.
README for additional insights
• Describes hardware setup (EC200U dev-board + sensors + SIM card)
• Instructs on flashing firmware via QPYcom, transferring “code/” directory to module
• Explains runtime behavior: dial-up, periodic sensor prints, change detection >1 unit (or 150 RGB units) triggers upload, GNSS/LBS location updates when moved >50 m
Main components and their relationships
a. Hardware layer
• EC200U module (LTE modem + Python interpreter)
• SIM card + LTE antenna
b. Firmware layers on the module
1) Core/Platform (Qth)
• qth_bus: event/message bus
• qth_file: file I/O
• qth_ota: firmware update
• qth_protocal: network protocol abstractions
2) Drivers (one per sensor)
• Wrap I2C transactions & raw data parsing
3) Libs/utilities
• I2C wrapper, logging, threading, pub-sub event hub, common helpers
4) Extensions/services
• sensor_service: periodically polls drivers, publishes sensor readings
• gnss_service & lbs_service: location services from module’s GNSS/LBS APIs
• qth_client: network client that dials up, sends JSON payloads to cloud
5) Application (_main.py)
• Loads config, subscribes to sensor events, applies threshold logic, triggers qth_client uploads
c. Network & cloud
• EC200U LTE link over 4G network → remote API endpoint
• Cloud backend stores data, responds to “read” requests from mobile/web app
d. Mobile/Web App
• Uses cloud API to fetch latest sensor & location data; UI refreshable on demand
Important architectural patterns & design principles
• Layered separation: drivers ← libs ← services ← application
• Pub-sub event bus for decoupling sensors from upload logic
• Config-driven thresholds & endpoints
• Threading model: each service may run in its own thread, orchestrated via libs/threading.py