OC
OceanRemote
Low-code IoT platform
โ† Back to Course

Calibrating Sensors for Different Soil Types

Calibrating Sensors for Different Soil Types

๐Ÿ”ง Calibrating Sensors for Different Soil Types - One Size Does NOT Fit All

๐Ÿ”ง What You'll Learn:

  • ๐ŸŒพ Understand why sandy and clay soils need different moisture thresholds
  • ๐Ÿ“Š Learn Field Capacity, Wilting Point, and Available Water for 5 soil types
  • โš™๏ธ Write soil-specific code that adjusts thresholds automatically
  • ๐Ÿ’ง Save water by irrigating based on YOUR soil type, not generic rules

A sandy soil at 30% moisture is already dry and needs water. A clay soil at 30% moisture is still wet and does NOT need water. Using the same threshold for all soil types wastes water or causes drought stress. This lesson teaches you how to calibrate your system for YOUR specific soil.

๐Ÿ“Š Soil Type Characteristics

Soil Type Field Capacity (%) Wilting Point (%) Available Water (%) Drainage Rate Water When Below (%)
๐Ÿœ๏ธ Sandy20-25%5-10%15%Very Fast15-20%
๐Ÿชจ Sandy Loam25-35%10-15%20%Fast20-25%
๐ŸŒพ Loam (Ideal)35-45%15-20%25%Medium25-30%
๐Ÿงด Clay Loam45-55%25-30%25%Slow30-35%
๐Ÿงฑ Clay55-65%30-35%30%Very Slow35-40%
๐Ÿ’ก Understanding the Numbers:
  • Field Capacity (FC): Maximum water soil can hold after draining. Above this = waterlogged.
  • Wilting Point (WP): Below this = plants permanently wilt and die. Never go below!
  • Available Water = FC - WP: Water that plants can actually use.
  • Water When Below: Ideal threshold to start irrigation (50% of available water depleted).

๐ŸŒพ How to Identify Your Soil Type

  • Squeeze Test (Wet soil): Take a handful of moist soil and squeeze.
  • ๐Ÿœ๏ธ Sandy: Falls apart immediately, feels gritty. Water drains fast - water frequently.
  • ๐Ÿชจ Sandy Loam: Forms a weak ball, breaks apart easily. Good drainage, moderate watering.
  • ๐ŸŒพ Loam: Forms a ball that holds together, breaks when poked. IDEAL - balanced watering.
  • ๐Ÿงด Clay Loam: Forms a strong ball, feels smooth. Slow drainage - water less frequently.
  • ๐Ÿงฑ Clay: Forms a tight, sticky ball that stays together. Very slow drainage - water rarely.
โš ๏ธ Common Mistake - Same Threshold for All Soils:
  • โŒ Using 30% threshold for sandy soil โ†’ Plant wilts (sandy soil at 30% is almost dry)
  • โŒ Using 30% threshold for clay soil โ†’ Over-watering, root rot (clay soil at 30% is still wet)
  • โœ… Fix: Sandy needs 15-20% threshold; clay needs 35-40% threshold

๐Ÿ“– Soil-Specific Threshold Code

/*
 * Soil-Specific Irrigation Thresholds
 * Adjust watering based on your soil type
 */

#include <Arduino.h>

#define SOIL_PIN 32

// ========== SOIL TYPE SELECTION ==========
// Uncomment YOUR soil type:
// String soilType = "Sandy";
// String soilType = "Sandy Loam";
String soilType = "Loam";          // Default - change to your soil
// String soilType = "Clay Loam";
// String soilType = "Clay";

// ========== SOIL CALIBRATION VALUES ==========
// Replace these with YOUR sensor's calibrated values
const int DRY_VALUE = 3800;   // Value in dry air
const int WET_VALUE = 1500;   // Value in water

// ========== GET SOIL-SPECIFIC THRESHOLDS ==========
int getWaterThreshold() {
    if (soilType == "Sandy") return 20;
    if (soilType == "Sandy Loam") return 25;
    if (soilType == "Loam") return 30;
    if (soilType == "Clay Loam") return 35;
    if (soilType == "Clay") return 40;
    return 30;  // Default
}

int getCriticalThreshold() {
    if (soilType == "Sandy") return 10;      // Wilting point ~10%
    if (soilType == "Sandy Loam") return 15;
    if (soilType == "Loam") return 20;
    if (soilType == "Clay Loam") return 30;
    if (soilType == "Clay") return 35;
    return 20;
}

int getFieldCapacity() {
    if (soilType == "Sandy") return 25;
    if (soilType == "Sandy Loam") return 35;
    if (soilType == "Loam") return 45;
    if (soilType == "Clay Loam") return 55;
    if (soilType == "Clay") return 65;
    return 45;
}

// ========== READ SOIL MOISTURE ==========
int readSoilMoisture() {
    int raw = analogRead(SOIL_PIN);
    int moisture = map(raw, DRY_VALUE, WET_VALUE, 0, 100);
    moisture = constrain(moisture, 0, 100);
    return moisture;
}

// ========== GET RECOMMENDATION ==========
String getRecommendation(int moisture) {
    int threshold = getWaterThreshold();
    int critical = getCriticalThreshold();
    int fc = getFieldCapacity();
    
    if (moisture <= critical) {
        return "๐Ÿšจ CRITICAL: Soil extremely dry! Water IMMEDIATELY!";
    } else if (moisture < threshold) {
        return "๐Ÿ’ง SOIL DRY: Start irrigation within 24 hours";
    } else if (moisture <= fc) {
        return "โœ… OPTIMAL: Soil moisture adequate";
    } else if (moisture > fc) {
        return "โš ๏ธ SOIL WET: Stop irrigation. Risk of over-watering";
    }
    return "Monitor conditions";
}

// ========== SETUP ==========
void setup() {
    Serial.begin(115200);
    pinMode(SOIL_PIN, INPUT);
    
    Serial.println("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—");
    Serial.println("โ•‘              ๐Ÿ”ง SOIL-SPECIFIC IRRIGATION SYSTEM              โ•‘");
    Serial.println("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•");
    
    Serial.printf("\n๐ŸŒพ Soil Type: %s\n", soilType.c_str());
    Serial.printf("๐Ÿ’ง Water threshold: %d%%\n", getWaterThreshold());
    Serial.printf("๐Ÿšจ Critical threshold: %d%%\n", getCriticalThreshold());
    Serial.printf("๐Ÿ’ง Field Capacity: %d%%\n", getFieldCapacity());
    Serial.println("");
}

// ========== LOOP ==========
void loop() {
    int moisture = readSoilMoisture();
    int threshold = getWaterThreshold();
    int critical = getCriticalThreshold();
    
    Serial.println("โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”");
    Serial.printf("๐Ÿ“Š Soil Moisture: %d%%\n", moisture);
    Serial.printf("๐ŸŽฏ %s threshold: %d%%\n", soilType.c_str(), threshold);
    Serial.printf("๐Ÿ’š %s\n", getRecommendation(moisture).c_str());
    
    // Decision logic
    if (moisture < threshold) {
        if (moisture < critical) {
            Serial.println("๐Ÿ”ด ACTION: EMERGENCY irrigation required NOW!");
        } else {
            Serial.println("๐ŸŸก ACTION: Schedule irrigation for today");
        }
        // startIrrigation();
    } else if (moisture > getFieldCapacity()) {
        Serial.println("๐ŸŸข ACTION: Stop irrigation - soil too wet");
    } else {
        Serial.println("โœ… ACTION: No irrigation needed - monitor");
    }
    
    Serial.println("โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n");
    
    delay(60000);  // Check every minute
}
    
๐Ÿ“– Case Study - The Same Threshold Disaster:

A farmer used 30% threshold for both sandy and clay fields:

  • ๐Ÿœ๏ธ Sandy field (30% threshold): Plants constantly wilted - watered too late
  • ๐Ÿงฑ Clay field (30% threshold): Plants developed root rot - watered too often
  • โœ… Fix: Sandy threshold = 20%, Clay threshold = 40%
  • ๐Ÿ“ˆ Result: Both fields recovered, water usage dropped 35%

"Same number meant completely different things to different soils. Now I treat each field separately." - Farmer, Nigeria

๐Ÿ’ก How to Determine YOUR Soil's Water Threshold:
  • 1. Find Field Capacity: Water thoroughly, wait 24 hours, measure moisture. That's your FC.
  • 2. Find Wilting Point: Let plants wilt naturally (or research for your crop). That's your WP.
  • 3. Available Water = FC - WP.
  • 4. Start watering at: FC - (Available Water ร— 0.5)
  • Example: FC=45%, WP=20%, Available=25%. Start watering at 45% - (25% ร— 0.5) = 32.5%
๐ŸŽฏ Key Takeaways:
  • โœ… Sandy soils need lower thresholds (15-20%) - water frequently, small amounts
  • โœ… Clay soils need higher thresholds (35-40%) - water rarely, deep watering
  • โœ… Loam is ideal (25-30% threshold) - best for most crops
  • โœ… Field Capacity = STOP watering; Wilting Point = CRITICAL
  • โœ… Always configure your soil type in code - one threshold does NOT fit all
  • โœ… Adjust thresholds based on crop growth stage (seedlings need more water)
๐Ÿ’ก 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.