Level Sensor HS-S37-L

Level Sensor HS-S37-L

1. Introduction

Water level sensor is specifically designed for depth detection, and can be widely used for detecting rainfall, water level, and even liquid leakage.When the water level sensor is placed in water, the higher the water level above the copper wire, the larger the simulated value.Read the analog value of the water depth sensor module and print it to the serial port.To know the water depth, we directly place a little bit of the sensor in front of the detection part into the water, so we can know the simulated value when it is just put into the water. Knowing this value, we can derive a formula: the current simulated value is CA, and the simulated value when put underwater is DA.Water depth = (CA-DA)/100.

2. Schematic

Water Depth Sensor-HS-S37-L SchematicClick to view

Module Parameters

Pin Name

description

G

GND (Negative Power Input)

V

VCC (Positive Power Input)

S

Analog Signal Pin

  • Power Supply Voltage: 3.3V / 5V

  • Connection method: PH2.0 socket

  • Installation method: Screw fixed / Lego construction

4, Circuit Board Size

5 of Arduino IDE example program

Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Arduino IDE Library Download and Import Tutorial:
Click to view

Example program (UNO development board):

volatile float num;
volatile int Buzzer;
void setup(){
 num = 0.0;
 Buzzer = 6;
 Serial.begin(9600);
 pinMode(A2, INPUT);
}
void loop(){
 //水深传感器接A2.,蜂鸣器接uno开发板D6
 //检测水越深,水深传感器模拟值越大;反之,水深传感器模拟值越小
 num = long(analogRead(A2));
 Serial.println(num);
 delay(500);
 if (num > 670) {
 //大概大于3cm
 pinMode(Buzzer, OUTPUT);
 digitalWrite(Buzzer,HIGH);
 } else {
 pinMode(Buzzer, OUTPUT);
 digitalWrite(Buzzer,LOW);
 }
}

6, ESP32 Python Example (for Mixly IDE/Misashi)

Choose the development board Python ESP32 [ESP32 Generic(4MB)] and upload in code mode

Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Download and import tutorial for Mixly IDE ESP32 library:
Click to view

Example program (ESP32-Python):

import machine

pin2 = machine.Pin(2, machine.Pin.OUT)
adc32 = machine.ADC(machine.Pin(32))
i = 0
while True:
    i = adc32.read_u16()
    print(i)
    if i >= 50000:
        pin2.value(1)
    else:
        pin2.value(0)

7, Mixly example program (graphical language)

Example program (UNO development board):Click to download
Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Download and import tutorial of Mixly IDE Arduino library:Click to view

Example Program (ESP32 Development Board):Click to download
Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Download and import tutorial for Mixly IDE ESP32 library:
Click to view

8. Setting up the Test Environment

Arduino UNO Test Environment Setup

Prepare Components:

  • HELLO STEM UNO R3 DEVELOPMENT BOARD *1

  • HELLO STEM UNO R3 P EXPANSION BOARD *1

  • USB TYPE-C DATA CABLE *1

  • Water Level Sensor Module (HS-S37L) *1

  • Active Buzzer Module (HS-F07L) *1

  • PH2.0 3P dual-head terminal line *2

Circuit wiring diagram:

ESP32 Test Environment Setup

Prepare Components:Pending update...

Circuit wiring diagram:Pending update...

9, Video tutorial

Video Tutorial:Click to view

10, Test results

Arduino UNO test results:

After the device is connected to the wire, upload the above program to the Arduino UNO development board, open the Mxily serial port monitor, slowly place the water level sensor module into the water, and the serial port outputs the analog value of the water depth sensor greater than 670 (equivalent to greater than 3cm), and the buzzer sounds.