The Soil Moisture Module is an electronic sensor designed to measure the moisture level in soil, providing a means to gauge the water content in the ground. This sensor is commonly used in gardening, agriculture, and landscaping to optimize irrigation schedules, conserve water, and promote healthy plant growth. By monitoring soil moisture, users can automate watering systems to activate only when necessary, thus preventing over or under-watering of plants.
Pin | Description |
---|---|
VCC | Connect to 3.3V or 5V power supply |
GND | Connect to ground |
AOUT | Analog output voltage, proportional to soil moisture |
DOUT | Digital output, high/low moisture threshold |
// Define the soil moisture sensor analog pin
const int MOISTURE_SENSOR_PIN = A0;
void setup() {
// Initialize serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Read the value from the moisture sensor
int sensorValue = analogRead(MOISTURE_SENSOR_PIN);
// Convert the analog reading to a more familiar percentage
int moisturePercent = map(sensorValue, 0, 1023, 100, 0);
// Print the moisture level to the Serial Monitor
Serial.print("Soil Moisture Level: ");
Serial.print(moisturePercent);
Serial.println("%");
// Wait for a second before reading again
delay(1000);
}
Q: Can the sensor be left in the soil permanently? A: It's not recommended to leave the sensor in the soil permanently due to potential corrosion. Remove it when not in use and clean it regularly.
Q: Is the sensor waterproof? A: The sensor probe is water-resistant but the electronic components are not. Avoid getting the module's board wet.
Q: How do I calibrate the sensor for my soil type? A: Insert the sensor into the soil, slowly adjust the potentiometer until the digital output switches from high to low, or use a known moisture reference and adjust the potentiometer until the analog output matches the reference.
Q: What is the difference between AOUT and DOUT? A: AOUT provides an analog voltage proportional to the soil moisture level, while DOUT provides a digital signal that indicates whether the moisture level is above or below a set threshold.