Project tutorial

Using the YL-39 + YL-69 Soil Humidity Sensor with Arduino © LGPL

Here is how to use the YL-39 + YL-69 soil humidity sensor with any Arduino.

  • 25,399 views
  • 6 comments
  • 16 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
soil humidity sensor
×1

Apps and online services

About this project

I plan to do an automation for our greenhouse so I started small, by playing first with the sensors that I need. Here is how to use the YL-39 (logic) + YL-69 (probe) pair that form the soil humidity sensor.

The YL-39 module has 4 pins: 

- VCC: 3.3-5V

- GND

- A0 : analog output that can be easily read by Arduino

- D0 :  digital pin that goes LOW or HIGH depending on a preset value

The issue with such sensors is that the probe itself work by trying to measure the current that goes from one side of it to the other. Because of this electrolysis occurs so it can destroy the probe (YL-69) pretty fast in high-moisture soils. To bypass this, instead of directly linking the VCC to the Arduino's VCC/5V we simply link it to a digital pin and power it (digital pin goes HIGH) only before we do a readout (see the code for this).

To connect it to the Arduino you just need to connect A0 from YL-39 to A1 from the Arduino and VCC from YL-39 to digital pin 6 from the Arduino.

That's all.

Code

humidity_sensor_yl_39_69.inoArduino
// YL-39 + YL-69 humidity sensor
byte humidity_sensor_pin = A1;
byte humidity_sensor_vcc = 6;

void setup() {
  // Init the humidity sensor board
  pinMode(humidity_sensor_vcc, OUTPUT);
  digitalWrite(humidity_sensor_vcc, LOW);

  // Setup Serial
  while (!Serial);
  delay(1000);
  Serial.begin(9600);
}

int read_humidity_sensor() {
  digitalWrite(humidity_sensor_vcc, HIGH);
  delay(500);
  int value = analogRead(humidity_sensor_pin);
  digitalWrite(humidity_sensor_vcc, LOW);
  return 1023 - value;
}

void loop() {
  Serial.print("Humidity Level (0-1023): ");
  Serial.println(read_humidity_sensor()); 
  delay(10000);
}

Schematics

yl-39.fzz
yl-39.fzz

Comments

Similar projects you might like

A Microwave Interface for the IKEA Duktig Kids Kitchen

Project showcase by Myles Eftos

  • 1,308 views
  • 8 comments
  • 7 respects

Servo Signals and Characterization

by 3 developers

  • 1,030 views
  • 4 comments
  • 13 respects

Music Adaptive RGB LED with Arduino and Processing

Project in progress by ounane mohamed elfarouk

  • 997 views
  • 6 comments
  • 10 respects

Cellular IoT with Blynk & Hologram

by Moheeb Zara

  • 5,027 views
  • 9 comments
  • 18 respects

Monitoring Temperature Remotely with Blynk for Dummies

Project in progress by Cmtelesann

  • 1,224 views
  • 2 comments
  • 4 respects

How to Make a Customizable Punchable Keyboard Button

Project tutorial by Amal Mathew

  • 1,528 views
  • 4 comments
  • 4 respects
Add projectSign up / Login