A full-stack IoT application for automated plant irrigation with real-time moisture monitoring. Built with Rust backend and React frontend.
- Real-time Monitoring - Track soil moisture levels with interactive charts
- Automated Irrigation - Configurable thresholds trigger watering automatically
- Manual Override - One-click manual irrigation control
- Multi-timeframe Views - View data by hour, day, week, or month
- Configurable Parameters - Adjust irrigation duration, intervals, and thresholds
- Time-series Storage - Efficient multi-granularity data aggregation
| Layer | Technology |
|---|---|
| Backend | Rust, Rocket 0.5, MongoDB |
| Frontend | React 18, TypeScript, Tailwind CSS, Visx |
| Database | MongoDB 6 |
| Infrastructure | Docker, Docker Compose, GitHub Actions |
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ ESP8266/RPi │────▶│ Rust Backend │◀────│ React Frontend │
│ (Sensor Data) │ │ (Rocket API) │ │ (Dashboard) │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
┌────────▼────────┐
│ MongoDB │
│ (Time-series) │
└─────────────────┘
The easiest way to run the project:
# Clone the repository
git clone https://github.com/cosmologist10/irrigation-system.git
cd irrigation-system
# Start all services
docker-compose up -d
# Open the dashboard
open http://localhost:3000This starts:
- Frontend at http://localhost:3000
- Backend API at http://localhost:8000
- MongoDB at localhost:27017
To see the system in action without real sensors:
# Seed historical data (past 7 days)
python scripts/demo_simulator.py --seed
# Run continuous simulation (live data)
python scripts/demo_simulator.py --continuous- Rust 1.70+ (
rustup) - Node.js 18+ (
nvm) - MongoDB 6+
# Copy environment file
cp .env.example .env
# Start MongoDB (if not using Docker)
mongod --dbpath /path/to/data
# Run the backend
cargo runThe API will be available at http://localhost:8000.
cd frontend
# Install dependencies
npm install
# Start development server
npm startThe dashboard will be available at http://localhost:3000.
| Method | Endpoint | Description |
|---|---|---|
POST |
/app/measurement |
Submit new sensor reading |
GET |
/app/get_last_day_measurements/:sensor |
Get last 24 hours data |
GET |
/app/get_last_week_measurements/:sensor |
Get last 7 days data |
GET |
/app/get_last_hour_measurements/:sensor |
Get last 60 minutes data |
GET |
/app/get_last_month_measurements/:sensor |
Get last 30 days data |
GET |
/app/sensors |
List all configured sensors |
GET |
/app/sensors/irrigation/:sensor |
Trigger manual irrigation |
GET |
/app/irrigations/:sensor |
Get irrigation history |
GET |
/app/preferences/:sensor |
Get sensor preferences |
POST |
/app/preferences/:sensor |
Update sensor preferences |
curl -X POST http://localhost:8000/app/measurement \
-H "Content-Type: application/json" \
-d '{"sensor_name": "plant_1", "capacity": 650}'| Variable | Description | Default |
|---|---|---|
MONGODB_URI |
MongoDB connection string | mongodb://localhost:27017 |
ROCKET_ADDRESS |
Server bind address | 0.0.0.0 |
ROCKET_PORT |
Server port | 8000 |
REACT_APP_API_URL |
Backend URL for frontend | http://localhost:8000 |
Each sensor can be configured with:
- Irrigation Time - How long to water (seconds)
- Minimum Interval - Cooldown between irrigations (minutes)
- Capacity Buffer - Moisture threshold to trigger irrigation
- Signal Pin - GPIO pin for relay control (Raspberry Pi)
irrigation-system/
├── src/ # Rust backend
│ ├── main.rs # Entry point
│ ├── lib.rs # App initialization & CORS
│ ├── models/ # Data models
│ ├── repository/ # Database layer
│ └── routes/ # HTTP endpoints
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── Graph/ # Data visualization
│ │ │ └── ControlPanel/ # Settings UI
│ │ └── constants/ # Configuration
│ └── package.json
├── scripts/ # Utility scripts
│ └── demo_simulator.py # Demo data generator
├── docker-compose.yml # Container orchestration
├── Dockerfile # Backend container
└── .github/workflows/ # CI/CD pipeline
For actual deployment with sensors:
- Raspberry Pi Zero W
- Capacitive Soil Moisture Sensor
- 5V Relay Module
- 12V Water Pump
Raspberry Pi GPIO 18 ──▶ Relay IN
Relay COM ──▶ 12V Power Supply
Relay NO ──▶ Water Pump (+)
# Run backend tests
cargo test
# Run with verbose output
cargo test --verbose
# Run frontend type checking
cd frontend && npx tsc --noEmit- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under MIT - see the LICENSE file for details.
Inspired by PatrickHallek/automated-irrigation-system, reimplemented with a Rust backend for better performance and type safety.