OC
OceanRemote
Low-code IoT platform
← Back to Course

Making Decisions from Data

Making Decisions from Data

🧠 Making Smart Decisions from Sensor Data

📊 What You'll Learn:

  • 🧠 Create decision trees for automated irrigation
  • 🚨 Set up alerts for critical farm conditions
  • 📈 Learn from historical data to optimize watering schedules
  • 💰 Save water and increase yields with data-driven decisions

📊 Example Decision Tree for Irrigation

If soil_moisture > 50%:
    → Do NOT water (save water!)
    → Status: "🌊 Soil is wet. Good."

If 30% ≤ soil_moisture ≤ 50%:
    → Check again in 6 hours
    → Status: "🌿 Soil is drying. Monitor."

If soil_moisture < 30%:
    → Send ALERT to phone
    → Turn on water pump (if automated)
    → Status: "⚠️ WATER NOW - soil is too dry!"
    
💡 Why Decision Trees Work:

A decision tree removes guesswork. Instead of asking "Should I water today?" you simply follow the rules. Farmers using decision trees save 30-50% more water than those using timers or gut feelings.

🚨 Setting Up Alerts in OceanRemote

  • 🌡️ Temperature Alert
    Send notification when greenhouse exceeds 40°C
    💡 Prevents crop heat stress and wilting
  • 💧 Humidity Alert
    Warn when storage humidity > 70% (risk of mold)
    💡 Protects harvested crops from spoilage
  • 🌱 Soil Moisture Alert
    Notify when below 30% (time to water)
    💡 Prevents drought stress before visible wilting
  • 🌧️ Rain Alert
    Suspend irrigation automatically when rain detected
    💡 Saves water by not watering before rain
⚠️ Alert Best Practices:
  • Set multiple thresholds (warning at 35°C, critical at 40°C)
  • Test alerts during normal conditions to avoid false alarms
  • Add time delays (e.g., alert only if dry for 2+ hours) to prevent notification spam
  • Always have a fallback contact (neighbor or farm manager) if you miss the alert

📈 Learning from Historical Data

  • 📅 Pattern Discovery #1:
    "Every Tuesday afternoon, temperature spikes. I should water Monday nights."
    💧 Result: Plants are hydrated before heat arrives
  • 📅 Pattern Discovery #2:
    "My soil stays moist for 3 days after watering. I can water every 4 days, not daily."
    💧 Result: 75% reduction in water usage!
  • 📅 Pattern Discovery #3:
    "Last month I watered 15 times. This month with sensors, I only watered 9 times."
    💧 Result: 40% less water, healthier plants (no over-watering)
📖 Case Study — Data-Driven Decisions Save $2,000, Ghana:

A pepper farmer analyzed 3 months of soil moisture data:

  • 📊 Discovery: Soil stayed wet for 4 days after watering (not 2 days as assumed)
  • Action: Changed schedule from every 2 days to every 4 days
  • 💧 Water savings: 50% reduction (from 20,000L to 10,000L/week)
  • 💰 Cost savings: $2,000/year on water + electricity
  • 📈 Yield increase: 20% more peppers (reduced over-watering stress)

"I used to water every other day because that's what my neighbor did. The data showed I was wasting water. Now my peppers are bigger and my bills are smaller." — Farmer, Central Region

🎯 Your Action Plan:
  1. Identify 3 important parameters on your farm (soil moisture, temperature, humidity)
  2. Set alert thresholds for each (e.g., water when moisture < 30%)
  3. Check data weekly to find patterns (same day, same time each week)
  4. Adjust your farming practices based on evidence, not guessing!
  5. 📝 Track your savings in a notebook — you'll be amazed at the difference
💡 Sample Code for Automated Decision Making:
// Complete decision logic for your ESP32
int moisture = getSoilMoisturePercent();
float temp = dht.readTemperature();

if (moisture < 25) {
    sendAlert("CRITICAL: Soil moisture below 25%!");
    digitalWrite(RELAY_PIN, LOW);  // Start pump
    delay(600000);  // Water for 10 minutes
    digitalWrite(RELAY_PIN, HIGH);
} 
else if (moisture < 35 && temp > 32) {
    // Hot + moderately dry = water
    digitalWrite(RELAY_PIN, LOW);
    delay(300000);  // Water for 5 minutes
    digitalWrite(RELAY_PIN, HIGH);
}
else if (moisture > 65) {
    sendAlert("Soil too wet! Check drainage.");
}
        
⚠️ Common Decision-Making Mistakes:
  • ❌ Reacting to single readings: One false reading can trigger wrong actions. Average 3-5 readings.
  • ❌ Ignoring time of day: Soil moisture drops at 2pm due to evaporation, but recovers at night.
  • ❌ No fail-safes: Always add max run time to pumps in case sensor fails.
  • ❌ Not reviewing historical data: Weekly reviews reveal patterns you'd miss day-to-day.
  • ❌ Same thresholds for all crops: Tomatoes need more water than maize. Adjust per crop!
🎯 Key Takeaways:
  • ✅ Decision trees remove guesswork — follow simple rules for consistent results
  • ✅ Set alerts for critical conditions: temperature (>40°C), moisture (<30%), humidity (>70%)
  • ✅ Review historical data weekly to discover patterns you'd otherwise miss
  • ✅ Farmers using data-driven decisions save 30-50% water and increase yields 15-25%
  • ✅ Always add fail-safes (max run time) and time delays to prevent false alarms
  • ✅ Your action plan: Identify 3 parameters → Set thresholds → Review weekly → Adjust practices
💡 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.