← Back to Course
Data-Driven Irrigation Decisions
💧 Data-Driven Irrigation Decisions - Smart Water Management
🌾 What You'll Learn in This Lesson:
- 📊 Make data-driven irrigation decisions using soil moisture + weather data
- 💧 Save 30-50% water by irrigating only when needed
- 🌧️ Integrate rain forecasts to avoid wasting water
- 📈 Optimize crop yield with perfect soil moisture levels
- 🤖 Build an automated decision engine for your farm
📊 Why Data-Driven Irrigation Matters
| Traditional Irrigation | Data-Driven Irrigation |
|---|---|
| ❌ Water on fixed schedule (e.g., every day at 6 AM) | ✅ Water only when soil moisture drops below threshold |
| ❌ Wastes water when raining or soil already wet | ✅ Integrates rain forecast - skips irrigation when rain expected |
| ❌ Over-watering causes root rot, under-watering reduces yield | ✅ Maintains optimal moisture range for each crop type |
| ❌ 30-50% water typically wasted | ✅ Up to 50% water savings, 20-30% yield increase |
💡 The Cost of Over-Watering:
Over-watering is worse than under-watering! It causes:
- 🌱 Root rot and fungal diseases
- 💧 Nutrient leaching (washing away fertilizers)
- 💰 Higher water bills and energy costs
- 🌍 Environmental damage from runoff
🎯 The Complete Irrigation Decision Matrix
| Soil Moisture | Rain Forecast (24h) | Temperature | Action | Water Duration |
|---|---|---|---|---|
| < 20% (Critical) | Any | Any | 🚨 EMERGENCY WATER - Immediate! | 15-20 minutes |
| 20-35% (Dry) | None or < 5mm | < 35°C | 💧 Water Now | 10-15 minutes |
| 20-35% (Dry) | ≥ 10mm expected | Any | ⏸️ Skip irrigation - rely on rain | 0 minutes |
| 35-50% (Adequate) | Any | < 35°C | ✅ Monitor only - no action | 0 minutes |
| 35-50% (Adequate) | Any | ≥ 35°C (Heat wave) | 💧 Light cooling irrigation (stress prevention) | 3-5 minutes |
| 50-70% (Optimal) | Any | Any | ✅ No irrigation needed - perfect conditions | 0 minutes |
| 70-85% (Wet) | Any | Any | ⚠️ Stop irrigation - drying needed | 0 minutes |
| > 85% (Flooded) | Any | Any | 🚨 CRITICAL ALERT - Risk of root rot! Improve drainage | 0 minutes |
🌧️ Rain Forecast Integration
💡 Smart farmers don't water before rain!
Integrating weather forecasts is the #1 way to save water. Always check:
- Next 24 hours: If ≥ 10mm rain expected → Skip irrigation entirely
- Next 48 hours: If ≥ 15mm rain expected → Reduce irrigation by 50%
- High wind forecast: Increase irrigation by 20% (wind increases evaporation)
🌡️ Temperature Adjustments
| Temperature Range | Effect on Plants | Irrigation Adjustment |
|---|---|---|
| < 15°C | Slow growth, low water needs | ⬇️ Reduce by 40% |
| 15-25°C | Optimal growth | ✅ Normal schedule |
| 25-32°C | Good growth, higher transpiration | ⬆️ Increase by 20% |
| 32-38°C | Heat stress begins | ⬆️ Increase by 40% + light cooling |
| > 38°C | Critical heat stress | 🚨 Emergency cooling irrigation |
📈 Crop-Specific Moisture Thresholds
| Crop | Optimal Range (%) | Water When Below (%) | Critical Below (%) |
|---|---|---|---|
| 🍅 Tomatoes | 45-70% | 40% | 25% |
| 🌶️ Peppers | 45-70% | 40% | 25% |
| 🥒 Cucumbers | 50-75% | 45% | 30% |
| 🥬 Lettuce | 50-80% | 45% | 30% |
| 🌽 Corn | 40-65% | 35% | 20% |
| 🍆 Eggplant | 45-70% | 40% | 25% |
| 🥕 Carrots | 40-65% | 35% | 20% |
| 🧅 Onions | 35-60% | 30% | 15% |
| 🍓 Strawberries | 50-75% | 45% | 30% |
| 🌿 Basil/Herbs | 45-70% | 40% | 25% |
💻 Arduino Code: Smart Irrigation Decision Engine
/* * Smart Irrigation Decision Engine * Combines soil moisture, temperature, and rain forecast * * Features: * - Automatic irrigation based on 5+ data points * - Rain forecast integration (saves water) * - Temperature compensation * - Crop-specific thresholds */ #include// ========== PIN DEFINITIONS ========== #define SOIL_PIN 32 // Soil moisture sensor #define RELAY_PIN 5 // Water pump relay #define DHT_PIN 4 // DHT22 temperature/humidity // ========== CALIBRATION VALUES (CALIBRATE THESE!) ========== const int DRY_VALUE = 3800; const int WET_VALUE = 1500; // ========== CROP CONFIGURATION ========== struct CropConfig { const char* name; int optimalMin; int optimalMax; int waterThreshold; // Water when below this int criticalPoint; // Emergency below this }; CropConfig crops[] = { {"Tomatoes", 45, 70, 40, 25}, {"Peppers", 45, 70, 40, 25}, {"Corn", 40, 65, 35, 20}, {"Lettuce", 50, 80, 45, 30}, {"Default", 40, 70, 35, 20} }; int currentCrop = 0; // Index of selected crop // ========== WEATHER FORECAST ========== float rainForecastMM = 0; // mm of rain expected in 24h bool heatWaveWarning = false; // ========== IRRIGATION SETTINGS ========== const int BASE_WATER_DURATION = 600; // 10 minutes base const int MAX_WATER_DURATION = 1200; // 20 minutes max const int MIN_WATER_DURATION = 180; // 3 minutes min // Read soil moisture and return percentage int readSoilMoisture() { int raw = analogRead(SOIL_PIN); int percentage = map(raw, DRY_VALUE, WET_VALUE, 0, 100); percentage = constrain(percentage, 0, 100); return percentage; } // Calculate optimal water duration based on multiple factors int calculateWaterDuration(int moisture, float temperature, float rainMM) { CropConfig crop = crops[currentCrop]; int duration = 0; // Factor 1: Soil moisture deficit if (moisture < crop.criticalPoint) { duration = MAX_WATER_DURATION; } else if (moisture < crop.waterThreshold) { int deficit = crop.waterThreshold - moisture; duration = BASE_WATER_DURATION + (deficit * 10); duration = constrain(duration, MIN_WATER_DURATION, MAX_WATER_DURATION); } // Factor 2: Temperature adjustment if (temperature > 35) { duration = duration * 1.4; // 40% increase for heat wave } else if (temperature > 32) { duration = duration * 1.2; // 20% increase for heat } else if (temperature < 15) { duration = duration * 0.6; // 40% reduction for cold } // Factor 3: Rain forecast adjustment if (rainMM > 15) { duration = 0; // Skip completely if heavy rain } else if (rainMM > 8) { duration = duration * 0.5; // 50% reduction if moderate rain } else if (rainMM > 3) { duration = duration * 0.7; // 30% reduction if light rain } return constrain(duration, 0, MAX_WATER_DURATION); } // Get decision message String getDecisionMessage(int moisture, float rainMM, float temperature) { CropConfig crop = crops[currentCrop]; if (moisture < crop.criticalPoint) { return "🚨 CRITICAL: Soil extremely dry! Emergency irrigation required!"; } if (moisture < crop.waterThreshold) { if (rainMM > 15) { return "⏸️ Soil dry but heavy rain expected - skipping irrigation, relying on rain"; } else if (rainMM > 8) { return "💧 Soil dry - irrigating at 50% due to forecast rain"; } else { return "💧 Soil below threshold - starting irrigation"; } } if (moisture >= crop.optimalMin && moisture <= crop.optimalMax) { return "✅ Optimal soil moisture - no action needed"; } if (moisture > crop.optimalMax) { return "⚠️ Soil too wet - stop irrigation, check drainage"; } return "📊 Monitoring - conditions normal"; } // Display complete irrigation report void displayIrrigationReport(int moisture, int duration, float temp, float rainMM) { CropConfig crop = crops[currentCrop]; Serial.println("╔══════════════════════════════════════════════════════════════╗"); Serial.println("║ 💧 IRRIGATION DECISION REPORT ║"); Serial.println("╚══════════════════════════════════════════════════════════════╝"); Serial.println(""); Serial.println("📊 CURRENT CONDITIONS:"); Serial.printf(" 🌱 Crop: %s\n", crop.name); Serial.printf(" 💧 Soil Moisture: %d%%\n", moisture); Serial.printf(" 🌡️ Temperature: %.1f°C\n", temp); Serial.printf(" 🌧️ Rain Forecast (24h): %.1f mm\n", rainMM); Serial.println(""); Serial.println("📋 CROP THRESHOLDS:"); Serial.printf(" 🟢 Optimal range: %d-%d%%\n", crop.optimalMin, crop.optimalMax); Serial.printf(" 🟡 Water below: %d%%\n", crop.waterThreshold); Serial.printf(" 🔴 Critical below: %d%%\n", crop.criticalPoint); Serial.println(""); Serial.println("🎯 DECISION:"); Serial.printf(" %s\n", getDecisionMessage(moisture, rainMM, temp).c_str()); if (duration > 0) { Serial.printf(" 💧 Watering duration: %d seconds (%d minutes)\n", duration, duration/60); } Serial.println(""); Serial.println("══════════════════════════════════════════════════════════════════\n"); } void setup() { Serial.begin(115200); pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, HIGH); // Pump OFF initially Serial.println("========================================"); Serial.println("💧 SMART IRRIGATION DECISION ENGINE v2.0"); Serial.println(" Data-driven watering decisions"); Serial.println("========================================\n"); } void loop() { // Read sensors int moisture = readSoilMoisture(); // In real implementation, get temperature from DHT22 float temperature = 26.5; // Replace with actual sensor reading float rainForecast = 0; // Replace with API call to weather service // Calculate water duration int waterDuration = calculateWaterDuration(moisture, temperature, rainForecast); // Generate report displayIrrigationReport(moisture, waterDuration, temperature, rainForecast); // Execute irrigation if needed if (waterDuration > 0) { Serial.printf("💧 Activating pump for %d seconds...\n", waterDuration); digitalWrite(RELAY_PIN, LOW); // Pump ON delay(waterDuration * 1000); digitalWrite(RELAY_PIN, HIGH); // Pump OFF Serial.println("✅ Irrigation complete\n"); } // Wait before next check (default: 1 hour = 3,600,000 ms) delay(3600000); }
📱 API Integration for Real-Time Weather Data
/* * Fetch real-time weather forecast from OpenWeatherMap API * Integrate with your irrigation decision engine */ #include#include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; const char* apiKey = "YOUR_OPENWEATHER_API_KEY"; const char* city = "Nairobi,KE"; struct WeatherForecast { float temp; float humidity; float rainMM; // mm of rain expected int windSpeed; // km/h String condition; }; WeatherForecast getWeatherForecast() { WeatherForecast forecast = {0, 0, 0, 0, "clear"}; if (WiFi.status() == WL_CONNECTED) { HTTPClient http; String url = "http://api.openweathermap.org/data/2.5/weather?q=" + String(city) + "&appid=" + apiKey + "&units=metric"; http.begin(url); int httpCode = http.GET(); if (httpCode == 200) { String payload = http.getString(); DynamicJsonDocument doc(2048); deserializeJson(doc, payload); forecast.temp = doc["main"]["temp"]; forecast.humidity = doc["main"]["humidity"]; // Check for rain if (doc.containsKey("rain")) { forecast.rainMM = doc["rain"]["1h"].as (); } // Get weather condition const char* condition = doc["weather"][0]["main"]; forecast.condition = String(condition); } http.end(); } return forecast; }
📖 Real Farm Case Study - Moroccan Tomato Greenhouse:
A 2-hectare tomato farm implemented data-driven irrigation decisions:
- 💧 Before: Fixed irrigation schedule - watered 2 hours daily
- 📊 After: Smart system only when moisture < 40% + rain check
- 💧 Water saved: 45% reduction (saved 2,000 m³/month)
- 💰 Cost saved: $180/month on water + electricity
- 🌱 Yield: 25% increase (less over-watering stress)
"The decision matrix changed everything. We now irrigate only when needed, and the rain forecast feature has saved us thousands." - Greenhouse Manager, Morocco
💡 Pro Tips for Best Results:
- 📍 Soil moisture sensors - Install at root depth (10-30cm), not surface
- 📍 Multiple sensors - Use 3-5 sensors per zone and average readings
- 📍 Rain gauge - Install physical rain gauge to validate forecasts
- 📍 Morning watering - Best time is 5-7 AM to reduce evaporation
- 📍 Keep records - Log all decisions to refine thresholds over time
🎉 Congratulations!
You now have a complete data-driven irrigation decision system!
- ✅ Decision matrix for any soil moisture + weather combination
- ✅ Crop-specific thresholds for optimal growth
- ✅ Temperature + rain forecast integration
- ✅ Complete Arduino code for automation
- ✅ Save 30-50% water while increasing yields
📋 Quick Reference - Daily Irrigation Decision Flow:
┌─────────────────────────────────────────────────────────────────────────┐ │ DAILY IRRIGATION DECISION FLOW │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ 1. Read soil moisture sensor │ │ ↓ │ │ 2. Check rain forecast (24h) │ │ ↓ │ │ 3. Check current temperature │ │ ↓ │ │ 4. Apply decision matrix: │ │ │ │ Moisture < 20%? ──YES──→ EMERGENCY WATER (15-20 min) │ │ ↓ NO │ │ Moisture < threshold? ──YES──→ Check rain forecast │ │ ↓ NO ↓ │ │ Moisture optimal? ──YES──→ No action needed! │ │ Rain > 10mm? ──YES──→ Skip irrigation │ │ ↓ NO │ │ → Water (10-15 min) │ │ │ │ 5. Adjust for temperature (hot = more water, cold = less) │ │ 6. Execute irrigation if needed │ │ 7. Log decision for future analysis │ │ │ └─────────────────────────────────────────────────────────────────────────┘
💡 Key Takeaways:
- Apply these concepts directly to your farm or project.
- Take notes on important details for the quiz.
- Use the button below to track your progress.
×