X
Home > Blog > STEM for Arduino > HOW to Make A Soil Moisture Detection System with KidsIOT

HOW to Make A Soil Moisture Detection System with KidsIOT

By r September 3rd, 2024 45 views
Note: Do not allow water to overflow from sinks and soil troughs when using the device. Sprinkling water on other sensors will cause a short circuit and device failure. Sprinkling water on batteries will cause heating and explosion. Please be careful when using the device, especially when used by young children, it must be under the supervision of parents. To ensure safe operation of the device, please follow relevant usage guidelines and safety regulations.

1. Description

This project introduces how to use a kidsIOT mainboard, a soil moisture sensor, a passive buzzer and an OLED display to make an intelligent soil moisture detection system. The system can display the value of the soil moisture sensor in real time through the OLED display. When the soil moisture is lower than the set value, the buzzer will sound an alarm to remind you that it is time to water the land.

2. Components

Img

Img

Img

Img

Img

kidsIOT Mainboard×1

Soil Moisture Sensor×1

Passive Buzzer×1

GPIO Shield×1

Wire×2

Img

Img

Img

Img

F-F DuPont Wires

USB Cable×1

Soil Moisture/Water Level/Automatic Irrigation System LEGO Pieces×1

Sink×1

Img

3. Assembly Steps

Step 1:Components Needed

Img

Step 2:Process

Process 1:

Img

Process 2:

Img

Process 3:

Img

Process 4:

Img

Process 5:

Img

Img

Process 6:

Img

Process 7:

Img

Process 8:

Img

Process 9:

Img

Process 10:

Img

Img

Process 11:

Img

Process 12:

Img

Process 13:

Img

Process 14:

Img

Complete:

Img

4. Wiring Diagram

Module

GPIO Shield

kidsIOT Mainboard

Soil Moisture Sensor

G→G,V→V,S→S3

No.4 port(control pin of S3 is io27)

Passive Buzzer

No.8 port(control pin is io5)

Connect the kidsIOT mainboard to your computer via USB cable.

Img

5. Read the value of soil moisture sensor

Img

(1). Write the Program

① Set the baud rate to 15200.

Img

② Set the pin IO27 connected to the soil moisture sensor to “input” mode.

Img

③ Define a “Soil_humidity_sensor” global variable to store the analog value of the soil moisture sensor.

Img

④ Store the read analog value of the soil moisture sensor in the “Soil_humidity_sensor” variable and print it on the serial port.

Img

⑤ Complete Program

Img

(2). Test Result

ClickImg to upload the above complete code to the kidsIOT board. After powering up via the USB cable, click Img in the serial monitor and set the baud rate to 15200.

Insert the soil moisture sensor into the soil (or touch the sensor with wet hands), then the serial monitor will print the analog value of the soil moisture sensor (range: 0~4095). The greater the soil moisture (or the wetter the hand), the greater the value!

Img

6. Soil Moisture Detection System

Img

(1). Programming Steps
Step 1:Flow Chart

Img

Step 2:Add “passive buzzer”

Img

Step 3:Write the Program

① Set the pin IO27 connected to the soil moisture sensor to “input” mode.

Img

② Initialize the width, height, I2C address, text size and color as well as background color of the OLED display.

Img

③ Define a “Soil_humidity_sensor” global variable to store the analog value of the soil moisture sensor.

Img

④ Store the read analog value of the soil moisture sensor in the “Soil_humidity_sensor” variable and display it on the OLED.

Img

⑤ Determine the analog value of the sensor. If it is less than 500, the buzzer will sound an alarm; otherwise, the buzzer will not sound.

Img

⑥ Complete Program

Img

(2). Test Result

ClickImg to upload the above complete code to the kidsIOT mainboard. After powering up via the USB cable, insert the soil moisture sensor into the soil (or touch the sensor with wet hands), when the sensor detects that the moisture of the soil (or the moisture of your hands) is less than the set threshold, the buzzer will sound an alarm.

Img

7. Common Problems

Q: Is the sensor waterproof?

A: The detection area of the soil moisture sensor is waterproof. Exceeding the detection area will cause a short circuit.

HOW to Make a Temperature and Humidity Control System with KidsIOT
Previous
HOW to Make a Temperature and Humidity Control System with KidsIOT
Read More
HOW to Make a Track Alarm with KidsIOT
Next
HOW to Make a Track Alarm with KidsIOT
Read More
Message Us