Free Nationwide Doorstep Delivery on orders over ₹499
← All 10 Projects•Intermediate•60 mins

Smart Plant Soil Moisture & Irrigation Prototype

Build an automated plant health assistant that checks soil dryness and sounds an alert or activates a pump prototype when water is needed.

Real-World Engineering Application

Precision agriculture drip systems, indoor automated garden planters, and greenhouse crop moisture management.

Physics & Working Principle

Electrical conductivity in soil increases with water content. Measuring the resistance between two probes yields an analog voltage inversely proportional to soil dryness.

Key Learning Outcome:Learn resistive soil sensor calibration, analog mapping (map() function), and multi-condition alert loops.

Pin Connection & Wiring Table

Component Pin / TerminalMicrocontroller Pin (ESP32 / Arduino)Wiring Note
Sensor A0GPIO 32 / A1Analog soil reading
Sensor VCC3.3VPower supply
Sensor GNDGNDGround
Buzzer (+)GPIO 19Audio alert signal
Buzzer (-)GNDGround

Step-by-Step Plug & Play Assembly

1

Insert the sensor prongs into a small potted plant or cup of soil.

2

Connect sensor A0 to GPIO 32.

3

Connect buzzer positive leg to GPIO 19 and negative leg to GND.

Complete Tested Source Code

// NovaCircuit Project 6: Smart Plant Monitor
const int MOISTURE_PIN = 32;
const int BUZZER_PIN = 19;
const int DRY_THRESHOLD = 2800; // High ADC value corresponds to dry soil

void setup() {
  Serial.begin(115200);
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.println("Smart Plant Monitoring Active");
}

void loop() {
  int rawMoisture = analogRead(MOISTURE_PIN);
  
  // Calculate moisture percentage (approximate calibration)
  // Completely dry in air ~3500; Wet in cup of water ~1200
  int moisturePercent = map(rawMoisture, 3500, 1200, 0, 100);
  moisturePercent = constrain(moisturePercent, 0, 100);
  
  Serial.print("Soil Moisture: ");
  Serial.print(moisturePercent);
  Serial.println("%");

  if (rawMoisture > DRY_THRESHOLD) {
    Serial.println("Alert: Soil is Dry! Please Water the Plant.");
    digitalWrite(BUZZER_PIN, HIGH);
    delay(200);
    digitalWrite(BUZZER_PIN, LOW);
  }

  delay(2000);
}
Code Logic Breakdown:

The code reads raw soil impedance, maps it to a calibrated 0-100% moisture scale, and sounds a short buzzer chirp whenever soil moisture drops below acceptable levels.

Expected Physical Output

Serial monitor displays live soil percentage. When probe is removed from moist soil, warning beeps alert the student.
Troubleshooting Tips
  • •Probe corrosion: Clean probes after tests. Do not leave powered 24/7 in wet soil to avoid electrolysis corrosion.
Electrical Safety Directives
  • •Operate strictly on 3.3V-5V DC. Avoid splashing water onto the microcontroller board.
Companion Resources

Related Book Chapter & Hardware Kit

Covered in depth within Chapter 6: Sensors and Their Applications. Build this easily with the Sensor Explorer Kit.