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.
This project introduces how to use a kidsIOT mainboard, a water level sensor, a passive buzzer and an OLED display to make an intelligent automatic water level detection system. It is able to monitor water level changes, detect problems in time and take measures to avoid disasters, and is widely used in water conservancy projects, urban drainage as well as environment monitoring.
kidsIOT Mainboard×1 |
Water Level Sensor×1 |
Passive Buzzer×1 |
GPIO Shield×1 |
Wire×2 |
USB Cable×1 |
Soil Moisture/Water Level/Automatic Irrigation System LEGO Pieces×1 |
F-F DuPont Wires |
Sink×1 |
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.
Module |
GPIO Shield |
kidsIOT Mainboard |
---|---|---|
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) |
Connect the kidsIOT mainboard to your computer via USB cable.
① Set the baud rate to 15200.
② Set the pin IO39 connected to the water level sensor to “input” mode.
③ Define a “Water_level_sensor” global variable to store the analog value of the water level sensor.
④ Store the read analog value of the water level sensor in the “Water_level_sensor” variable and print it on the serial port.
⑤ Complete Program
Click to upload the above complete code to the kidsIOT mainboard. After powering up via the USB cable, click in the serial monitor and set the baud rate to 15200.
Insert the water level sensor in the water (or touch the sensor with wet hands), then the serial monitor will print the analog value of the sensor (range: 0~4095). The greater the water level, the greater the value!
① Set the pin IO39 connected to the water level 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 “Water_level_sensor” global variable to store the analog value of the water level sensor.
④ Store the read analog value of the sensor in the“Water_level_sensor” variable and display it on the OLED.
⑤ Determine the analog value of the sensor. If it is greater than 2000, 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 water level sensor in the water (or touch the sensor with wet hands), when the sensor detects that the water level (or the moisture of your hands) is greater than the set threshold, the buzzer will sound an alarm.
A: The detection area of the sensor is waterproof. Exceeding the detection area will cause a short circuit.