Soil Moisture Sensor with Arduino UNO

Soil Moisture Sensor with Arduino UNO
Atribot team

Written by

Atribot team

Last updated

June 18, 2026

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

Swipe right to view full table
Item NameQtyAction
1
Soil Moisture Sensor
1
USB Cable
1
Breadboard
1
Jumper Wires
1

Tools Required

Swipe right to view full table
Item NameAction
Soldering Iron
Screwdriver

Software Required

Swipe right to view full table
Item NameAction
Arduio IDE

Circuit Diagram

Soil Moisture Sensor with Arduino UNO Circuit connections
Soil Moisture Sensor with Arduino UNO Circuit connections

Source Code

Soil_Moisture_Sensor_with_Arduino_UNO.inocpp
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:

Swipe right to view full table

Soil Moisture Sensor

Arduino UNO

VCC

5V

GND

GND

A0

A0

Step 2: Open Arduino IDE

  1. Launch Arduino IDE.

  2. Connect Arduino UNO using USB.

  3. 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

  1. Open Serial Monitor.

  2. Set the baud rate to 9600.

  3. Insert the sensor probes into the soil.

  4. 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: 855

In moist soil:

Soil Moisture Value: 450
Soil Moisture Value: 420
Soil Moisture Value: 390

Lower 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.