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

아두위키 : Arduwiki
208번째 줄: 208번째 줄:
== '''Cautions''' ==
== '''Cautions''' ==


Container materials can vary and include plastic, paper, glass, etc., but '''metal containers''' may cause issues with sensor operation and are not suitable.
* 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 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.
* The thickness of the container must be within the detection range for accurate measurement.
 




== '''Purchase Link''' ==
== '''Purchase Link''' ==
[https://gongzipsa.com/shop/1715255582 GONGZIPSA]
[https://gongzipsa.com/shop/1715255582 GONGZIPSA]

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


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