How khoaphunsonac/assignment_iot_hk261 works
This is an IoT classroom monitoring and environmental-control system. The main path is Node A sensing and classifying conditions, ESP-NOW delivery to Node B, Node B control and MQTT telemetry, then the Python gateway’s CoreIOT and local-UI integrations. Separate capabilities include gateway-side AI/OTA, Node B web/LCD interfaces, and TinyML data collection and training. The README documents system-level links; source excerpts and index references support selected firmware links. Unsampled gateway and webserver implementation details are represented only at subsystem level.
Main entry points: bridge.py CoreIOT bridge and OTA · main.cpp Sampling tasks · net.cpp Wi-Fi and MQTT · node_b_logic.cpp Telemetry and control logic
Components 22
Node A sensing
- Sampling tasks
App/IOT/firmware/node_a/src/main.cpp - Sensor acquisition
App/IOT/firmware/node_a/src/sensors.cpp - Presence and TX logic
App/IOT/firmware/node_a/lib/node_a_logic/node_a_logic.cpp - TinyML inference
App/IOT/ai/models/tinyml_model.h - ESP-NOW pairing and TX
App/IOT/firmware/node_a/src/espnow_link.cpp
Node B control
- ESP-NOW receive
App/IOT/firmware/node_b/src/espnow_rx.cpp - Telemetry and control logic
App/IOT/firmware/node_b/lib/node_b_logic/node_b_logic.cpp - Threshold storage
App/IOT/firmware/node_b/src/config_store.cpp - Fan and light control
App/IOT/firmware/node_b/src/control.cpp - Wi-Fi and MQTT
App/IOT/firmware/node_b/src/net.cpp - Node B web interface
App/IOT/firmware/node_b/src/web.cpp - LCD display
App/IOT/firmware/node_b/src/lcd.cpp - Device OTA updater
App/IOT/firmware/node_b/src/ota.cpp
Gateway services
- CoreIOT bridge and OTA
App/IOT/gateway/bridge.py - Local gateway UI
App/IOT/gateway/ui/app.py - Gateway event AI
App/IOT/gateway
AI workflow
- CSV capture tools
App/IOT/ai/tools - TinyML training and export
App/IOT/ai/train/train_tinyml.py
CoreIOT platform
- CoreIOT dashboard and rules
App/IOT/coreiot
Other components
- Room sensors
- ESP-NOW packet types
App/IOT/firmware/common/espnow_packet.h - Mosquitto broker
Connections 28
- Room sensors → Sensor acquisition: provides readings
- Sensor acquisition → Sampling tasks: returns samples
App/IOT/firmware/node_a/src/main.cpp - Sampling tasks → Presence and TX logic: checks samples
App/IOT/firmware/node_a/src/main.cpp - Sampling tasks → ESP-NOW pairing and TX: pairs and sends
App/IOT/firmware/node_a/src/main.cpp - Sampling tasks → TinyML inference: runs inference
- Sampling tasks → ESP-NOW packet types: packs data
App/IOT/firmware/node_a/src/main.cpp - ESP-NOW pairing and TX → ESP-NOW packet types: uses packet types
- ESP-NOW pairing and TX → ESP-NOW receive: sends ESP-NOW
- ESP-NOW receive → ESP-NOW packet types: validates packets
- ESP-NOW receive → Telemetry and control logic: processes readings
- Telemetry and control logic → Fan and light control: determines outputs
- Threshold storage → Telemetry and control logic: supplies thresholds
- Wi-Fi and MQTT → Telemetry and control logic: uses logic
App/IOT/firmware/node_b/src/net.cpp - Wi-Fi and MQTT → Mosquitto broker: publishes telemetry
- Mosquitto broker → CoreIOT bridge and OTA: forwards MQTT
- Wi-Fi and MQTT → Device OTA updater: delivers OTA commands
- Device OTA updater → Wi-Fi and MQTT: queues status
App/IOT/firmware/node_b/src/ota.cpp - CoreIOT bridge and OTA → CoreIOT dashboard and rules: sends telemetry
- CoreIOT dashboard and rules → CoreIOT bridge and OTA: returns rules and commands
- CoreIOT bridge and OTA → Local gateway UI: shares gateway data
- CoreIOT bridge and OTA → Gateway event AI: runs event detection
- CoreIOT bridge and OTA → Device OTA updater: distributes firmware
- Node B web interface → Fan and light control: exposes controls
- Fan and light control → LCD display: provides status
- Mosquitto broker → CSV capture tools: captures telemetry
App/IOT/ai/tools/mqtt_to_csv.py - Room sensors → CSV capture tools: serial capture
- CSV capture tools → TinyML training and export: provides CSV data
- TinyML training and export → TinyML inference: exports model