Translate

Arduino Based Soil Moisture Monitor DIY

 Keeping houseplants alive can be a struggle. Whether you're an over-waterer or a forgetful plant parent, the solution lies in a bit of simple DIY electronics. In this guide, we’ll build a Smart Soil Moisture Monitor using an Arduino Uno. This project uses a traffic-light system (Red, Yellow, Green) to tell you exactly when your leafy friends need a drink.


The Components You’ll Need

To build this project, gather the following parts:

  • 1x Arduino Uno R3 (The "brain" of the operation)

  • 1x Soil Moisture Sensor (Resistive or Capacitive)

  • 3x LEDs (Red, Yellow, Green)

  • 3x 220Ω Resistors (To protect the LEDs)

  • 1x Breadboard & Jumper Wires

  • 1x USB Cable (To upload the code)


Circuit Wiring & Working

The circuit works by measuring the electrical resistance of the soil. Wet soil conducts electricity better than dry soil. The Arduino reads this "analog" signal and translates it into a digital status.

Diagram of Soil Moisture Monitor with Arduino


Step-by-Step Wiring:

  1. Sensor: Connect the VCC to 5V, GND to Ground, and the Signal (S/AO) pin to Analog Pin A0 on the Arduino.

  2. LEDs: Connect the long leg (Anode) of each LED to Arduino Digital Pins 2 (Red), 3 (Yellow), and 4 (Green).

  3. Resistors: Place a 220Ω resistor between the short leg (Cathode) of each LED and the GND rail.

  4. Power: The Arduino is powered via the USB port from your computer or a 9V battery.


The Code: Smart Watering Logic

Copy and paste this code into your Arduino IDE. It uses a simple "if-else" logic to determine which light to trigger based on the moisture level.

C++
/*
 * Project: Smart Soil Moisture Monitor
 * Description: Uses 3 LEDs to show plant hydration levels.
 */

const int sensorPin = A0;  // Soil sensor input
const int redLED = 2;     // "Thirsty"
const int yellowLED = 3;  // "Getting Dry"
const int greenLED = 4;   // "Happy Plant"

// Thresholds (Adjust these after testing your soil)
int dryLimit = 300; 
int wetLimit = 700;

void setup() {
  pinMode(redLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  Serial.begin(9600); // To see real-time values
}

void loop() {
  int moistureValue = analogRead(sensorPin);
  
  // Print value to Serial Monitor for calibration
  Serial.print("Soil Moisture Level: ");
  Serial.println(moistureValue);

  // Reset LEDs
  digitalWrite(redLED, LOW);
  digitalWrite(yellowLED, LOW);
  digitalWrite(greenLED, LOW);

  // Logic to light up the correct LED
  if (moistureValue < dryLimit) {
    digitalWrite(redLED, HIGH);   // RED = Needs Water
  } 
  else if (moistureValue >= dryLimit && moistureValue < wetLimit) {
    digitalWrite(yellowLED, HIGH); // YELLOW = Monitoring
  } 
  else {
    digitalWrite(greenLED, HIGH);  // GREEN = Healthy
  }

  delay(1000); // Take a reading every second
}

How the Code Works

  1. analogRead(A0): This function looks at the voltage coming from the sensor. It converts it to a number between $0$ and $1023$.

  2. Thresholding: We define two "border" numbers. If the value is below $300$, the Arduino identifies the soil as "Dry."

  3. Serial Communication: By using Serial.println, the Arduino sends the exact data to your computer screen, allowing you to see how different soil types affect the numbers.


Pro-Tips for Success

  • Calibration: Soil types vary! Sand, potting mix, and clay all hold water differently. Open your Serial Monitor (Ctrl+Shift+M), dip the sensor in water, and then pull it out to see your specific "Wet" and "Dry" ranges.

  • Corrosion Prevention: If using a cheap resistive sensor, the metal prongs will corrode over time. To fix this, only power the sensor when you are actually taking a reading by using a Digital Pin as a power source.

  • Permanent Housing: Once it works, consider 3D printing a small "mushroom" or "robot" case to house the electronics next to your plant!


Conclusion

Building a soil moisture monitor is a fantastic entry-level project that combines hardware, software, and nature. Not only do you learn the basics of analog sensing, but you also save your plants from a dry demise.

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.