Soil moisture sensor(YL-69) JP: 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: {{#seo:|title=アルドゥウィキ:アルドゥイーノ土壌水分センサー(YL-69)ガイド|title_mode=append|keywords=アルドゥイーノ, 情報科学, メーカー学習, パフォーマンス評価, 土壌水分センサー(YL-69), アルドゥイーノプロジェクト, キャップストーンプロジェクト, アルドゥイーノサンプルコード|description=アルドゥイーノで土壌水分センサー(YL-69)を制御する方法(基本...)
(차이 없음)

2025년 3월 26일 (수) 22:10 판


概要

土壌水分センサー(YL-69)は、土壌の水分含有量を測定するために使用されるセンサーです。農業、園芸、環境モニタリングなど様々な分野で活用され、作物の健康と生産性を維持するために重要な役割を果たします。アルドゥイーノなどのマイクロコントローラーと共に使用することで、リアルタイムで水分値をモニタリングすることができます。

動作原理

YL-69センサーは、2つの電極を使用して土壌の電気伝導度を測定します。土壌の水分含有量が高くなるほど抵抗値が低くなり、それに伴って電気伝導度が増加します。この値はアナログ信号に変換されてマイクロコントローラーに送信されます。

仕様

List 説明
感度調整 PCBに取り付けられた可変抵抗器を回して感度調整が可能
Voltage 3.3V - 5V
Output Mode デジタル出力とアナログ出力の両方をサポート

デジタル出力: しきい値を超えるとLOW、それ以外はHIGHを出力 アナログ出力: 0 〜 1023の間の値を出力

設置の容易さ 固定ボルト穴があり、設置が容易
Size PCB: 3cm x 1.6cm

プローブ部:約2cm x 6cm

電源および出力表示 電源表示灯(赤)およびデジタルスイッチ出力表示灯(緑)
Chip LM393


Usage Example

1. Checking Soil Moisture Sensor Output Values via Serial Monitor

You can check the analog output values through the serial monitor.


1-1. Circuit Configuration

The YL-69 soil moisture sensor supports both digital and analog outputs, consisting of a total of 4 pins: VCC, GND, DO, and AO.

In the circuit diagram, if digital output is needed, connect the DO pin; if analog output is needed, connect the AO pin to the Arduino.

In this example, we require an analog output, so the AO pin is connected to the A0 pin of the Arduino.

YL-69 Pin Arduino
VCC 5V
GND GND
AO A0

1-2. Arduino Code

const int sensorPin = A0;

void setup() {
    Serial.begin(9600); // Start serial communication
}

void loop() {
    int sensorValue = analogRead(sensorPin); // Read sensor value
    Serial.print("Soil moisture level : "); 
    Serial.println(sensorValue); // Print sensor value
    delay(1000); // Wait a second
}


1-3. Execution Result


2. Displaying Soil Moisture Sensor Value and Water Supply Necessity on LCD

This example displays the analog output value of the soil moisture sensor on an LCD and indicates whether water supply is necessary based on that value.

For more detailed information about the LCD, please refer to the LCD(Liquid Crystal Display) document.


2-1. Circuit Configuration

YL-69 Pin Arduino LCD Pin Arduino
VCC 5V VCC 5V
GND GND GND GND
AO A0 SCA A4(Uno) / 20(Mega)
SCL A5(Uno) / 21(Mega)


2-2. Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// I2C LCD initialization: address 0x27, columns 16, rows 2
LiquidCrystal_I2C lcd(0x27, 16, 2);

// YL-69 sensor pin definition
const int sensorPin = A0;

void setup() {
    lcd.init();
    lcd.clear();
    lcd.backlight(); // Turn on backlight
    Serial.begin(9600); // Start serial communication
}

void loop() {
    int sensorValue = analogRead(sensorPin); // Read sensor value
    Serial.print("Soil moisture level: ");
    Serial.println(sensorValue); // Output to serial monitor

    // Display value on LCD
    lcd.clear(); // Clear LCD screen
    lcd.setCursor(0, 0); // Move cursor to the first column of the first row
    lcd.print("water : ");
    lcd.print(sensorValue); // Output sensor value
    lcd.setCursor(0, 1); // Move cursor to the first column of the second row
    if (sensorValue > 500)
      lcd.print("Please Water");
    else
      lcd.print("Enough Water");

     delay(1000); // Wait for 1 second
}


2-3. Execution Result

When there is no moisture, "Please Water" is displayed on the LCD.


On the other hand, when there is moisture, "Enough Water" is displayed.


3. Utilizing Soil Moisture Sensor with LCD and LED

This example adds an LED to the previous example so that a blue light turns on when there is sufficient moisture, while the LED turns off when moisture is lacking, indicating the need for water.


==== 3-1. Circuit Configuration ====

3-2. Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// I2C LCD initialization: address 0x27, columns 16, rows 2
LiquidCrystal_I2C lcd(0x27, 16, 2);

// YL-69 sensor pin definition
const int sensorPin = A0;
const int ledPin = 3;

void setup() {
    lcd.init();
    lcd.clear();
    lcd.backlight(); // Turn on backlight
    Serial.begin(9600); // Start serial communication
    pinMode(ledPin, OUTPUT);
}

void loop() {
    int sensorValue = analogRead(sensorPin); // Read sensor value
    Serial.print("Soil moisture level: ");
    Serial.println(sensorValue); // Output to serial monitor

    // Display value on LCD
    lcd.clear(); // Clear LCD screen
    lcd.setCursor(0, 0); // Move cursor to the first column of the first row
    lcd.print("water : ");
    lcd.print(sensorValue); // Output sensor value
    lcd.setCursor(0, 1); // Move cursor to the first column of the second row
    if (sensorValue > 500) {
        lcd.print("Please Water");
        digitalWrtie(ledPin, LOW); // Turn off the LED
    }
    else {
        lcd.print("Enough Water");  
        digitalWrtie(ledPin, HIGH); // Turn on the LED
    }

    delay(1000); // Wait a second
}

3-3. Execution Result

When there is no moisture, "Please Water" is displayed on the LCD, and the LED is turned off.


On the other hand, when there is moisture, "Enough Water" is displayed, and the LED is turned on.


In addition, if water pumps are used together, it can be applied to various projects such as automatic irrigation systems.


Purchase Link

GONGZIPSA