X
Home > Blog > HOW to Make an Automatic Irrigation System with KidsIOT

HOW to Make an Automatic Irrigation System with KidsIOT

By r September 5th, 2024 517 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.
Img

1. Description

This project introduces how to use a kidsIOT mainboard, a soil moisture sensor, a water level sensor, a passive buzzer, an OLED display, a relay and a water pump to build an automatic irrigation system.

We will read the analog values of the soil moisture sensor and water level sensor by writing code to control the relay and the water pump.

When the soil is too dry, the relay will be turned on to control the water pump to irrigate the plants, when too low, the water pump will not be started and the buzzer will alarm.

At the same time, the OLED display will display the dryness of the soil and the water level, thus realizing automated plant watering and water level control, improving production efficiency while reducing the time and energy costs of manual operations.

2. Components

Img

Img

Img

Img

kidsIOT Mainboard×1

Water Level Sensor×1

Soil Moisture Sensor×1

Passive Buzzer×1

Img

Img

Img

Img

GPIO Shield×1

Relay Module×1

Water Pump×1

Wire×3

Img

Img

Img

Img

Battery Holder×1

Slotted Screwdriver×1

M-F DuPont Wires

F-F DuPont Wires

Img

Img

Img

Img

Water Pipe×1

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

AA Battery(Not provide)×6

Sink×2

Img

3. Assembly Steps

It shares the same structural shape with Project 07. If the assembly parts of Project 07 have finished, there is no need to assemble it again.

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)

Water Level Sensor

G→G,V→V,S→S4

No.4 port(control pin of S4 is io39)

Passive Buzzer

No.8 port(control pin is io5)

Relay Module

No.2 port(control pin is io2)


**Note:** You need to use a slotted screwdriver to loosen the screws at the NO port and COM port of the relay module. Use a m-f DuPont wire to connect the COM port on the module to V on the GPIO shield, and connect the red wire of the water pump to the NO port of the relay module, the black wire of the water pump and the f--f Dupont wire are connected to G of the GPIO shield. After connecting the wires, use the screwdriver to tighten the screws at the NO port and COM port.

Connect the kidsIOT mainboard to your computer via USB cable, connect the external power supply and turn the DIP switch on the mainboard to ON end.

Img

5. Pumping System

Img

(1). Write the Program

① Set the pin IO2 connected to the relay module to “input” mode.

Img

② Set the relay module to close for 0.5 seconds and then disconnect, controlling the water pump to pump water for 0.5 seconds.

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, the relay module will control the water pump to pump water.

6. Automatic Irrigation System

Img

(1). Programming Steps
Step 1:Flow Chart

Img

Step 2:Add “passive buzzer”

Img

Step 3:Write the Program

① Initialize pin IO27 of the soil moisture sensor and pin IO39 of the water level sensor to “input” mode.

Img

② Initialize pin IO2 of the relay module and pin IO5 of the passive buzzer to “Output” 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 and a “Water_level_sensor” global variable to store the analog value of the water level sensor.

Img

⑤ Assign sensor data to variables.

Img

⑥Display the sensor data at the corresponding position on the OLED display.

Img

⑦ Judgment: When the water level is less than 1000, or the soil moisture is less than 500, the buzzer will sound an alarm.

Img

⑧ When the soil moisture is less than 500 and the water level in the sink is greater than 1000, the relay will drive the water pump for automatic irrigation.

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, the OLED displays current soil moisture and sink water level information.

When the soil moisture is lower than the set threshold, then the soil is too dry, the buzzer will sound an alarm. At this time, the pumping system will automatically irrigate the soil. When the water level in the sink is lower than the set threshold, the pumping system will not work and the buzzer will sound an alarm to indicate that there is insufficient water in the sink.

Img

7. Common Problems
Q1: Is the sensor waterproof?

A: The relay is not waterproof.

Q2: Does the rotation of the water pump cause the kidsIOT board to reset?
A: When the water pump rotates, it requires a larger current than other sensors, which will cause voltage and current fluctuations in the circuit. Excessive voltage and current fluctuations will cause the voltage and current of the kidsIOT mainboard to be too low, causing the kidsIOT mainboard to reset.
HOW to Make a Water Level Detection System with KidsIOT
Previous
HOW to Make a Water Level Detection System with KidsIOT
Read More
How to Program Relay Module on Kidsuno
Next
How to Program Relay Module on Kidsuno
Read More
Message Us