MyRoboPathOpen Robotics Lab
Arduino Uno #21 of 35
Est. 0.5 Hours
Budget: $2 - $4
Beginner

Soil Moisture Sensor & Smart Plant Hydration Monitor

Measure volumetric soil wetness with corrosion-saving pulsed excitation to automate indoor plant watering alerts.

Keep houseplants thriving by sensing soil moisture directly with an Arduino Uno. Wire the dual-prong soil probe and LM393 comparator module, convert raw ADC values into 0–100% moisture percentages, and power the probe only during brief 20ms readings to prevent galvanic electrode corrosion!

Arduino Uno R3Soil Moisture ProbePulsed Excitation10-Bit ADC (A0)Smart Agriculture
Soil Moisture Sensor & Smart Plant Hydration Monitor Blueprint
Soil Moisture Sensor & Smart Plant Hydration MonitorCAD Blueprint

Key Learning Objectives & Robotics Concepts

By building and programming this project, you will master the following core engineering skills:

1Understand how water dissolved ions lower soil electrical resistance between probe forks.
2Prevent galvanic probe oxidation using switched GPIO excitation instead of constant 5V.
3Calibrate real-world dry-air (~1000) and damp-soil (~300) ADC endpoints into intuitive 0–100% hydration.
4Trigger hydration alerts with hysteresis so watering transitions cleanly.

Power Architecture & Voltage Staging

5V / 3.3V Regulated Power

Instead of continuously energizing the copper soil forks from 5V (which electroplates them in days), we drive module VCC from Arduino pin D7 (<15mA) for just 20ms every 2 seconds. Powering the probe from digital pin D7 only during 20ms measurements extends probe lifespan by >50× by halting DC electrolysis!

Soil Moisture Sensor & Smart Plant Hydration Monitor Power Architecture Schematic
Figure: Regulated Arduino Uno supply rails, current budget, and component protection.Power Schematic

Bill of Materials (BOM) & Hardware Components

Bill of Materials for Soil Moisture Sensor & Smart Plant Hydration Monitor
ComponentSpecifications & AlternativeQtyApprox Cost
Arduino Uno R3ATmega328P @ 16MHz1$8.00
Soil Moisture Sensor Probe + LM393 ModuleResistive dual-prong probe + analog/digital breakout1$1.80
5mm Blue/Red LED + 220Ω ResistorLow-moisture plant alert indicator1$0.15
Breadboard & Jumper Wires6× breadboard jumpers1$2.00

Electrical & System Architecture

Connect the 2-pin soil fork to the LM393 amplifier board. Wire amplifier VCC to D7 (switched power), GND to GND, AO to A0, and a Dry-Soil alert LED (+220Ω) to D8.

Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Soil Moisture Sensor & Smart Plant Hydration Monitor.
Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Soil Moisture Sensor & Smart Plant Hydration Monitor.Wiring Schematic

Autonomous Behavior & Finite State Machine (FSM)

Deterministic Arduino loop handling Soil Moisture Fork Probe + LM393 Board acquisition, filtering, and real-time output updates.

Figure: Firmware execution flow and state transitions for Soil Moisture Sensor & Smart Plant Hydration Monitor.
Figure: Firmware execution flow and state transitions for Soil Moisture Sensor & Smart Plant Hydration Monitor.Control Algorithm

Step-by-Step Physical Assembly & Wiring Tutorial

Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.

1

Connect Soil Fork to LM393 Interface Board

Duration: 5 Mins

Link the two-prong fork probe to the 2-pin side of the comparator module (non-polarized).

Soil Moisture Sensor & Smart Plant Hydration Monitor hardware layout diagram
Stage 1: Soil Moisture Fork Probe + LM393 Board hardware inspection & pinout overview.Stage 1 Diagram
Step Action Checklist:
  • Use two Female-to-Female jumpers to join the soil fork to the 2-pin header on the LM393 PCB.
  • Never submerge the top white wire solder joints of the fork in water—insert only the lower plated prongs into soil.
  • Identify the 4-pin Arduino side: VCC, GND, DO, AO.
Engineering & Tuning Tip: For long-term outdoor gardens, you can also swap in a capacitive v1.2 soil sensor using the exact same A0 code!
2

Wire Switched Power (D7) & Analog Input (A0)

Duration: 5 Mins

Power the sensor cleanly from D7 so firmware toggles it on only when measuring.

Soil Moisture Sensor & Smart Plant Hydration Monitor breadboard wiring check diagram
Stage 2: Breadboard layout & Arduino Uno pin-to-pin wiring audit.Stage 2 Diagram
Step Action Checklist:
  • Connect Soil Module VCC → D7, GND → GND, and AO → A0.
  • Wire D8 → 220Ω resistor → Alert LED anode → cathode to GND.
  • Connect USB power to the Arduino Uno.
Engineering & Tuning Tip: The module draws ~10mA during measurement—well below D7's 20mA recommended limit.
3

Calibrate Dry vs. Wet ADC Endpoints

Duration: 5 Mins

Record raw ADC in dry air and dipped in a cup of damp soil to tune DRY_ADC and WET_ADC.

Soil Moisture Sensor & Smart Plant Hydration Monitor power rail protection diagram
Stage 3: Supply rail check (Switched D7 Excitation (5V pulsed 20ms)) and circuit protection verification.Stage 3 Diagram
Step Action Checklist:
  • Upload the production sketch and open Serial Monitor.
  • Note raw ADC in dry air (typically 980–1023).
  • Insert prongs 3cm into damp potting soil and note raw ADC (typically 280–450).
Engineering & Tuning Tip: Notice the inverse relationship: HIGHER raw ADC means DRIER soil!
4

Verify Anti-Corrosion Pulsed Operation

Duration: 5 Mins

Watch the module's red power LED flash briefly once every 2 seconds as measurements occur.

Soil Moisture Sensor & Smart Plant Hydration Monitor serial telemetry verification diagram
Stage 4: Firmware upload & 115200 baud Serial Monitor verification.Stage 4 Diagram
Step Action Checklist:
  • Observe the sensor's power LED pulsing briefly on each reading.
  • Confirm Serial Monitor prints calibrated 0–100% Moisture cleanly.
  • Verify D8 Alert LED lights when prongs sit in dry air/soil and turns off in moist soil.
Engineering & Tuning Tip: In real indoor planters, polling once every 60 seconds keeps probes corrosion-free for months.
5

Test Hydration Recovery

Duration: 5 Mins

Pour a spoonful of water near the dry soil test pot and watch % moisture climb live.

Soil Moisture Sensor & Smart Plant Hydration Monitor live operational logic diagram
Stage 5: Live operational logic flow & calibration verification.Stage 5 Diagram
Step Action Checklist:
  • Insert probe into dry potting mix and verify Alert LED turns ON.
  • Add a small amount of water and watch Moisture % jump above 50%.
  • Confirm Alert LED extinguishes automatically.
Engineering & Tuning Tip: Wipe the metal prongs dry with a tissue after bench testing before storing your starter kit.

Subsystem Benchtop Verification Scripts

Test each hardware subsystem independently before deploying the full autonomous firmware.

1Bench Diagnostic: Soil Moisture Fork Probe + LM393 Board Hardware Check

Subsystem Diagnostic

Minimal standalone sketch to verify pin wiring and signal response for Soil Moisture Fork Probe + LM393 Board before running the full project firmware.

Arduino IDE Diagnostic ScriptC++ / Arduino
// Diagnostic: Pulsed Soil Raw ADC Check
void setup() { pinMode(7, OUTPUT); Serial.begin(115200); }
void loop() {
  digitalWrite(7, HIGH); delay(20);
  int raw = analogRead(A0);
  digitalWrite(7, LOW);
  Serial.print("Soil Raw ADC: "); Serial.println(raw);
  delay(1500);
}
Expected Output: Prints ~1010 in dry air and ~320 in damp soil while flashing sensor LED briefly.

Complete Production Firmware

Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.

arduino_uno_soil_moisture_irrigation_monitor.ino
arduino_uno_soil_moisture_irrigation_monitor.inoArduino C++
/**
 * Project 21: Anti-Corrosion Soil Moisture Hydration Monitor
 * Board: Arduino Uno R3 | Pins: D7 (Switched VCC), A0 (AO), D8 (Dry Alert LED)
 */
const uint8_t PROBE_PWR_PIN = 7;
const uint8_t SOIL_AO_PIN   = A0;
const uint8_t ALERT_LED     = 8;

const int DRY_ADC = 1000; // Calibrated dry soil reading
const int WET_ADC = 300;  // Calibrated saturated soil reading
const int THIRST_PCT = 35;

int readSoilRaw() {
  digitalWrite(PROBE_PWR_PIN, HIGH);
  delay(25); // Allow divider to settle
  long sum = 0;
  for (uint8_t i = 0; i < 4; i++) { sum += analogRead(SOIL_AO_PIN); delay(5); }
  digitalWrite(PROBE_PWR_PIN, LOW); // Cut power to prevent electrolysis
  return sum / 4;
}

void setup() {
  pinMode(PROBE_PWR_PIN, OUTPUT);
  digitalWrite(PROBE_PWR_PIN, LOW);
  pinMode(ALERT_LED, OUTPUT);
  Serial.begin(115200);
  Serial.println(F("Smart Soil Hydration Monitor Ready"));
}

void loop() {
  int raw = readSoilRaw();
  int moisturePct = constrain(map(raw, DRY_ADC, WET_ADC, 0, 100), 0, 100);
  bool needsWater = (moisturePct < THIRST_PCT);

  digitalWrite(ALERT_LED, needsWater ? HIGH : LOW);

  Serial.print(F("Raw ADC: ")); Serial.print(raw);
  Serial.print(F(" | Moisture: ")); Serial.print(moisturePct);
  Serial.print(F("% | Status: "));
  Serial.println(needsWater ? F("DRY - WATER PLANT!") : F("HYDRATED"));
  delay(2000);
}

Firmware Architecture Explanation:

  • Switches module power on D7 for just 45ms per 2-second cycle (<2.5% duty) to prevent fork corrosion.
  • Maps inverted resistance readings (high=dry, low=wet) into intuitive 0–100% soil moisture.
  • Illuminates D8 alert LED whenever soil hydration drops below 35%.

Operational Verification & Pin State Matrix

1Double-check all 4 Arduino Uno pin connections against the wiring schematic before plugging in USB.
2Upload the Bench Diagnostic sketch first and confirm Serial Monitor at 115200 baud matches: Prints ~1010 in dry air and ~320 in damp soil while flashing sensor LED briefly.
3Upload the complete production sketch and verify every condition in the operational truth table below.

Input Signal vs. System Output Truth Table:

Operational truth table for Soil Moisture Sensor & Smart Plant Hydration Monitor
Input / StatePin / SignalDetected ConditionExpected Output
Moisture < 35%A0 > 755 ADCDry SoilD8 Alert LED ON (Water Plant)
Moisture ≥ 35%A0 ≤ 755 ADCAdequately MoistD8 Alert LED OFF (Hydrated)

Engineering Troubleshooting Matrix

Engineering troubleshooting matrix for Soil Moisture Sensor & Smart Plant Hydration Monitor
ProblemLikely CauseDiagnostic CheckEngineering Solution
Always reads 0% even in waterSoil fork jumpers unplugged from LM393 board or D7 power wire looseVerify sensor power LED blinks every 2 secondsCheck both fork leads and confirm VCC connects to D7.
Readings fluctuate wildlyLoose soil air pockets around prongsPress soil gently around the forkSeat prongs firmly into uniform soil depth.
Probe forks turn dark/corroded quicklyModule wired permanently to 5V instead of pulsed D7Verify VCC wire lands on D7Use switched D7 excitation or upgrade to a capacitive soil sensor.

Engineering Challenges & Upgrades

Take your build to the next level with these progressive engineering upgrades:

Level 13-LED Plant Mood Gauge

Show Red (<30% Dry), Green (30–75% Ideal), and Blue (>75% Overwatered).

Level 2Auto-Watering Pump Controller

Drive a 5V mini water pump via transistor/relay for 3 seconds whenever soil stays dry.

Level 3OLED Plant Health Screen

Render a happy or thirsty plant face on Project 4 OLED based on moisture %.