Soil Moisture Sensor with Arduino UNO

Introduction
The Soil Moisture Sensor is a simple and widely used sensor for measuring the moisture level in soil. It is commonly used in smart irrigation systems, automatic plant watering projects, greenhouse monitoring, and agricultural automation applications.
In this tutorial, you will learn how to interface a Soil Moisture Sensor with an Arduino UNO, upload the code, and monitor soil moisture levels using the Serial Monitor. By the end of this guide, you'll understand how to detect dry and wet soil conditions for your Arduino projects.
Components Required
Tools Required
Software Required
| Item Name | Action |
|---|---|
Arduio IDE | Download |
Circuit Diagram
Source Code
const int moisturePin = A0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int moistureValue = analogRead(moisturePin);
Serial.print("Soil Moisture Value: ");
Serial.println(moistureValue);
delay(1000);
}Step by Step Instructions
Step 1: Connect the Soil Moisture Sensor
Make the following connections:
Soil Moisture Sensor | Arduino UNO |
|---|---|
VCC | 5V |
GND | GND |
A0 | A0 |
Step 2: Open Arduino IDE
Launch Arduino IDE.
Connect Arduino UNO using USB.
Select:
Board → Arduino UNO
Port → Correct COM Port
Step 3: Create a New Sketch
Create a new Arduino sketch and paste the provided code.
Step 4: Verify the Code
Click the Verify button to check for syntax errors.
Step 5: Upload the Code
Click Upload and wait until the upload process completes successfully.
Step 6: Open Serial Monitor
Open Serial Monitor.
Set the baud rate to 9600.
Insert the sensor probes into the soil.
Observe the moisture readings displayed on the screen.
The Serial Monitor will continuously display soil moisture values.
Expected Output
In dry soil:
Soil Moisture Value: 850
Soil Moisture Value: 840
Soil Moisture Value: 855In moist soil:
Soil Moisture Value: 450
Soil Moisture Value: 420
Soil Moisture Value: 390Lower values generally indicate wetter soil, while higher values indicate drier soil.
Conclusion
In this tutorial, you learned how to interface a Soil Moisture Sensor with Arduino UNO and measure soil moisture levels using analog readings. This setup can be used in smart irrigation systems, plant monitoring projects, greenhouse automation, and various agricultural applications.









