Wednesday, June 8, 2016

YL-69 Soil Moisture Sensor


The YL-69 (Probes) and the YL-38 (Interface) both make up a resistance sensor that is often used to measure soil moisture. The YL-38 acts as a middle man circuit or a bridge that connects the YL-69 sensor to the Arduino. It is fitted with a commonly used comparator LM393 and a digital potentiometer that can be used to alter the sensitivity of the sensor. There are four pins on the board that includes VCC (3.3/5V), GND, D0 (Digital Output) and A0 (Analog Output).

The digital output only produces HIGH or LOW value. In the circuit below, only the analog output is used in order to get a more accurate value. It connects to the Arduino analog input (A0). When the soil is dry, the resistance between the two electrodes or the sensor probes is high, the A0 port of the YL-38 bridge outputs a high level. When the two electrodes are in contact with water, more current will be passed across them. The analog port of the bridge produces low.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
void setup()
{
  Serial.begin(9600);
  pinMode(A0, INPUT);
}

void loop()
{
  int A0Value = analogRead(A0);
  Serial.print(A0Value); Serial.print(" - ");

  if(A0Value < 1000 && A0Value >= 700) { 
   Serial.println("Dry soil");
  }
  if(A0Value < 700 && A0Value >= 300) {
   Serial.println("Humid soil"); 
  }
  if(A0Value < 300) {
   Serial.println("In water");
  }
  delay(1000);
}

1 comment: