

The Soil Moisture Sensor is a device designed to measure the volumetric water content in soil. It provides real-time data that can be used for irrigation management, plant health monitoring, and agricultural automation. By detecting the moisture level in the soil, this sensor helps optimize water usage and ensures plants receive adequate hydration.








The Soil Moisture Sensor typically consists of two probes that measure the resistance of the soil, which correlates to its moisture level. Below are the key technical details:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.3V - 5V |
| Operating Current | < 20mA |
| Output Type | Analog and Digital |
| Analog Output Voltage | 0V (dry soil) to 4.2V (wet soil) |
| Digital Output | High (wet) / Low (dry) |
| Dimensions | ~60mm x 20mm x 5mm |
| Probe Material | Corrosion-resistant metal |
The Soil Moisture Sensor module typically has four pins:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin (3.3V - 5V) |
| 2 | GND | Ground pin |
| 3 | A0 | Analog output pin (provides a voltage proportional to soil moisture level) |
| 4 | D0 | Digital output pin (provides a HIGH or LOW signal based on a threshold value) |
Connect the Sensor to a Microcontroller:
VCC pin to the 5V pin of the microcontroller (e.g., Arduino UNO).GND pin to the ground (GND) of the microcontroller.A0 pin to an analog input pin (e.g., A0 on Arduino UNO) for reading moisture levels.D0 pin to a digital input pin if you want to use the digital output.Insert the Probes into the Soil:
Calibrate the Sensor:
Read the Output:
A0) for precise moisture level readings.D0) for simple wet/dry detection.// Soil Moisture Sensor Example Code for Arduino UNO
// This code reads both analog and digital outputs from the sensor
// and displays the results in the Serial Monitor.
const int analogPin = A0; // Analog pin connected to A0 of the sensor
const int digitalPin = 7; // Digital pin connected to D0 of the sensor
const int ledPin = 13; // LED pin to indicate soil dryness
void setup() {
pinMode(digitalPin, INPUT); // Set digital pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Read analog value from the sensor
int analogValue = analogRead(analogPin);
// Read digital value from the sensor
int digitalValue = digitalRead(digitalPin);
// Print the analog value to the Serial Monitor
Serial.print("Analog Value: ");
Serial.println(analogValue);
// Print the digital value to the Serial Monitor
Serial.print("Digital Value: ");
Serial.println(digitalValue);
// Turn on the LED if the soil is dry (digital output is LOW)
if (digitalValue == LOW) {
digitalWrite(ledPin, HIGH);
Serial.println("Soil is dry! LED ON.");
} else {
digitalWrite(ledPin, LOW);
Serial.println("Soil is wet! LED OFF.");
}
delay(1000); // Wait for 1 second before the next reading
}
Inconsistent Readings:
Corrosion of Probes:
No Output from the Sensor:
Digital Output Always HIGH or LOW:
Can the sensor be used outdoors?
How do I extend the lifespan of the sensor?
What is the difference between analog and digital outputs?
Can I use this sensor with a Raspberry Pi?