4

members

Easy Basics: Project 036a Soil Moisture Sensor YL-69, FC-28 or HL-69

of Acoptex.com in UNO

Basics: Project 036a

Project name: Soil Moisture Sensor YL-69, FC-28 or HL-69

Tags: Arduino, Soil Moisture Sensor YL-69, FC-28 or HL-69

Attachments: soilmoisturesketch

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Arduino Uno R3 (you can also use the other version of Arduino)

2.Arduino IDE ( you can download it from here  )

3.Jumper cables F-M

4. Soil Moisture Sensor YL-69, FC-28 or HL-69 1 pc

General

Have you ever wanted your plants to tell you when they need watered? Or know how saturated the soil in your garden is?

The moisture sensor allows to monitor the water content in the soil. This is useful if you want to build an automatic watering system. You can also use it to just monitor your plants soil moisture.

We will learn how to connect soil moisture sensor YL-69, FC-28 or HL-69 to Arduino board and use it.

Understanding the soil moisture sensor YL-69, FC-28 or HL-69

The soil moisture sensor or the hygrometer is usually used to detect the humidity of the soil. So, it is perfect to build an automatic watering system or to monitor the soil moisture of your plants. The sensor consists of two pieces: the electronic board and the probe with two pads, that detects the water content.

One commonly known issue with soil moisture sensors is their short lifespan when exposed to a moist environment. To combat this, some of them have done the PCB coated in Gold Finishing. Another way to extend the lifespan of your sensor is to only power it when you take a reading or delay the sensor reading (for example take readings every 10 mins). Using a digital pin set to HIGH on an Arduino, for example, is an easy way to accomplish this. If you wish to power the sensor with more than a digital pin on your microcontroller can provide, you could always use a transistor.

The sensor gives us both analog and digital output, so it can be used in both analog and digital mode.

It has a built-in potentiometer for sensitivity adjustment of the digital output (D0), a power LED and a digital output LED, as you can see in the following figure.

How does it work

The soil moisture sensor consists of two probe's pads which are used to measure the Volumetric content of water. The two probe's pads allow the current to pass through the soil and then it gets the resistance value to measure the moisture value. It can cause corrosion across the probe pads. 

When there is water, the soil will conduct more electricity which means that there will be less resistance. Therefore, the moisture level will be higher. Dry soil conducts electricity poorly, so when there is less water, then the soil will conduct less electricity which means that there will be more resistance. Therefore, the moisture level will be lower. Your analog readings will vary depending on what voltage you use for VCC as well as the resolution of your ADC pins.

Weatherproofing

If you intend to use this sensor outdoors, we recommend adding a little protection to the PCB to extend its lifespan. You could always use good ol' fashioned hot glue. However, hot glue does not hold up well in the sun and is only recommended for projects that will not be exposed to high temperatures. For projects that need to be able to withstand all the elements, you could use a conformal coating to cover the SMD parts on the PCB as well as your solder connections.

Calibration

System Calibration

To get any sort of useful data out of your Soil Moisture Sensor, it is advised that you calibrate it to whatever soil you plan to monitor. Different types of soil can affect the sensor, and you may get different readings from one composition tot he next. Before you start storing moisture data or triggering events based on that value, you should see what values you are actually getting from your sensor. Using the sketch above, note what values your sensor outputs when the sensor is completely dry vs when the sensor is completely submerged in a shallow cup of water. Depending on what microcontoller you’re using, the operating voltage of that microcontoller, and the resolution of its analog-to-digital converter, you’re results will vary. Thus, it is difficult to write an example sketch that works for all platforms. It really depends on the operating voltage and ADC resolution of the board you’re using.

Soil Calibration

Once you have an idea what values your sensor is outputting in completely dry and completely wet situations, it’s time to calibrate your sensor for the specific soil you want to monitor. Do the same test above, only this time test your soil when it is as dry as possible, then measure it when the soil is completely saturated with moisture. Getting these values and comparing them to the ones from the previous calibration will give you the best insight into what values mean for your specific plant and soil. This test may take some trial and error and patience. Be careful not to over-water (or under-water) your plants during these tests.

Once you have a good handle on the values you can expect, you can use the map() function to adjust your code accordingly.

Specification:

  • Sensitivity is adjustable via the blue digital potentiometer
  • Operating voltage 3.3V-5V
  • Module dual output mode: digital output or analog output giving more accuracy
  • Has pre-drilled hole for easy installation
  • Small board PCB size: 3cm * 1.6cm
  • Power indicator (red) and digital switching output indicator (green)
  • Uses the LM393 comparator chip

Signals and connections of the soil moisture sensor YL-69, FC-28 or HL-69

VCC (5V)  - connect to 3.3 V or 5V pin of Arduino board. 

GND (or G) - ground pin of Arduino board

SIG - an analog signal out that can be attached to the ADC pin on any microcontroller. The value read on SIG will vary depending on the voltage with which you power the sensor

D0 - Digital output to Arduino board

A0 - Analog output to Arduino board

The "A0", is a serial signal 0-5 volts that when fully dry it outputs 5 volts, when fully wet, 0 volts. The "D0", is configured with the trim pot and is brought high when the moisture level reaches a desired point.

Build the circuit

The following picture shows the needed connections with the Arduino Uno 

Code

The output can be a digital signal (D0) LOW or HIGH, depending on the water content. If the soil humidity exceeds a certain predefined threshold value, the modules outputs LOW, otherwise it outputs HIGH. The threshold value for the digital signal can be adjusted using the potentiometer.

The output can be a analog signal and so you’ll get a value between 0 and 1023. Please note that the analog value returned will vary depending on what voltage is provided for the sensor.

Map function used to specify the moisture limits: 100% - very wet, 0% - very dry.

Step by Step instruction

  1. Do wiring.
  2. Insert the soil moisture sensor probe to the soil.
  3. Open Arduino IDE.
  4. Plug your Adruino Uno board into your PC and select the correct board and com port
  5. Open up serial monitor and set your baud to 9600 baud
  6. Verify and upload the the sketch to your Adruino Uno board.
  7. Open the Arduino IDE serial monitor to see the values. Then, try your sensor in a wet and in a dry soil and see what happens. When the analog value goes above a certain threshold, a message will be shown that the plant needs watering and when the value goes below a certain threshold a message will be printed that the  plant is ok.

Summary

We have learnt how to connect soil moisture sensor YL-69, FC-28 or HL-69 to Arduino board and use it.

Library:

  • No libraries required for this project

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Acoptex.com
Easy CBASIC Lesson 9 Compiling and debugging in Visual Studio of Acoptex.com in Csharp 10-04-2019
Easy Raspberry basics: Project 00a Getting started with Raspberry Pi of Acoptex.com in Raspberry Pi 3 06-04-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 20-10-2017
Viewed: 4813 times