This project n includes a physical automation layer that controls shutters for massive areacnut drying areas using a Raspberry Pi and the trained ML model.
- π€ ML-based rain prediction (6h horizon)
- β±οΈ Automatic shutter closing ~10 minutes before rain
- βοΈ Automatic reopening when safe
- π Uses latest model from GitHub
- ποΈ Manual override via hardware button
- πΎ Persistent state recovery after power loss
| Condition | Action |
|---|---|
| Rain probability β₯ threshold | Close shutters |
| Rain probability < safe margin | Open shutters |
| Manual button press | Override to open |
No external API calls are made from the hardware device.
Hourly rain forecasting project using Visual Crossing weather data and scikit-learn gradient boosting models for multiple prediction horizons.
weather-ml/
βββ .env # Local secrets (not committed)
βββ .env.example # Safe example variables (no secrets)
βββ README.md
βββ requirements.txt
βββ LICENSE
βββ CONTRIBUTING.md
βββ SECURITY.md
βββ config/
β βββ chirps_config.yaml # Non-secret CHIRPS defaults
βββ docs/ # GitHub Pages dashboard
β βββ index.html
βββ data/
β βββ raw/
β β βββ chirps_daily.csv
β βββ processed/
β βββ weather_hourly_clean.csv
β βββ chirps_features_daily.csv
β βββ weather_hourly_clean_enriched.csv
βββ models/
β βββ hgb_*_current.pkl
β βββ hgb_*_previous.pkl
β βββ *_meta.json
β βββ history/
β β βββ metrics_history.csv
β βββ snapshots/
βββ hardware/
β βββ shutter_controller.py
β βββ gpio_config.py
β βββ state.txt
βββ notebooks/
βββ scripts/
β βββ update_data_and_retrain.py
β βββ run_full_training_pipeline.py
β βββ run_chirps_pipeline.py
β βββ fetch_chirps_history.py
β βββ build_chirps_features.py
β βββ enrich_training_data_with_chirps.py
βββ weather/ # Local virtual environment
- Activate your project environment (for example
./Scikitif you are using that venv). - Install dependencies:
pip install -r requirements.txt- Add runtime secrets to
.env(local only, never commit):
VISUAL_CROSSING_KEY=your_key_here
VISUAL_CROSSING_LOCATION=latitude,longitude
LOCATION_LAT=your_latitude
LOCATION_LON=your_longitude
EE_PROJECT=your_gcp_project_id- (Optional but recommended for CHIRPS) authenticate Earth Engine locally once:
earthengine authenticate- Download raw hourly weather data:
python3 scripts/download_visual_crossing.py- Clean and engineer base features (
rain_1h,rain_6h,rain_24h):
python3 scripts/clean_visual_crossing.py- Train multi-horizon HistGradientBoosting models:
python3 scripts/train_boosting_multihorizon.py- Run live inference for the 6-hour horizon:
python3 scripts/predict_live_vc.py- Open notebooks for analysis and interactive inspection:
jupyter notebook notebooks/model_analysis.ipynb
jupyter notebook notebooks/interactive_dashboard.ipynbpython3 scripts/run_full_training_pipeline.pyConfigure these repository secrets:
VISUAL_CROSSING_KEYVISUAL_CROSSING_LOCATIONLOCATION_LATLOCATION_LONEE_PROJECTGOOGLE_CREDENTIALS(full Google service-account JSON)
python3 scripts/run_chirps_pipeline.pyThis executes:
scripts/fetch_chirps_history.pyscripts/build_chirps_features.pyscripts/enrich_training_data_with_chirps.py
- Version
1.0.7adds CHIRPS-aware model metadata support. - CLI output now includes CHIRPS training status and CHIRPS feature count from model metadata.
- The package still reads runtime secrets from environment (
.envlocally or CI secrets) and does not embed credentials.
npm install -g weather-ml-edge
weather-mlπ© For full details for hardware refer Hardware_Setup
- Raspberry Pi (3/4/5)
- Servo motor or relay module
- Manual override button
- 5V power supply
- GPIO wiring
sudo apt update
sudo apt install python3-pigpio pigpio
pip install gpiozero pandas joblib- Enable GPIO daemon:
sudo systemctl enable pigpiod
sudo systemctl start pigpiod
- Run controller:
python hardware/shutter_controller.py
- Auto-Start on Boot
The controller runs as a systemd service:
sudo systemctl status weather-shutter
Shutters will operate automatically using the latest trained model.
- Clean dataset:
data/processed/weather_hourly_clean.csv - CHIRPS daily cache:
data/raw/chirps_daily.csv - CHIRPS daily features:
data/processed/chirps_features_daily.csv - Enriched training dataset:
data/processed/weather_hourly_clean_enriched.csv - Trained model artifacts and metadata:
models/*.pkl,models/*_meta.json - Horizon metrics table:
models/metrics_multihorizon.csv
- Training and inference use cloud + edge hybrid architecture.
- Secrets are read from
.envlocally and GitHub Secrets in CI. - API keys and location coordinates are not hardcoded in tracked source.
- Hardware devices never expose API keys.
- Raspberry Pi fetches models from GitHub.
- Public dashboard performs no external requests.
- System is quota-safe for free-tier usage.
| Field | Value |
|---|---|
| Last retrain (UTC) | 2026-03-09T04:18:42.437451 |
| Active horizon | D_next_6h (6h) |
| Dataset rows | 17,928 |
| Data range | 2024-02-22 --> 2026-03-09 |
| ROC-AUC | 0.8748 |
| PR-AUC | 0.7298 |
| Positive rate | 0.3146 |
| Features used | 34 |
| CHIRPS training | Enabled |
| CHIRPS feature count | 17 |
| CHIRPS raw rows | 0 |
| CHIRPS feature rows | 16,467 |
| CHIRPS enriched rows | 17,928 |
Last updated automatically by GitHub Actions.
The shutter system includes multiple safety mechanisms:
| Feature | Purpose |
|---|---|
| State file | Restores last position after reboot |
| Manual override | Immediate user control |
| Hysteresis | Prevents rapid toggling |
| Model fallback | Uses previous model if current fails |
| Watchdog restart | Auto-restart on crash |
Future enhancements include rain sensors and limit switches.
| Field | Value |
|---|---|
| Horizon | D_next_6h (6h) |
| Last trained | 2026-03-09T04:18:42.437451 |
| Features | 34 |
| CHIRPS features | 17 |
| Positive rate | 0.3146 |
| Metric | Latest | Trend |
|---|---|---|
| ROC-AUC | 0.8748 | β ββ βββββββββ |
| PR-AUC | 0.7298 | ββββββββββββ |
β No degradation detected
Disabled (free-tier safe mode)
| Field | Value |
|---|---|
| Rows | 17,928 |
| Range | 2024-02-22 --> 2026-03-09 |
Last updated: 2026-03-09 04:18 UTC
Visual Crossing API
β
CHIRPS (Google Earth Engine)
β
GitHub Actions (48h)
β
Data Cleaning
β
CHIRPS Feature Enrichment
β
Model Training
β
Model Commit
β
Raspberry Pi (git pull)
β
Live Prediction
β
Shutter Control
This project is licensed under the MIT License. See LICENSE for details.
See CONTRIBUTING.md for guidelines.
See SECURITY.md for reporting vulnerabilities.
Don't let those crops get wet
Minimal β’ Automation β’ ML
GitHub β’ GitLab β’ Dashboard
Built by @rotsl π