How aneazi/weatherpi works
Project type and purpose
• This is a small, two‐component full-stack IoT application (“WeatherPI”) designed for a Raspberry Pi.
• “pi-publisher” reads local sensors and publishes measurements.
• “weather-dashboard” subscribes to those measurements and provides a web dashboard.
File structure
Top‐level:
• config.yaml – global configuration (e.g., broker URL, topics)
• pi-publisher/ – Dockerized Python publisher
– Dockerfile, requirements.txt
– src/publisher.py, src/sensors.py, src/utils.py
• weather-dashboard/ – Python web subscriber + UI
– src/server.py (HTTP server), src/subscriber.py, src/utils.py
– static/ (CSS, JS for charting)
– templates/index.html
README insights
• Shows how to build/run the publisher container on a Pi.
• Implies use of a message broker (likely MQTT).
• No explicit mention of broker; assumed external.
Main components
a. Hardware & OS layer
• Raspberry Pi + physical sensors
b. Publisher component (Container)
• sensors.py: reads from GPIO/hardware
• publisher.py: publishes to broker (e.g., MQTT)
• utils.py: common helpers
c. Message broker (external service)
• MQTT Broker (could be local or cloud)
d. Subscriber component (Web server)
• subscriber.py: subscribes to broker topics, stores or buffers data
• server.py: runs a web server (Flask/HTTP) to serve HTML/JS
• utils.py: common code (e.g., config parsing)
e. Frontend (Browser)
• templates/index.html
• static/js/chart-setup.js (Chart.js or similar)
• static/css/styles.css
Relationships and interactions
1. sensors.py → publisher.py: raw readings passed to publisher
2. publisher.py → MQTT Broker: publishes messages on a topic (e.g., “weather/data”)
3. MQTT Broker → subscriber.py: subscriber receives live data
4. subscriber.py → server.py: passes or caches data for HTTP endpoints (e.g., /data)
5. server.py → Browser: serves index.html and exposes REST or WebSocket for live updates
6. Browser (chart-setup.js) → subscribes over HTTP/WebSocket to render charts
Architectural patterns and design principles
• Containerization (Docker) isolates the publisher on the Pi.
• Pub/Sub messaging decouples publisher and dashboard.
• Separation of concerns: sensor I/O vs. data transport vs. presentation.
• Single‐page dashboard client with static assets and dynamic charting.