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.
Precision agriculture drip systems, indoor automated garden planters, and greenhouse crop moisture management.
Electrical conductivity in soil increases with water content. Measuring the resistance between two probes yields an analog voltage inversely proportional to soil dryness.
Pin Connection & Wiring Table
| Component Pin / Terminal | Microcontroller Pin (ESP32 / Arduino) | Wiring Note |
|---|---|---|
| Sensor A0 | GPIO 32 / A1 | Analog soil reading |
| Sensor VCC | 3.3V | Power supply |
| Sensor GND | GND | Ground |
| Buzzer (+) | GPIO 19 | Audio alert signal |
| Buzzer (-) | GND | Ground |
Step-by-Step Plug & Play Assembly
Insert the sensor prongs into a small potted plant or cup of soil.
Connect sensor A0 to GPIO 32.
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);
}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
- •Probe corrosion: Clean probes after tests. Do not leave powered 24/7 in wet soil to avoid electrolysis corrosion.
- •Operate strictly on 3.3V-5V DC. Avoid splashing water onto the microcontroller board.
Related Book Chapter & Hardware Kit
Covered in depth within Chapter 6: Sensors and Their Applications. Build this easily with the Sensor Explorer Kit.