The Capacitive Soil Moisture Sensor M2 is a reliable and efficient device designed to measure the volumetric water content in soil. Unlike resistive soil moisture sensors, this capacitive sensor detects changes in soil capacitance, which varies with moisture levels. This design ensures better durability and resistance to corrosion, making it ideal for long-term use in agricultural, gardening, and environmental monitoring applications.
The Capacitive Soil Moisture Sensor M2 has a 3-pin interface. The table below describes each pin:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin. Connect to 3.3V or 5V. |
2 | GND | Ground pin. Connect to the ground of the power supply or microcontroller. |
3 | AOUT | Analog output pin. Provides a voltage proportional to the soil moisture level. |
Wiring the Sensor:
Placement:
Reading the Output:
The following code demonstrates how to read the sensor's analog output using an Arduino UNO and display the moisture level in the Serial Monitor.
// Define the analog pin connected to the sensor
const int sensorPin = A0;
void setup() {
// Initialize the Serial Monitor for debugging
Serial.begin(9600);
}
void loop() {
// Read the analog value from the sensor
int sensorValue = analogRead(sensorPin);
// Map the sensor value to a percentage (0% to 100%)
// Adjust the min and max values based on calibration
int moisturePercent = map(sensorValue, 1023, 300, 0, 100);
// Print the moisture level to the Serial Monitor
Serial.print("Soil Moisture: ");
Serial.print(moisturePercent);
Serial.println("%");
// Wait for 1 second before the next reading
delay(1000);
}
Inconsistent Readings:
No Output or Incorrect Values:
Sensor Not Responding:
Corrosion or Damage:
Q1: Can this sensor be used with a Raspberry Pi?
Yes, the sensor can be used with a Raspberry Pi. However, since the Raspberry Pi does not have built-in analog input pins, you will need an external ADC (Analog-to-Digital Converter) module to read the sensor's output.
Q2: How do I calibrate the sensor?
To calibrate, measure the sensor's output voltage in completely dry soil and fully saturated soil. Use these values to map the sensor's output to a percentage or other meaningful scale.
Q3: Is the sensor waterproof?
The sensor is water-resistant but not fully waterproof. Avoid submerging it in water for extended periods to prevent damage.
Q4: Can this sensor measure moisture in other materials?
The sensor is optimized for soil but may work with other porous materials. Calibration is required for accurate results.