An intelligent IoT irrigation system that combines ESP8266 hardware with an Android mobile app and AI-powered recommendations to optimize plant watering.
Demo Videodemo.mp4 |
ESP Device
|
The Smart Irrigation System monitors soil moisture in real-time and controls a water pump automatically or manually. The system features an AI assistant that provides intelligent threshold recommendations based on plant type and location.
┌─────────────┐ WiFi/HTTP ┌──────────────┐
│ ESP8266 │ ◄────────────────────────► │ Android App │
│ + Sensors │ SSE Stream + REST API │ + AI Bot │
└─────────────┘ └──────────────┘
│ │
├─ Soil Moisture Sensor ├─ Real-time Monitoring
├─ Relay (Pump Control) ├─ Manual/Auto Control
└─ WiFi Communication └─ AI Recommendations
Communication Flow:
- ESP8266 continuously reads soil moisture and sends updates via Server-Sent Events (SSE)
- Android App receives real-time data and displays current status
- User can manually control pump or switch to automatic mode
- AI Chatbot analyzes plant type + location → recommends optimal threshold
- App sends HTTP requests to ESP8266 to control pump/mode/threshold
Smart_Irrigation/
├── Android/ # 📱 Android Mobile Application
│ ├── app/ # Main app module (Kotlin + Jetpack Compose)
│ ├── gradle/ # Build system
│ └── README.md # Android development guide
│
├── Arduino/ # 🔌 ESP8266 Firmware
│ ├── main/ # Arduino sketch (.ino)
│ └── README.md # Hardware setup & API docs
│
├── LICENSE # Project license
└── README.md # This file
- Live soil moisture readings (0-100%)
- Current pump status (ON/OFF)
- Connection status indicator
- Automatic reconnection on network issues
- ESP8266 monitors soil moisture continuously
- Automatically turns pump ON when moisture < threshold
- Turns pump OFF when moisture ≥ threshold
- Hands-free irrigation
- User controls pump directly from app
- Override automatic behavior
- Useful for testing or special watering needs
The chatbot feature will:
- Accept plant name (e.g., "Tomato", "Rose", "Cactus")
- Accept location (city/region for climate data)
- Analyze plant water requirements
- Consider local climate conditions
- Recommend optimal moisture threshold
- Automatically set threshold on user confirmation
Example Interaction:
User: "I'm growing tomatoes in Mumbai"
AI: "Tomatoes in Mumbai's climate need moderate watering.
I recommend a threshold of 45%. Shall I set it for you?"
User: "Yes"
AI: ✓ Threshold set to 45%
- Set custom moisture thresholds (0-100%)
- Configure plant preferences
- Manage notifications
- Dark mode support
- Language: Kotlin
- UI: Jetpack Compose (Material 3)
- Architecture: Clean Architecture + MVVM
- DI: Dagger Hilt
- Networking: Ktor Client (HTTP + SSE)
- Storage: DataStore Preferences
- Async: Coroutines + Flow
- Microcontroller: ESP8266 (NodeMCU/Wemos D1)
- Sensors: Capacitive/Resistive Soil Moisture Sensor
- Actuator: Relay Module (for pump control)
- Communication: WiFi (HTTP Server + SSE)
- Power: 5V USB or external supply
- Android: Device running Android 7.0+ (API 24+)
- ESP8266: NodeMCU or compatible board
- Network: Both devices on same WiFi network
-
Connect components:
- Soil moisture sensor → ESP8266 analog pin
- Relay module → ESP8266 digital pin
- Water pump → Relay output
-
Flash firmware:
cd Arduino/main/ # Open main.ino in Arduino IDE # Configure WiFi credentials # Upload to ESP8266
-
Note the ESP8266's IP address from Serial Monitor
📖 Detailed guide: Arduino/README.md
- Open Android Studio
- Open the
Android/folder - Update ESP8266 IP in
IrrigationRepoImpl.kt:private const val BASE_URL = "http://YOUR_ESP_IP"
- Build and install on your Android device
📖 Detailed guide: Android/README.md
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /sse |
Server-Sent Events stream (real-time updates) | No |
| POST | /setThreshold |
Set moisture threshold (0-1024) | Yes |
| POST | /setMode |
Switch manual/auto mode | Yes |
| POST | /setPump |
Turn pump ON/OFF (manual mode) | Yes |
Authentication: Bearer token (myStrongAdminKey123)
data: {
"threshold": 512, // Current threshold (0-1024)
"soilMoisture": 650, // Current moisture (0-1024)
"relayStatus": false, // Pump state (true=ON)
"mode": true // true=manual, false=auto
}Set Threshold:
POST http://192.168.1.150/setThreshold
Authorization: Bearer myStrongAdminKey123
Content-Type: application/json
{"threshold": 512}Switch to Auto Mode:
POST http://192.168.1.150/setMode
Authorization: Bearer myStrongAdminKey123
Content-Type: application/json
{"mode": false}Turn Pump ON:
POST http://192.168.1.150/setPump
Authorization: Bearer myStrongAdminKey123
Content-Type: application/json
{"pumpStatus": true}User Input (Plant + Location)
↓
AI Analysis Engine
↓
┌─────────────────┐
│ Plant Database │ → Water requirements
│ Climate API │ → Local weather data
│ ML Model │ → Optimal threshold
└─────────────────┘
↓
Recommendation
↓
User Confirmation
↓
HTTP POST /setThreshold
↓
ESP8266 Updates Threshold
- Plant Name: Type of plant being grown
- Location: City/region for climate context
- Threshold Recommendation: Optimal moisture percentage
- Reasoning: Why this threshold is recommended
- Auto-Set Option: One-tap threshold configuration
- Connected: Green indicator, live data streaming
- Disconnected: Red banner, attempting reconnection
- Reconnecting: Yellow indicator, retry in progress
- Automatic: ESP8266 controls pump based on threshold
- Manual: User controls pump via app
- ON: Actively irrigating
- OFF: Standby
- Local Network Only: System operates on local WiFi (no internet required)
- Bearer Token Auth: Protects control endpoints
- No Cloud Dependency: All data stays on local network
- Cleartext HTTP: Suitable for home networks (consider HTTPS for production)
- Real-time soil moisture monitoring
- Manual pump control
- Automatic irrigation mode
- Custom threshold settings
- SSE-based live updates
- Background service for persistent monitoring
- AI Chatbot Integration
- Plant database integration
- Weather API integration
- ML-based threshold recommendations
- Conversational interface
- Auto-threshold setting
- Historical data charts
- Irrigation scheduling
- Multi-device support
- Cloud sync (optional)
- Water usage analytics
Contributions are welcome! Areas for improvement:
- AI chatbot implementation
- Additional sensor support
- UI/UX enhancements
- Documentation improvements
See LICENSE file for details.
- Ensure both devices are on same WiFi network
- Verify ESP8266 IP address is correct
- Check firewall settings
- Restart ESP8266 and app
- Verify relay connections
- Check power supply to pump
- Test relay manually
- Review ESP8266 serial logs
- Calibrate sensor (dry vs wet soil)
- Check sensor connections
- Clean sensor probes
- Verify sensor type (capacitive recommended)
For issues or questions:
Built with ❤️ for smarter, more efficient irrigation
