Non-contact Water Level Sensor(XKC-Y25): 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: {{#seo:|title=아두위키 : 아두이노 비접촉 수위 센서(XKC-Y25) 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, 비접촉 수위 센서(XKC-Y25), 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 비접촉 수위 센서(XKC-Y25)를 제어하는 방법(기본정보, 회로, 예제 코드)을 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}} 파일:비...)
 
잔글편집 요약 없음
1번째 줄: 1번째 줄:
{{#seo:|title=아두위키 : 아두이노 비접촉 수위 센서(XKC-Y25) 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, 비접촉 수위 센서(XKC-Y25), 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 비접촉 수위 센서(XKC-Y25)를 제어하는 방법(기본정보, 회로, 예제 코드)을 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}}
{{#seo:|title=Arduwiki : Arduino Non-contact Water Level Sensor(XKC-Y25) Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Assessment, Non-contact Water Level Sensor(XKC-Y25), Arduino Project, Capstone Project, Arduino Example Code|description=This introduces how to control a Non-contact Water Level Sensor(XKC-Y25) with Arduino (basic information, circuit, example code). It can be used in Information Science and Maker classes.}}
[[파일:비접촉_수위센서_xkcy25.jpg|가운데|클래스=coders100]]
비접촉식 수위 센서는 탱크나 용기 외부에 부착하여 내부의 액체 수위를 측정할 수 있는 장치입니다.


물에 직접 닿지 않기 때문에 안정적으로 오래 사용할 수 있으며 다양한 용기'''(금속 제외)''' 및 액체에 활용 가능합니다.
[[파일:비접촉_수위센서_xkcy25.jpg|가운데|class=coders100]]


== '''사양''' ==
A non-contact level sensor is a device that can be attached to the outside of a tank or container to measure the liquid level inside.
 
Since it does not come into direct contact with water, it can be used reliably for a long time and is applicable to various containers '''(excluding metal)''' and liquids.
 
 
== '''Specifications''' ==
{| class="wikitable"
{| class="wikitable"
!특성
!Characteristics
!XKC-Y25-V
!XKC-Y25-V
!XKC-Y25-PNP
!XKC-Y25-PNP
13번째 줄: 16번째 줄:
!XKC-Y28-RS485
!XKC-Y28-RS485
|-
|-
|'''전원 전압'''
|'''Power Voltage'''
|DC 5-24V
|DC 5-24V
|DC 5-12V, DC 24V
|DC 5-12V, DC 24V
|DC 5-12V, DC 24V
|DC 5-12V, DC 24V
|24V (12V 맞춤형 가능)
|24V (12V Customizable)
|-
|-
|'''출력 모드'''
|'''Output Mode'''
|High and low level
|High and low level
|Switch quantity (high pulse effective)
|Switch quantity (high pulse effective)
25번째 줄: 28번째 줄:
|Communication output
|Communication output
|-
|-
|'''리플 전압 요구 사항'''
|'''Ripple Voltage Requirements'''
| colspan="4" |≤200 mV
| colspan="4" |≤200 mV
|-
|-
|'''전류'''
|'''Current'''
| colspan="4" |≤5mA
| colspan="4" |≤5mA
|-
|-
|'''응답 시간'''
|'''Response Time'''
| colspan="4" |500mS
| colspan="4" |500mS
|-
|-
|'''작동 온도'''
|'''Operating Temperature'''
| colspan="4" | -20~105℃
| colspan="4" | -20~105℃
|-
|-
|'''습도'''
|'''Humidity'''
| colspan="4" |5%~100%
| colspan="4" |5%~100%
|-
|-
|'''측정 두께 (민감도 범위)'''
|'''Measurement Thickness (Sensitivity Range)'''
| colspan="4" |≤20mm (컨테이너 벽 두께)
| colspan="4" |≤20mm (Container Wall Thickness)
|-
|-
|'''수위 오차범위'''
|'''Water Level Tolerance Range'''
| colspan="4" |±1.5mm
| colspan="4" |±1.5mm
|-
|-
|'''선 길이'''
|'''Wire length'''
| colspan="4" |500MM (±10MM) (대량 주문 시 커스터마이징 가능)
| colspan="4" |500MM (±10MM)
|-
|-
|'''단자 순서'''
|'''Terminal Order'''
| colspan="4" |갈색 (VCC), 노랑 (신호 출력), 파랑 (GND), 검정 (COM 단자)
| colspan="4" |Brown (VCC), Yellow (Signal Output), Blue (GND), Black (COM)
|-
|-
|'''재질'''
|'''Material'''
| colspan="4" |PC V0 방염 소재
| colspan="4" |PC V0 Flame Retardant Material
|-
|-
|'''방수 성능'''
|'''Waterproof Performance'''
| colspan="4" |IP67
| colspan="4" |IP67
|-
|-
|'''안전 표준 인증'''
|'''Safety Standard Certification'''
| colspan="4" |CE
| colspan="4" |CE
|-
|-
|'''환경 보호 인증'''
|'''Environmental Protection Certification'''
| colspan="4" |ROHS-2.0
| colspan="4" |ROHS-2.0
|}
|}
모델에 따라 전압 및 출력 모드에 차이가 있으며, 본 문서를 XKC-Y25-NPN 모델을 기준으로 합니다.
There are differences in voltage and output modes depending on the model, and this document is based on the XKC-Y25-NPN model.


== '''활용 예제''' ==


=== 1. 단순 측정 테스트 ===
== '''Usage Example''' ==
용기 외부에 비접촉 수위 센서를 갖다 대었을 때 정확하게 측정하고 있는지 확인하는 예제입니다.


==== 회로 구성 ====
=== 1. Simple Measurement Test ===
센서 선은 수축 튜브를 살짝 당겨보시면 확인 가능합니다.
This is an example of verifying whether the non-contact level sensor accurately measures when placed outside the container.
 
 
==== Circuit Configuration ====
You can check the sensor wire by gently pulling on the shrink tube.
{| class="wikitable"
{| class="wikitable"
!센서 선 색상
!Sensor Wire Color
!기능
!Function
!아두이노 핀
!Arduino Pin
|-
|-
|갈색
|Brown
|VCC (전원 공급)
|VCC  
|5V
|5V
|-
|-
|파란색
|Blue
|GND (접지)
|GND  
|GND
|GND
|-
|-
|노란색
|Yellow
|OUT (출력 신호)
|OUT  
|D2
|D2
|-
|-
|검정색
|Black
|SET (설정)
|SET ()
|연결하지 않음 (또는 설정용)
|Not Connected (or for Configuration)
|}
|}
[[파일:Xkcy25_예제1_회로.png|가운데|클래스=coders100]]
[[파일:Xkcy25_예제1_회로.png|가운데|class=coders100]]


==== 코드 ====
==== Code ====
사양 탭에서 보여드린 대로 모델에 따라 출력모드가 달라 수위 감지 시에 HIGH, LOW 중 어느 쪽이 출력되는지 확인이 필요합니다.
As shown in the specifications tab, the output mode varies depending on the model, so it is necessary to check whether HIGH or LOW is output when detecting the water level.


본 문서에서 사용한 XKC-Y25-NPN 모델의 경우 수위가 감지되면 LOW가 출력됩니다.<syntaxhighlight lang="c++" line="1">
In the case of the XKC-Y25-NPN model used in this document, LOW is output when the water level is detected.
const int sensorPin = 2; // 센서 출력 핀
 
<syntaxhighlight lang="c++" line="1">
const int sensorPin = 2; // Sensor Output Pin
int sensorValue = 0;
int sensorValue = 0;


void setup() {
void setup() {
   pinMode(sensorPin, INPUT_PULLUP); // 내부 풀업 저항 활성화
   pinMode(sensorPin, INPUT_PULLUP); // Activate INPUT_PULLUP Resistor
   Serial.begin(9600);
   Serial.begin(9600);
}
}
110번째 줄: 117번째 줄:
void loop() {
void loop() {
   sensorValue = digitalRead(sensorPin);
   sensorValue = digitalRead(sensorPin);
   if (sensorValue == LOW) { // 모델에 따라 수위 감지시 LOW, HIGH가 다르게 출력될 수 있으니 확인 필요
   if (sensorValue == LOW) { // Depending on the model, LOW or HIGH may be output differently when detecting the water level, so verification is necessary.
     Serial.println("수위 감지됨");
     Serial.println("Water Level Detected");
   } else {
   } else {
     Serial.println("수위 감지되지 않음");
     Serial.println("Water Level Not Detected");
   }
   }
   delay(1000); // 1초 간격으로 측정
   delay(1000); // Measure at 1-second Interval
}
}
</syntaxhighlight>
</syntaxhighlight>


==== 실행 결과 ====
 
수위 감지 시에 xkc-y25 센서에 내장된 LED가 켜지는 것을 확인할 수 있습니다.
==== Execution Result ====
[[파일:Xkcy25_예제1_시리얼모니터.png|가운데|클래스=coders100]]
You can observe that the LED built into the XKC-Y25 sensor lights up when the water level is detected.
[[파일:Xkcy25_예제1_시리얼모니터.png|가운데|class=coders100]]
<div class="coders70">
<div class="coders70">
<youtube> 7P-8_H-TWTM </youtube>
<youtube> 7P-8_H-TWTM </youtube>
</div>
</div>


=== 2. 비접촉 수위센서와 LED 함께 사용 ===
수위 감지되면 LED가 켜지고, 감지되지 않으면 꺼지는 예제입니다.


비슷한 방법으로 부저, 워터펌프 등 다양한 모듈, 센서들을 혼합해서 사용할 수 있습니다.
=== 2. Using Non-Contact Water Level Sensor with LED ===
This example demonstrates that the LED lights up when the water level is detected and turns off when it is not detected.


==== 회로 구성 ====
Similar methods can be used to combine various modules and sensors, such as buzzers and water pumps.
센서 선은 수축 튜브를 살짝 당겨보시면 확인 가능합니다.


예제1 회로와 동일하게 비접촉 수위 센서를 연결하신 후, LED를 추가해주세요.
 
==== Circuit Configuration ====
You can check the sensor wire by gently pulling the shrink tube.
 
Please connect the non-contact water level sensor in the same way as in Example 1, and then add the LED.
{| class="wikitable"
{| class="wikitable"
!아두이노 핀
!Arduino Pin
!연결 부위
!Connect
|-
|-
|D3
|D3
|LED의 긴 다리
|Long leg of LED
|-
|-
|GND
|GND
|저항의 한쪽 다리
|One Leg of the Resistor
|-
|-
|저항의 다른 쪽 다리
|Other Leg of the Resistor
|LED의 짧은 다리
|Short leg of LED
|}
|}
[[파일:Xkcy25_예제2_회로.png|가운데|클래스=coders100]]
[[파일:Xkcy25_예제2_회로.png|가운데|class=coders100]]
 
==== Code ====
As in Example 1, it is necessary to check whether HIGH or LOW is output when detecting the water level, as the output mode varies depending on the model.


==== 코드 ====
In the case of the XKC-Y25-NPN model used in this document, LOW is output when the water level is detected.
예제1과 마찬가지로, 모델에 따라 출력모드가 달라 수위 감지 시에 HIGH, LOW 중 어느 쪽이 출력되는지 확인이 필요합니다.


본 문서에서 사용한 XKC-Y25-NPN 모델의 경우 수위가 감지되면 LOW가 출력됩니다.<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
const int sensorPin = 2;  // 비접촉 수위 센서의 OUT 핀 연결
const int sensorPin = 2;  // Connecting the OUT Pin of the Non-Contact Water Level Sensor
const int ledPin = 3;    // LED 연결 핀
const int ledPin = 3;    // LED Connection Pin


void setup() {
void setup() {
   pinMode(sensorPin, INPUT_PULLUP); // 비접촉 수위 센서 핀을 INPUT_PULLUP 모드로 설정
   pinMode(sensorPin, INPUT_PULLUP); // Set the non-contact water level sensor pin to INPUT_PULLUP mode
   pinMode(ledPin, OUTPUT);          // LED 핀을 출력 모드로 설정
   pinMode(ledPin, OUTPUT);          // Set the LED pin to OUTPUT mode
   Serial.begin(9600);              // 시리얼 통신 시작
   Serial.begin(9600);              // Start serial communication
}
}


void loop() {
void loop() {
   int sensorValue = digitalRead(sensorPin); // 비접촉 수위 센서 값 읽기
   int sensorValue = digitalRead(sensorPin); // Reading the Value from the Non-Contact Water Level Sensor


   if (sensorValue == LOW) { // 수위가 감지되었을 때 (센서가 LOW를 읽을 때)
   if (sensorValue == LOW) { // When the water level is detected (when the sensor reads LOW)
     digitalWrite(ledPin, HIGH); // LED 켜기
     digitalWrite(ledPin, HIGH); // Turning on the LED
     Serial.println("수위 감지됨");
     Serial.println("Water Level Detected");
   } else { // 수위가 감지되지 않았을 때 (센서가 HIGH를 읽을 때)
   } else { // When the water level is not detected (when the sensor reads HIGH)
     digitalWrite(ledPin, LOW); // LED 끄기
     digitalWrite(ledPin, LOW); // Turning off the LED
     Serial.println("수위 감지되지 않음");
     Serial.println("Water Level Not Detected");
   }
   }


   delay(500); // 0.5초 대기
   delay(500); // Wait for 0.5 seconds
}
}
</syntaxhighlight>
</syntaxhighlight>


==== 실행 결과 ====
 
시리얼 모니터 출력 결과는 예제1과 동일합니다. 수위 감지 시에 3번 핀에 연결된 LED가 켜지는 것을 확인할 수 있습니다.<div class="coders70">
==== Execution Result ====
The output in the serial monitor is the same as in Example 1. You can confirm that the LED connected to pin 3 turns on when the water level is detected.
<div class="coders70">
<youtube> 7F1ZReFs0PQ </youtube>
<youtube> 7F1ZReFs0PQ </youtube>
</div>
</div>


== '''응용 분야''' ==


* '''가정용 수위 모니터링''': 물탱크, 정수기, 어항 등
== '''Applications''' ==
* '''산업용 수위 제어''': 화학 탱크, 저장 탱크, 배수 시스템 등
 
* '''농업''': 관개 시스템의 수위 모니터링
*'''Home Water Level Monitoring''': Water tanks, water purifiers, aquariums, etc.
* '''의료''': 의료용 액체 저장 용기의 수위 감지
*'''Industrial Level Control''': Chemical tanks, storage tanks, drainage systems, etc.
*'''Agriculture''': Water level monitoring in irrigation systems.
*'''Medical''': Level detection in medical liquid storage containers.


== '''주의 사항''' ==


* 용기 재질은 플라스틱, 종이, 유리 등 다양하게 사용 가능하지만 '''금속 용기'''는 센서 작동에 문제가 생길 수 있어 적합하지 않습니다.
== '''Cautions''' ==
* 센서를 부착할 용기의 외부 표면이 깨끗하고 건조한 상태에서 설치해야 합니다.
* 용기 두께가 감지 거리 내에 있어야 정확한 측정이 가능합니다.


== '''구매 링크''' ==
Container materials can vary and include plastic, paper, glass, etc., but '''metal containers''' may cause issues with sensor operation and are not suitable.
[https://gongzipsa.com/shop/1715255582 공집사몰]
The external surface of the container where the sensor will be attached should be clean and dry during installation.
The thickness of the container must be within the detection range for accurate measurement.
== '''Purchase Link''' ==
[https://gongzipsa.com/shop/1715255582 GONGZIPSA]

2024년 8월 9일 (금) 13:19 판


A non-contact level sensor is a device that can be attached to the outside of a tank or container to measure the liquid level inside.

Since it does not come into direct contact with water, it can be used reliably for a long time and is applicable to various containers (excluding metal) and liquids.


Specifications

Characteristics XKC-Y25-V XKC-Y25-PNP XKC-Y25-NPN XKC-Y28-RS485
Power Voltage DC 5-24V DC 5-12V, DC 24V DC 5-12V, DC 24V 24V (12V Customizable)
Output Mode High and low level Switch quantity (high pulse effective) Switch quantity (low pulse effective) Communication output
Ripple Voltage Requirements ≤200 mV
Current ≤5mA
Response Time 500mS
Operating Temperature -20~105℃
Humidity 5%~100%
Measurement Thickness (Sensitivity Range) ≤20mm (Container Wall Thickness)
Water Level Tolerance Range ±1.5mm
Wire length 500MM (±10MM)
Terminal Order Brown (VCC), Yellow (Signal Output), Blue (GND), Black (COM)
Material PC V0 Flame Retardant Material
Waterproof Performance IP67
Safety Standard Certification CE
Environmental Protection Certification ROHS-2.0

There are differences in voltage and output modes depending on the model, and this document is based on the XKC-Y25-NPN model.


Usage Example

1. Simple Measurement Test

This is an example of verifying whether the non-contact level sensor accurately measures when placed outside the container.


Circuit Configuration

You can check the sensor wire by gently pulling on the shrink tube.

Sensor Wire Color Function Arduino Pin
Brown VCC 5V
Blue GND GND
Yellow OUT D2
Black SET () Not Connected (or for Configuration)

Code

As shown in the specifications tab, the output mode varies depending on the model, so it is necessary to check whether HIGH or LOW is output when detecting the water level.

In the case of the XKC-Y25-NPN model used in this document, LOW is output when the water level is detected.

const int sensorPin = 2; // Sensor Output Pin
int sensorValue = 0;

void setup() {
  pinMode(sensorPin, INPUT_PULLUP); // Activate INPUT_PULLUP Resistor
  Serial.begin(9600);
}

void loop() {
  sensorValue = digitalRead(sensorPin);
  if (sensorValue == LOW) { // Depending on the model, LOW or HIGH may be output differently when detecting the water level, so verification is necessary.
    Serial.println("Water Level Detected");
  } else {
    Serial.println("Water Level Not Detected");
  }
  delay(1000); // Measure at 1-second Interval
}


Execution Result

You can observe that the LED built into the XKC-Y25 sensor lights up when the water level is detected.


2. Using Non-Contact Water Level Sensor with LED

This example demonstrates that the LED lights up when the water level is detected and turns off when it is not detected.

Similar methods can be used to combine various modules and sensors, such as buzzers and water pumps.


Circuit Configuration

You can check the sensor wire by gently pulling the shrink tube.

Please connect the non-contact water level sensor in the same way as in Example 1, and then add the LED.

Arduino Pin Connect
D3 Long leg of LED
GND One Leg of the Resistor
Other Leg of the Resistor Short leg of LED

Code

As in Example 1, it is necessary to check whether HIGH or LOW is output when detecting the water level, as the output mode varies depending on the model.

In the case of the XKC-Y25-NPN model used in this document, LOW is output when the water level is detected.

const int sensorPin = 2;  // Connecting the OUT Pin of the Non-Contact Water Level Sensor
const int ledPin = 3;    // LED Connection Pin

void setup() {
  pinMode(sensorPin, INPUT_PULLUP); // Set the non-contact water level sensor pin to INPUT_PULLUP mode
  pinMode(ledPin, OUTPUT);          // Set the LED pin to OUTPUT mode
  Serial.begin(9600);               // Start serial communication
}

void loop() {
  int sensorValue = digitalRead(sensorPin); // Reading the Value from the Non-Contact Water Level Sensor

  if (sensorValue == LOW) { // When the water level is detected (when the sensor reads LOW)
    digitalWrite(ledPin, HIGH); // Turning on the LED
    Serial.println("Water Level Detected");
  } else { // When the water level is not detected (when the sensor reads HIGH)
    digitalWrite(ledPin, LOW); // Turning off the LED
    Serial.println("Water Level Not Detected");
  }

  delay(500); // Wait for 0.5 seconds
}


Execution Result

The output in the serial monitor is the same as in Example 1. You can confirm that the LED connected to pin 3 turns on when the water level is detected.


Applications

  • Home Water Level Monitoring: Water tanks, water purifiers, aquariums, etc.
  • Industrial Level Control: Chemical tanks, storage tanks, drainage systems, etc.
  • Agriculture: Water level monitoring in irrigation systems.
  • Medical: Level detection in medical liquid storage containers.


Cautions

Container materials can vary and include plastic, paper, glass, etc., but metal containers may cause issues with sensor operation and are not suitable. The external surface of the container where the sensor will be attached should be clean and dry during installation. The thickness of the container must be within the detection range for accurate measurement.

Purchase Link

GONGZIPSA