The Soil Moisture Sensor measures soil moisture grace to the changes in electrical conductivity of the earth (soil resistance increases with drought).
Wiring up the sensors is simple:
- Power (VCC to 5V)
- Ground (GND to GND)
- Signal (SIG to A0)
This example turns on the built-in LED when the soil is dry.
int sensorPin = A0;
int sensorValue;
int limit = 300; //300-600 is a good range of moisture generally
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print("Moisture Level: ");
Serial.println(sensorValue);
if (sensorValue < limit) {
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}
delay(100);
}