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

아두위키 : Arduwiki
(새 문서: {{#seo:|title=アルドゥウィキ:アルドゥイーノ土壌水分センサー(YL-69)ガイド|title_mode=append|keywords=アルドゥイーノ, 情報科学, メーカー学習, パフォーマンス評価, 土壌水分センサー(YL-69), アルドゥイーノプロジェクト, キャップストーンプロジェクト, アルドゥイーノサンプルコード|description=アルドゥイーノで土壌水分センサー(YL-69)を制御する方法(基本...)
 
 
(같은 사용자의 중간 판 하나는 보이지 않습니다)
40번째 줄: 40번째 줄:




== '''Usage Example''' ==
== '''利用例''' ==


=== 1. Checking Soil Moisture Sensor Output Values via Serial Monitor ===
=== 1. 土壌水分センサーの出力をシリアルモニタで確認する ===
You can check the analog output values through the serial monitor.
この例では、シリアルモニタを通じてセンサーのアナログ出力値を確認します。




==== 1-1. Circuit Configuration ====
==== 1-1. 回路構成 ====
The YL-69 soil moisture sensor supports both digital and analog outputs, consisting of a total of 4 pins: VCC, GND, DO, and AO.
YL-69土壌水分センサーはデジタル出力とアナログ出力を両方サポートしており、VCC、GND、DO、AOの4つのピンで構成されています。アナログ出力が必要な場合は、AOピンをアドゥイーノのA0ピンに接続します。
 
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.
{| class="wikitable"
{| class="wikitable"
!YL-69 Pin
!YL-69 Pin
84번째 줄: 80번째 줄:




==== 1-3. Execution Result ====
==== 1-3. 実行結果 ====
[[파일:토양수분센서yl69예제1실행결과.jpg|가운데|class=coders100]]
[[파일:토양수분센서yl69예제1실행결과.jpg|가운데|class=coders100]]




=== 2. Displaying Soil Moisture Sensor Value and Water Supply Necessity on LCD ===
=== 2. 土壌水分センサーの値と給水必要性を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.
この例では、土壌水分センサーのアナログ出力値をLCDに表示し、その値に基づいて給水が必要かどうかもLCDに表示します。


For more detailed information about the LCD, please refer to the [[LCD(Liquid Crystal Display)]] document.
LCDについての詳細は、[[LCD(Liquid Crystal Display) JP|LCD(Liquid Crystal Display)]]ドキュメントを参照してください。




==== 2-1. Circuit Configuration ====
2-1. 回路構成
{| class="wikitable"
{| class="wikitable"
!YL-69 Pin
!YL-69 Pin
126번째 줄: 122번째 줄:




==== 2-2. Arduino Code ====
==== 2-2. アルドゥイーノコード ====
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#include <Wire.h>
#include <Wire.h>
165번째 줄: 161번째 줄:




==== 2-3. Execution Result ====
==== 2-3. 実行結果 ====
When there is no moisture, "Please Water" is displayed on the LCD.
水がない場合、LCDに「Please Water」が表示されます。


[[파일:토양수분센서yl69예제2실행결과수분X.jpg|가운데|class=coders100]]
[[파일:토양수분센서yl69예제2실행결과수분X.jpg|가운데|class=coders100]]




 
水がある場合、「Enough Water」が表示されます。
On the other hand, when there is moisture, "Enough Water" is displayed.


[[파일:토양수분센서yl69예제2실행결과수분O.jpg|가운데|class=coders100]]
[[파일:토양수분센서yl69예제2실행결과수분O.jpg|가운데|class=coders100]]




=== 3. Utilizing Soil Moisture Sensor with LCD and LED ===
=== 3. 土壌水分センサーとLCD、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.
この例では、前の例にLEDを追加します。土壌が乾燥しているときはLEDが消え、十分な水があるときはLEDが点灯します。




==== 3-1. Circuit Configuration ====[[파일:토양수분센서YL69예제3회로.jpg|가운데|class=coders100]]
==== 3-1. 回路構成 ====
[[파일:토양수분센서YL69예제3회로.jpg|가운데|class=coders100]]


==== 3-2. Arduino Code ====
==== 3-2. Arduino Code ====
227번째 줄: 223번째 줄:
</syntaxhighlight>
</syntaxhighlight>


==== 3-3. Execution Result ====
==== 3-3. 実行結果 ====
When there is no moisture, "Please Water" is displayed on the LCD, and the LED is turned off.
水がない場合、LCDに「Please Water」が表示され、LEDが消えます。


[[파일:토양수분센서yl69예제3실행결과수분X.jpg|가운데|class=coders100]]
[[파일:토양수분센서yl69예제3실행결과수분X.jpg|가운데|class=coders100]]




On the other hand, when there is moisture, "Enough Water" is displayed, and the LED is turned on.
水がある場合、「Enough Water」が表示され、LEDが点灯します。


[[파일:토양수분센서yl69예제3실행결과수분O.jpg|가운데|class=coders100]]
[[파일:토양수분센서yl69예제3실행결과수분O.jpg|가운데|class=coders100]]




In addition, if water pumps are used together, it can be applied to various projects such as automatic irrigation systems.
このセットアップは、ポンプなどの他のコンポーネントを組み込むことで自動給水システムなどに応用できます。
 
 
== '''Purchase Link''' ==
[https://gongzipsa.com/shop/1699939374 GONGZIPSA]

2025년 3월 26일 (수) 22:15 기준 최신판


概要

土壌水分センサー(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


利用例

1. 土壌水分センサーの出力をシリアルモニタで確認する

この例では、シリアルモニタを通じてセンサーのアナログ出力値を確認します。


1-1. 回路構成

YL-69土壌水分センサーはデジタル出力とアナログ出力を両方サポートしており、VCC、GND、DO、AOの4つのピンで構成されています。アナログ出力が必要な場合は、AOピンをアドゥイーノのA0ピンに接続します。

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. 実行結果


2. 土壌水分センサーの値と給水必要性をLCDに表示する

この例では、土壌水分センサーのアナログ出力値をLCDに表示し、その値に基づいて給水が必要かどうかもLCDに表示します。

LCDについての詳細は、LCD(Liquid Crystal Display)ドキュメントを参照してください。


2-1. 回路構成

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. アルドゥイーノコード

#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. 実行結果

水がない場合、LCDに「Please Water」が表示されます。


水がある場合、「Enough Water」が表示されます。


3. 土壌水分センサーとLCD、LEDを使用する

この例では、前の例にLEDを追加します。土壌が乾燥しているときはLEDが消え、十分な水があるときはLEDが点灯します。


3-1. 回路構成

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. 実行結果

水がない場合、LCDに「Please Water」が表示され、LEDが消えます。


水がある場合、「Enough Water」が表示され、LEDが点灯します。


このセットアップは、ポンプなどの他のコンポーネントを組み込むことで自動給水システムなどに応用できます。