Non-contact Liquid Level Sensor w/ Raspberry-PI GPIO💦

DFRobot’s Non-contact Liquid Level Sensor XKC-Y25-T12V SKU: SEN0204 is a sensor that detects the condition whether there is air or water in an invisible tank or pipe Returning binary signal selection. Let’s code to detect the signal using the RaspberryPI GPIO port (Genreral purpose Input Output).



1.0 라즈베리파이 GPIO 수위센서

  1. 비접속 수위센서 코딩 1.RPi.GPIO modul - Digital INPUT.
  2. DFRobot Non-contact Liquid Level Sensor XKC-Y25-T12V SKU: SEN0204
  3. port 20,16,12 : Arduino Water level sensor
 
fig.01 - on pipes fig.02 - on valves



Introduction of XKC-Y25-T12V SKU

The non-contact liquid level sensor utilizes advanced signal processing technology by using a powerful chip with high-speed operation capacity to achieve non-contact liquid level detection. No contact with liquid makes the module suitable for hazardous applications such as detecting toxic substances, strong acid, strong alkali and all kinds of liquid in an airtight container under high pressure. There are no special requirements for the liquid or container and the sensor is easy to use and easy to install. The liquid level sensor is equipped with an interface adapter that makes it compatible with DFRobot “Gravity” interface. There are 4 levels of sensitivity which are set by pressing the SET button.

  • 4Pins into 3 Pins : ( 4 Pins are converted into 3 with small control board)
  • VCC (5~24v)
  • GND
  • Signal (Digital get)



Pin Description

Liquid Level Sensor-XKC-Y25-T12V Pin defination

fig.03 - adaptor & sensor in detail
 
Num.  Name      Description
1  (Brown)    VCC   In VCC (range: +5V~+24V)
2  (Yellow)   OUT   Liquid level sensor signal output
3  (Blue)    GND   GND
4  (Black)    ADJ   Sensor sensitivity adjustingswitch (Adjust the sensor
         sensitivity, 4 modes in all. Click the SET button
         on the adapter to set the sensor sensitivity.)



Non-contact Liquid Level Sensor Adapter

Liquid Level Sensor-XKC-Y25-T12V Pin defination

fig.04 - adaptor circuit
 
 Num. Name   Description
 Left_1 VCC  InVCC (range: +5V~+24V)
 Left_2 OUT  Liquid level sensor signal output
 Left_3 GND  GND
 Left_4 ADJ  Sensor sensitivity adjusting switch (Adjust the sensor
     sensitivity, 4 modes in all. Click the SET button on
     the adapterto set the sensor sensitivity.)
 Right_1 OUT  Signal
 Right_2 VCC  InVCC
 Right_3 GND  GND



 
fig.05 - PI, adaptor & sensor
 



2.0 파이썬 코드삽입 태그

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3
"""
# RPi.GPIO modul - Digital INPUT.
# DFRobot Non-contact Liquid Level Sensor XKC-Y25-T12V SKU: SEN0204
# - 20,16,12 : Arduino Water level sensor
"""
import time
import RPi.GPIO as GPIO

SENS = []
SENS.extend((14, 15, 18))   # Arduino Sensors
SENS.extend((23, 24))       # Blank
SENS.extend((25, 8, 7, 1))  # XKC-Y25-T12V SKU: SEN0204

NUM_PORTS = len(SENS)       # 9 ports

def main():
    setup()

    try:
        loop()
    except KeyboardInterrupt:
        GPIO.cleanup()

def setup():
    # BroadCom Chip Pin# Set
    GPIO.setmode(GPIO.BCM)
    for n in range(NUM_PORTS):
        GPIO.setup(SENS[n], GPIO.IN)

def loop():
    count = 1
    while True:
        print('-------------- count: %s' % count)

        for n in range(NUM_PORTS):
            num_bcm = str()
            read_bcm = GPIO.input(SENS[n])

            if SENS[n] >= 10:
                num_bcm = str(SENS[n])
            else:
                num_bcm = '0' + str(SENS[n])
            print('GPIO# %s = %s' % (num_bcm, read_bcm))

        print()
        time.sleep(1)
        count += 1

if __name__ == '__main__':
    main()


Written on ... June 30, 2018