Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 921 Bytes

File metadata and controls

42 lines (31 loc) · 921 Bytes

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)

image

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