
1. Introduction
Soil moisture sensors are a type of sensing device, mainly used to detect the size of soil moisture and are widely used in automatic windshield wiper systems, smart lighting systems, and smart sunroof systems, etc.Sensor uses high-quality FR-04 double material, large area of 5.0 * 4.0 cm, nickel plated surface.It has antioxidant, conductivity, and superior durability; The sensitivity is adjusted with a potentiometer; The operating voltage is 3.3 V to 5 V.Output in the form of digital values (0 and 1) and analog AO voltage output, using a LM393 dual voltage comparator, when the sensor is connected to a 5V power supply, no humidity is detected on the sensing board, and the DO output is at a high level.When inserted into soil or water, the DO output is at a low level.If the sensor board is dry, the output will return a high-level state.AO analog output can be connected to the AD interface of the microcontroller to detect the humidity size above.Digital output can also be connected to a microcontroller to detect if there is a water shortage.
2. Schematic

Raindrop sensor-HS-S09A schematicClick to view
Module Parameters
Pin Name | description |
|---|---|
G | GND (Negative Power Input) |
V | VCC (Positive Power Input) |
S | Digital Signal Pin |
A | Analog Signal Pin |
Power Supply Voltage: 3.3V / 5V
Connection Type: 2.54mm Header
Installation Method: Double Screw Fixed
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):
void setup(){
Serial.begin(9600);
pinMode(3, INPUT);
pinMode(6, OUTPUT);
pinMode(3, INPUT);
}
void loop(){
//雨滴检测模块接D3,有源蜂鸣器接开发板D6
//
//轻轻调节控制板模块背部电位器,土壤湿度感应板检测到湿度的情况下,控制板模块指示蓝灯亮起;
//土壤湿度感应板干燥情况下,控制板模块指示蓝灯熄灭。
if (digitalRead(3) == 1) {
//土壤湿度感应板干燥情况下,输出高电平(1),控制板模块信号指示蓝灯熄灭,蜂鸣器不响。
digitalWrite(6,LOW);
Serial.println(String("干燥土壤:") + String(digitalRead(3)));
} else if (digitalRead(3) == 0) {
//土壤湿度感应板遇到水或湿润土壤的情况下,输出低电平(0),控制板模块信号指示蓝灯亮起
digitalWrite(6,HIGH);
Serial.println(String("湿润土壤:") + String(digitalRead(3)));
}
}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.IN)
pin4 = machine.Pin(4, machine.Pin.OUT)
while True:
if pin2.value() == 1:
pin4.value(0)
print('干燥土壤')
else:
pin4.value(1)
print('湿润土壤')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 PRO DEVELOPMENT BOARD *1
USB TYPE-C DATA CABLE *1
Soil humidity sensor (HS-S09C) * 1
Soil Moisture Sensor (HS-S09A) *1
Active Buzzer (HS-F07A) * 1
1P female to female Dupont wire *6 pieces or 3P female to female Dupont wire *2 pieces
2.0 Dual Head Terminal Wire * 1
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:
Under the condition that the soil sensor module is powered on, adjust the potentiometer of the soil sensor module with a small screwdriver, until the soil sensor B module is dry, the sensor signal indicates that the blue light is on.

After the device is connected to the wire, upload the above program to the Arduino UNO development board, open the Mxily serial port monitor, insert the two copper strips of the soil humidity sensor module into the soil or water, and the serial port outputs the corresponding text.
