

The Moisture Sensor Module is a device designed to measure the moisture level in soil or other materials. It provides both analog and digital outputs, making it versatile for a wide range of applications. The module is commonly used in agricultural automation, gardening systems, and environmental monitoring to determine soil moisture levels and automate irrigation systems.








The Moisture Sensor Module typically consists of two main parts: the sensor probe and the control board. Below are the key technical details:
The Moisture Sensor Module typically has a 4-pin interface. Below is the pinout:
| Pin Name | Description |
|---|---|
| VCC | Power supply input (3.3V to 5V) |
| GND | Ground connection |
| A0 | Analog output pin (provides a voltage proportional to the moisture level) |
| D0 | Digital output pin (provides HIGH or LOW based on the set threshold) |
Connect the Module:
VCC pin to a 3.3V or 5V power source.GND pin to the ground of your circuit.A0 pin to an analog input pin on your microcontroller (e.g., Arduino).D0 pin to a digital input pin if you want to use the threshold-based output.Adjust the Sensitivity:
D0).Insert the Sensor Probe:
Read the Output:
A0 pin using an ADC (Analog-to-Digital Converter) on your microcontroller.D0 pin for HIGH or LOW signals.Below is an example of how to use the Moisture Sensor Module with an Arduino UNO:
// Define pin connections
const int analogPin = A0; // Analog output pin connected to A0
const int digitalPin = 2; // Digital output pin connected to D2
const int ledPin = 13; // LED pin to indicate dry soil
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 moistureLevel = analogRead(analogPin);
// Print the moisture level to the Serial Monitor
Serial.print("Moisture Level (Analog): ");
Serial.println(moistureLevel);
// Read digital value from the sensor
int digitalState = digitalRead(digitalPin);
// Check if the soil is dry (digital output LOW)
if (digitalState == LOW) {
digitalWrite(ledPin, HIGH); // Turn on LED if soil is dry
Serial.println("Soil is dry!");
} else {
digitalWrite(ledPin, LOW); // Turn off LED if soil is moist
Serial.println("Soil is moist.");
}
delay(1000); // Wait for 1 second before the next reading
}
No Output from the Sensor:
Inaccurate Readings:
Corrosion of the Sensor Probe:
Digital Output Always HIGH or LOW:
Q: Can the sensor be used outdoors?
A: Yes, but it is recommended to use a waterproof and corrosion-resistant probe for outdoor applications.
Q: How do I know if the soil is dry or moist?
A: Use the digital output (D0) for a simple dry/moist indication or the analog output (A0) for precise moisture level readings.
Q: Can I use this sensor with a 3.3V microcontroller?
A: Yes, the sensor operates at 3.3V to 5V, making it compatible with 3.3V microcontrollers like ESP32 or 5V microcontrollers like Arduino UNO.
Q: How do I prevent corrosion of the probe?
A: Use a corrosion-resistant probe or coat the existing probe with a protective layer, such as waterproof paint or epoxy.
By following this documentation, you can effectively integrate the Moisture Sensor Module into your projects and ensure reliable performance.