4.8 Project: Soil Humidity Monitoring System
Pay attention! Do not overflow water from plastic pools in experiments. Spilling water on other sensors may cause not only a short circuit or modules to be out of work but also heat generation and even explosion. Do be extra careful! Especially for younger users, please operate with your parents. To guarantee security, please obey guidances and safety regulations.

4.8.1 Flow Diagram

4.8.2 Soil Humidity Sensor
Description:
Soil humidity sensors are mainly used to measure water content in volumetric soil, monitor soil moisture, irrigate crops and protect forests. This kind of sensor is integrated in agricultural irrigation system to supply water regularly and efficiently, which optimize irrigation for a best plant growth.

Schematic Diagram:

Wiring Diagram:
Connect the soil humidity sensor to io32.
Attention: Connect yellow to S(Signal), red to V(Power), and black to GND. Do not reverse them!

Test Code:
Initialize the serial port.

Print the read sensor value.

Complete code:

Test Result:
Open the serial monitor.
Touch the detection area of the sensor with a wet finger and the currently detected humidity value will be printed on the monitor (range: 0~4095).

4.8.3 Soil Humidity Monitoring System
We adopt LCD1602 to reveal the real-time value of soil humidity value.When the value is lower than the set minimum humidity, the buzzer will emit sound to prompt farmers of irrigation.
Wiring Diagram:
Connect the soil humidity sensor to io32.
Connect the buzzer to io16.
Connect the LCD1602 to BUS I2C.
Attention: Connect yellow to S(Signal), red to V(Power), and black to GND. Do not reverse them!

Test Code:
Code Flow:

Code:
Initialize LCD and clear its display. Turn on the back light to observe the displayed value.

Initialize the serial port and define a variable.

Read the value of the soil humidity value and assign it to the variable. LCD shows the value.

Determine the read value. If it is lower than 200, the buzzer will alarm.

Complete code:

Test Result:
When the value detected by the soil humidity sensor is lower than the set threshold, the buzzer emits sound to alarm.
4.8.4 FAQ
Q: Is soil humidity sensor waterproof?
A: With the exception of the detection area, the sensor is not waterproof. Spilling water on other area may result in a short circuit.