How freightcognition/temp_monitor works
Main components
a. Hardware Layer
• Raspberry Pi Zero 2 W (system host)
• Sense HAT (environmental sensor + LED matrix)
b. Software Layer (all in temp_monitor.py)
• Data Acquisition Module (reads raw temperature & humidity via Sense HAT API)
• Temperature Compensation Logic (applies compensation formula using CPU temp)
• Logging Module (writes timestamped readings to a local log file)
• LED Display Module (renders current temperature on Sense HAT LEDs)
• Web Server & API Module (Flask app serves dashboard & JSON endpoints)
• Asset Store (static assets directory for logos, CSS if expanded)
• OpenAPI Specification (openapi.yaml describing JSON endpoints)
c. System Integration
• Systemd Service (manages automatic start/restart of the Python service)
d. External Clients
• Web Browser (dashboard UI consuming HTML + JSON)
• Third‑party Monitoring Tools (poll /api/temp or /api/raw)
Relationships & data flows
• Sensor → Acquisition Module: raw readings (temperature, humidity)
• Acquisition → Compensation Logic: raw + CPU temp → compensated temp
• Compensation →
• Logging Module → Log File
• LED Display Module → Sense HAT LEDs
• Web/API Module → in-memory state for endpoints
• Web/API Module →
• Dashboard HTML (auto‑refresh JS pulling /api/temp)
• JSON endpoints (/api/temp, /api/raw)
• Browser/Tools → HTTP calls to Flask server on port 8080
• Systemd → Python process lifecycle management
Architectural patterns & tech
• Monolithic single‑process service (no microservices)
• Modular logical separation within one Python script
• RESTful API layer (Flask + OpenAPI)
• Hardware abstraction via Sense HAT Python library
• Persistent logging to flat file (no DB)
• Systemd integration for process control
Detail without overthinking
• Every logical component even if implemented in one file
• Runtime interactions (sensor reads, HTTP requests, file writes, LED updates)