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.
kidsIOT Mainboard×1 |
Soil Moisture Sensor×1 |
Passive Buzzer×1 |
GPIO Shield×1 |
Wire×2 |
F-F DuPont Wires |
USB Cable×1 |
Soil Moisture/Water Level/Automatic Irrigation System LEGO Pieces×1 |
Sink×1 |
Process 1:
Process 2:
Process 3:
Process 4:
Process 5:
Process 6:
Process 7:
Process 8:
Process 9:
Process 10:
Process 11:
Process 12:
Process 13:
Process 14:
Complete:
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.
① Set the baud rate to 15200.
② Set the pin IO27 connected to the soil moisture sensor to “input” mode.
③ Define a “Soil_humidity_sensor” global variable to store the analog value of the soil moisture sensor.
④ Store the read analog value of the soil moisture sensor in the “Soil_humidity_sensor” variable and print it on the serial port.
⑤ Complete Program
Click to upload the above complete code to the kidsIOT board. After powering up via the USB cable, click 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!
① Set the pin IO27 connected to the soil moisture sensor to “input” mode.
② Initialize the width, height, I2C address, text size and color as well as background color of the OLED display.
③ Define a “Soil_humidity_sensor” global variable to store the analog value of the soil moisture sensor.
④ Store the read analog value of the soil moisture sensor in the “Soil_humidity_sensor” variable and display it on the OLED.
⑤ 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.
⑥ Complete Program
Click 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.
A: The detection area of the soil moisture sensor is waterproof. Exceeding the detection area will cause a short circuit.