Component: Soil Moisture Sensor YL‐69 - Albin-Tenghagen/The-Fellowship-of-the-Code-Flood-checker GitHub Wiki
Component: Soil Moisture Sensor [YL-69]
Overview
The YL-69 Soil Moisture Sensor is designed to measure the moisture content of soil. It operates by detecting the resistance between its two probes: wetter soil conducts electricity better (lower resistance), while drier soil resists it (higher resistance). This sensor is commonly used in agriculture, gardening, and environmental monitoring to automate irrigation systems and ensure optimal soil conditions. It is a resistive soil moisture sensor.
Technical Specifications
Specification | Details |
---|---|
Operating Voltage | 3.3V – 5V DC |
Output Signals | Analog (AO) and Digital (DO) |
Comparator Chip | LM393 |
Sensitivity Adjustment | Via onboard potentiometer |
Probe Dimensions | ~60mm x 20mm |
PCB Dimensions | ~32mm x 14mm |
Pin Layout
The YL-69 has 4 pins and they work as described below: VCC Provides power to the sensor module. Typically connected to the 3.3V or 5V pin on your microcontroller.
GND Ground reference for the sensor module. Connects to the ground (GND) pin on your microcontroller or power source.
AO (Analog Output) Analog voltage output proportional to the soil moisture level. Connect this pin to an analog input on your microcontroller to read moisture values as a voltage.
DO (Digital Output) Digital output pin. Outputs HIGH or LOW depending on the moisture threshold set by the onboard potentiometer.
Potentiometer (on the sensor board) Adjusts the sensitivity threshold for the digital output (DO). Turning it changes the moisture level at which DO switches between HIGH and LOW.
Pin Name | Function | Typical Connection |
---|---|---|
VCC | Power supply (3.3V – 5V) | 5V or Digital Pin (Output)that gets activated when you should read values |
GND | Ground | GND |
A0 | Analog output from sensor | Analog Pin( Input) Reads the value from the sensor |
D0 | Digital output from sensor | Digital Pin (Input) Reads the value from the sensor |
Operating Principle
The sensor consists of two parts:
-
Probe: Inserted into the soil to measure moisture levels.
-
Control Board: Contains the LM393 comparator and a potentiometer to set the threshold for the digital output.
- Analog Output (AO): Provides a voltage proportional to the soil moisture level. This can be read by an analog input on a microcontroller.
- Digital Output (DO): Outputs HIGH or LOW based on the threshold set by the potentiometer. When soil moisture exceeds the set threshold, the output changes state.
Typical Usage
- Analog Mode: Connect AO to an analog input on your microcontroller to get precise moisture readings.
- Digital Mode: Connect DO to a digital input to get a simple HIGH/LOW signal indicating whether the soil is wet or dry based on the set threshold.
Note: The potentiometer adjusts the sensitivity for the digital output. Turning it changes the threshold at which the digital output switches state.
Example Wiring with Arduino
YL-69 Sensor Module Arduino
------------------- -------
VCC 5V
GND GND
AO A0
DO D2 (optional)
Sample Code (Analog Reading)
int sensorPin = A0; // Analog input pin
int sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print("Soil Moisture: ");
Serial.println(sensorValue);
delay(1000);
}
Considerations
- Corrosion: The probes can corrode over time, especially if left in moist soil continuously. It's advisable to remove the sensor when not in use or consider using capacitive sensors for long-term applications. It is preferably to apply the VCC to the sensor through a digital pin that you can switch on and off to decrease the chance of corrosion as much as you can if you want to use a resistive soil moisture sensor.
- Calibration: Different soil types may yield different readings. Calibrate the sensor for your specific soil conditions to get accurate measurements. How to calibrate a soil Moisture sensor and How to dry soil correctly for calibrationtests
Sorces:
Last minute engineers
Greensense
Help the engineer
Datasheet for YL-69
Random nerds tutorial