A modular, extensible smart irrigation controller in Python
Decides intelligently when to water plants by combining soil moisture levels with rain probability forecasts β ideal for Raspberry Pi, ESP32, simulators, or any IoT setup.
- Configurable moisture & rain probability thresholds
- Simulated sensors (easy to replace with real hardware like capacitive soil sensors, DHT22, etc.)
- Dry-run / simulation mode (no hardware needed for development & testing)
- Structured logging + basic CLI interface
- Clean architecture ready for extensions:
- Real weather APIs (OpenWeatherMap, WeatherAPI, etc.)
- MQTT publishing/subscribing
- GPIO control (RPi.GPIO, adafruit libraries)
- Database storage (SQLite, InfluxDB)
- Web dashboard (future)
- Features
- Project Structure
- Prerequisites
- Installation
- Quick Start
- Usage Examples
- Configuration
- Testing
- Contributing
- License
smart-irrigation-platform/ β βββ src/ # Main source code β βββ init.py β βββ main.py # Entry point β βββ core/ β β βββ init.py β β βββ irrigation_system.py # Core business logic β βββ sensors/ β β βββ init.py β β βββ soil_moisture.py # Sensor abstractions β βββ weather/ β β βββ init.py β β βββ weather_service.py # Weather data (simulated or API) β βββ utils/ β βββ init.py β βββ logger.py # Centralized logging β βββ tests/ # Unit & integration tests β βββ init.py β βββ test_irrigation_system.py β βββ config/ β βββ config.py # Configuration (thresholds, etc.) β βββ .env # Environment variables (not in git) βββ .env.example # Template for .env βββ .gitignore βββ README.md βββ requirements.txt βββ setup.py # Optional: for packaging βββ LICENSE
- Python 3.8+
- Git
- (Optional) Virtual environment tool:
venv,uv,poetry, etc.
- Clone the repository:
git clone https://github.com/bundlab/smart_irrigation_sys.git cd smart_irrigation_sys
Run the simulation python -m smart_irrigation
[INFO] Soil moisture: 42% | Rain probability: 15% [INFO] Decision: NO irrigation needed
-
Simulate custom conditions python -m smart_irrigation --simulate --moisture=25 --rain-prob=60
-
Run once (good for scheduled tasks) python -m smart_irrigation --once
-
Verbose mode python -m smart_irrigation --verbose
cp src/smart_irrigation/config.example.yaml config.yaml Example config.yml thresholds: moisture_critical: 30 # below β must water moisture_warning: 45 rain_skip_probability: 40 # above β skip
pytest # run tests pytest --cov # with coverage black . # format ruff check --fix # lint & fix
- Fork the repo
- Create your branch (git checkout -b feature/cool-feature)
- Commit (git commit -m 'Add cool feature')
- Push (git push origin feature/cool-feature)
- Open a Pull Request Follow black formatting & add tests where possible.
- MIT License β see LICENSE for details.