Skip to main content

Using a Soil Moisture Sensor

What is a Soil Moisture Sensor?

The Soil Moisture Sensor measures soil moisture grace to the changes in electrical conductivity of the earth (soil resistance increases with drought).

Wiring

Wiring up the sensors is simple:

  1. Power (VCC to 5V)
  2. Ground (GND to GND)
  3. Signal (SIG to A0)

soilcircuit.png

Getting started

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); 
}