Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Project 21: Soil Sensor

Introduction

The Soil Moisture Sensor measures the volumetric water content in soil.
It outputs analog values that change depending on how wet or dry the soil is.
With Arduino, you can monitor these values to automate watering systems or trigger alerts.
In this tutorial, we’ll learn how to connect and read values from the sensor.

Required Components

  • Arduino Board (e.g., Arduino Uno)
  • Soil Sensor
  • Jumper Wires
  • Breadboard (optional)

Pinout

Circuit Diagram / Wiring

  • Soil Sensor VCC → 5V (Arduino)
  • Soil Sensor GND → GND (Arduino)
  • Soil Sensor Analog → A0 (Arduino)

Programming With Arduino

  • Copy the provided code into your Arduino IDE.
#define MoisturePin A0 
 
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  // Read the analog value from the soil moisture sensor
  int soilMoistureValue = analogRead(MoisturePin);
 
  // Print the soil moisture value to the Serial Monitor
  Serial.print("Soil Moisture Level: ");
  Serial.print(soilMoistureValue);
  Serial.print("%");
  Serial.println(); 
  delay(1000);
}

Explanation

  • analogRead(MoisturePin) reads the moisture level from the sensor connected to pin A0.
  • The value is printed to the Serial Monitor as a percentage (though it’s raw data; mapping may be needed for real %).
  • A 1-second delay (delay(1000)) controls how often the sensor reads and prints data.

Troubleshooting

  • If you get constant 0 or 1023, check the sensor’s connection to A0, 5V, and GND.
  • Make sure the sensor probes are properly inserted into the soil and not corroded.
  • Use a multimeter to verify voltage output from the sensor if readings seem stuck.

    Leave a Reply

    Your email address will not be published.

    Need Help?