# Build a Soil Moisture Detector Using Arduino

A complete guide to creating an affordable, automated system that monitors soil conditions and helps optimize watering schedules for healthier plants and water conservation.

## Project Team Members

| Name                      | PRN          |
|---------------------------|--------------|
| Aashray Lal Kayastha      | 25070122005  |
| Abhishek Singh            | 25070122012  |
| Abishek Yadav             | 25070122014  |
| Aditya Barnwal            | 25070122019  |
| Aditya Kumar Mandal       | 25070122022  |

## Project Statement

To design a low-cost Arduino-based system that detects soil moisture levels and alerts the user to help prevent overwatering and underwatering. Soil moisture monitoring matters because plants need consistent water to support healthy roots, nutrient absorption, and overall growth.

This project addresses a common gardening challenge by checking actual soil conditions instead of relying on guesswork or fixed schedules. Using an Arduino and a basic moisture sensor, it offers an affordable alternative to commercial smart watering systems while keeping the build simple and beginner-friendly.

## Project Objectives

- **Measure Soil Moisture**  
  Use a hygrometer sensor to accurately detect moisture levels in soil through electrical conductivity measurement.
- **Monitor Soil Conditions**  
  Continuously track whether soil is dry, moist, or wet to maintain optimal growing conditions for plants.
- **Provide Visual & Audio Alerts**  
  Utilize LED and buzzer to deliver immediate notifications when soil moisture drops below desired levels.
- **Efficient Water Usage**  
  Prevent over-watering and conserve water resources by watering plants only when necessary.
- **Low-Cost Solution**  
  Develop a simple, affordable system that's accessible to hobbyists, students, and home gardeners.

## Components Required

- **Arduino Uno**  
  Microcontroller board for processing sensor data and controlling outputs.
- **Soil Moisture Sensor**  
  Hygrometer module with probes to measure soil conductivity.
- **LED**  
  Visual indicator for dry soil condition (red or green).
- **Buzzer**  
  Audio alert when soil is too dry.
- **Resistor (220Ω)**  
  Protects LED from excessive current.
- **Jumper Wires**  
  Male-to-male wires for connecting components.
- **Breadboard**  
  Prototyping platform for temporary circuit assembly.
- **USB Cable**  
  Connects Arduino to computer for programming and power.

## Arduino Program Code

```cpp
// Pin Definitions
int sensorPin = A0; // Soil moisture sensor
int ledPin = 7; // LED indicator
int buzzerPin = 8; // Buzzer

int sensorValue = 0;

void setup() {
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    pinMode(buzzerPin, OUTPUT);
    Serial.println("Soil Moisture Detection System");
}

void loop() {
    sensorValue = analogRead(sensorPin);
    Serial.print("Moisture Value: ");
    Serial.println(sensorValue);

if (sensorValue < 300) {
        Serial.println("Status: DRY SOIL");
        digitalWrite(ledPin, HIGH);
        digitalWrite(buzzerPin, HIGH);
    }
    else if (sensorValue >= 300 && sensorValue < 700) {
        Serial.println("Status: MOIST SOIL");
        digitalWrite(ledPin, LOW);
        digitalWrite(buzzerPin, LOW);
    }
    else {
        Serial.println("Status: WET SOIL");
        digitalWrite(ledPin, LOW);
        digitalWrite(buzzerPin, LOW);
    }

Serial.println("------------------------");
    delay(1000);
}
```

## Block Diagram

## Circuit Diagram

## Circuit Connections

- **Soil Moisture Sensor → Arduino**  
  - VCC → 5V pin  
  - GND → GND pin  
  - AO → Analog Pin A0  
- **LED → Arduino**  
  - Positive leg → Digital Pin 7  
  - Negative leg → GND (through 220Ω resistor)  
- **Buzzer → Arduino**  
  - Positive leg → Digital Pin 8  
  - Negative leg → GND pin

## Working Principle

The soil moisture sensor operates on the principle of electrical conductivity. When the probes are inserted into soil, they measure the resistance between them. Water conducts electricity, so wet soil creates lower resistance and produces higher analog values, while dry soil creates higher resistance and lower values.

1. **Probes Inserted**  
   Two metal probes are placed into the soil at the desired depth  
2. **Conductivity Measured**  
   Electrical current flows between probes, resistance indicates moisture level  
3. **Analog Signal Generated**  
   Sensor converts resistance to analog voltage (0-5V)  
4. **Arduino Reads Value**  
   analogRead() function converts voltage to digital value (0-1023)  
5. **Threshold Comparison**  
   Code compares value against predefined ranges for dry, moist, wet conditions  
6. **Output Activation**  
   LED and buzzer trigger when soil is dry (below 300)  
7. **Serial Monitoring**  
   Real-time values and status updates displayed on computer serial monitor

## Output Conditions & Thresholds

- **Dry Soil**  
  **Value Range:** 0 - 300  
  LED turns ON and buzzer sounds to alert that immediate watering is needed  
- **Moist Soil**  
  **Value Range:** 300 - 700  
  Normal condition, LED and buzzer remain OFF. Soil has adequate moisture  
- **Wet Soil**  
  **Value Range:** 700 - 1023  
  LED and buzzer OFF. Soil is saturated, no additional watering required

**Note:** Threshold values can be adjusted based on testing with your specific soil type and sensor. Calibrate by testing in known dry and wet conditions.

## Challenges & Limitations

- **Sensor Corrosion**  
  Probes may rust or corrode over time when exposed to moisture and soil minerals. Regular cleaning or using stainless steel probes can extend sensor life.
- **Calibration Required**  
  Different soil types (clay, sand, loam) have varying conductivity. Calibration testing in your specific soil is necessary for accurate readings.
- **Accuracy Issues**  
  Fertilizers, salts, and minerals in soil can affect conductivity readings. Organic matter and temperature also influence results.
- **Power Consumption**  
  Continuous operation requires constant power. For long-term deployment, consider battery power with sleep modes or solar charging.
- **Signal Fluctuation**  
  Analog values may vary slightly due to electrical noise. Implement averaging in code to smooth readings and reduce false alerts.

## Advantages & Next Steps

- **Simple & Low-Cost**  
  Uses affordable, readily available components totaling under $15  
- **Easy to Build**  
  Beginner-friendly project requiring no soldering or complex tools  
- **Water Conservation**  
  Prevents over-watering and promotes sustainable gardening practices  
- **Future Enhancements**  
  - Add LCD display for standalone monitoring without computer  
  - Implement automatic irrigation system with relay and water pump  
  - Connect to IoT platform for remote monitoring via smartphone  
  - Add data logging to track moisture trends over time  
  - Use multiple sensors for different plant zones

**This soil moisture detector provides a practical foundation for smart gardening and can evolve into more sophisticated automated systems.**

## Conclusion

This Arduino soil moisture detector offers an affordable and practical way to automate plant care while helping conserve water by ensuring plants are only watered when they truly need it. It is also an excellent learning project for understanding electronics, sensors, microcontrollers, and basic automation, making it valuable for students, hobbyists, and makers alike. In real-world use, it can support healthier plant growth, reduce manual maintenance, and inspire smarter home gardening solutions, while also serving as a strong foundation for more advanced smart gardening systems with features like automatic irrigation, data logging, and IoT monitoring.

## Project Photos
