A comprehensive 24ร7 IoT-based crop stress monitoring and smart irrigation system built with Flutter. This application provides real-time visualization of soil moisture, temperature, and humidity data from ESP32 sensors, with intelligent alerts and manual pump control.
- Live sensor data updates (temperature, humidity, soil moisture)
- Automatic data refresh every 3-5 seconds
- Visual crop stress level indicators
- Multi-field support with unique device IDs
- Daily/Weekly/Monthly data visualization
- Line and bar charts for trend analysis
- Min/Max/Average statistics
- Exportable reports
- Configurable threshold alerts
- Critical, warning, and info severity levels
- Push notifications for urgent issues
- Alert history and management
- Manual pump ON/OFF control
- Real-time pump status monitoring
- Auto-irrigation option (configurable)
- Pump action logging
- Data buffering when offline
- Automatic sync when connection returns
- Local storage for preferences
- Modern Material Design 3
- Dark and light themes
- Smooth animations
- Farmer-friendly interface
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HARDWARE LAYER โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ESP32 + DHT22 + Soil Moisture Sensor + Relay (Pump) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ WiFi
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CLOUD LAYER โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Firebase Realtime Database โ
โ โโโ devices/ โ
โ โ โโโ field-001/ โ
โ โ โโโ latest/ (current sensor readings) โ
โ โ โโโ history/ (historical data) โ
โ โ โโโ pumpStatus (pump control flag) โ
โ โ โโโ settings/ (configuration) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTPS
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ APPLICATION LAYER โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Flutter Mobile App โ
โ โโโ Real-time visualization โ
โ โโโ Historical charts โ
โ โโโ Alert management โ
โ โโโ Pump control โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Flutter SDK 3.8+
- Android Studio / VS Code
- Firebase account
- ESP32 development board (for hardware)
-
Clone the repository
git clone https://github.com/yourusername/crop_monitor.git cd crop_monitor -
Install dependencies
flutter pub get
-
Configure Firebase (for production)
- Create a Firebase project
- Enable Realtime Database
- Download
google-services.json(Android) - Place in
android/app/ - Update Firebase rules (see below)
-
Run the app
flutter run
{
"rules": {
"devices": {
"$deviceId": {
".read": true,
".write": true,
"latest": {
".read": true,
".write": true
},
"history": {
".read": true,
".write": true,
".indexOn": ["timestamp"]
}
}
}
}
}| Component | Quantity | Purpose |
|---|---|---|
| ESP32 DevKit | 1 | Main controller |
| DHT22 Sensor | 1 | Temperature & Humidity |
| Capacitive Soil Moisture Sensor | 1 | Soil moisture |
| 5V Relay Module | 1 | Pump control |
| Mini Water Pump | 1 | Irrigation (demo) |
| Jumper Wires | Several | Connections |
| 5V Power Supply | 1 | Power |
ESP32 Pin Connections:
โโโโโโโโโโโโโโโโโโโโโ
GPIO4 โ DHT22 Data
GPIO34 โ Soil Moisture Sensor (Analog)
GPIO25 โ Relay IN
3.3V โ DHT22 VCC, Soil Sensor VCC
GND โ DHT22 GND, Soil Sensor GND, Relay GND
5V โ Relay VCC
- Open
esp32_firmware/crop_monitor.inoin Arduino IDE - Install required libraries:
- Firebase ESP Client
- DHT sensor library
- Update WiFi and Firebase credentials
- Select ESP32 board and upload
lib/
โโโ main.dart # App entry point
โโโ models/ # Data models
โ โโโ sensor_data.dart # Sensor reading model
โ โโโ field.dart # Farm field model
โ โโโ alert.dart # Alert model
โโโ providers/ # State management
โ โโโ field_provider.dart # Field & sensor state
โ โโโ alert_provider.dart # Alert management
โ โโโ settings_provider.dart # App settings
โโโ screens/ # UI screens
โ โโโ splash_screen.dart # Splash with animation
โ โโโ home_screen.dart # Main navigation
โ โโโ dashboard_screen.dart # Live data view
โ โโโ graph_screen.dart # Charts & analytics
โ โโโ alerts_screen.dart # Alert management
โ โโโ fields_screen.dart # Multi-field view
โ โโโ settings_screen.dart # App preferences
โโโ services/ # Backend services
โ โโโ firebase_service.dart # Firebase RTDB
โ โโโ notification_service.dart # Push notifications
โ โโโ storage_service.dart # Local storage
โโโ theme/ # App theming
โ โโโ app_theme.dart # Colors, styles
โโโ widgets/ # Reusable widgets
โโโ sensor_card.dart # Sensor display card
โโโ stress_indicator.dart # Crop stress widget
โโโ field_card.dart # Field selector
โโโ alert_card.dart # Alert item
โโโ pump_control.dart # Pump toggle
โโโ charts.dart # Line & bar charts
The system calculates crop stress based on three parameters:
| Parameter | Optimal Range | Moderate Stress | High Stress | Critical |
|---|---|---|---|---|
| Temperature | 20-30ยฐC | 18-32ยฐC | 15-35ยฐC | <15 or >35ยฐC |
| Humidity | 40-70% | 35-80% | 30-85% | <30 or >85% |
| Soil Moisture | 40-70% | 35-75% | 25-85% | <25 or >85% |
- ๐พ Paddy (Rice)
- ๐พ Wheat
- ๐ฅ Groundnut
- ๐ฟ Cotton
- ๐ Sugarcane
- ๐ฝ Maize (Corn)
- ๐ Tomato
- ๐ฅ Potato
- ๐ง Onion
- ๐ถ๏ธ Chili
- ๐ฅญ Mango
- ๐ Banana
- ๐ฅฅ Coconut
- โ Coffee
- ๐ต Tea
| ID | Requirement | Status |
|---|---|---|
| FR-1 | Sensor Data Acquisition | โ |
| FR-2 | Data Transmission to Cloud | โ |
| FR-3 | Real-Time Visualization | โ |
| FR-4 | Historical Data View | โ |
| FR-5 | Alert System | โ |
| FR-6 | Multi-Location Support | โ |
| FR-7 | Manual Irrigation Control | โ |
- AI-based stress prediction
- SMS alert system
- Voice alerts in local languages
- Solar-powered sensor nodes
- Weather forecast integration
- Crop disease detection (camera)
- Multi-user authentication
- Farm analytics dashboard
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
Developed as an Academic Project for IoT-Based Smart Agriculture
Made with โค๏ธ for Smart Agriculture
"The proposed system enables 24ร7 crop monitoring using IoT sensors and a Flutterโbased mobile application with realโtime visualization, alerts, and offline support."