micro:bit L4 - Water Level Monitoring & Auto Refill

Lesson 4 - Water Level Monitoring & Auto Water Refilling

Students learn how to use loops to continuously monitor water level and event-driven programming to automatically control a water pump.

image1.png I can read the water level with a sensor and a micro:bit

image1.png I can use loops to continuously monitor the water level

image1.png I can use events to automatically control the pump


 

1. Engage: Is Your Reservoir Running Low?

If you find yourself needing to refill your reservoir every 2-3 days, you're not alone. It's a common experience among many hydroponic enthusiasts.

image2.png

Key Question

What leads to insufficient water levels?

Two main reasons:

1. Evaporation - Light and air movement cause water to continuously evaporate from the reservoir.

2. Plant Uptake - Roots absorb water for growth and transpiration.

Manually refilling every few days is not only tiring - it's also risky. What if we forget? What if we're away on vacation? Today we will build a system that can refill itself automatically!


 

2. Explore: How Does the Water Level Sensor Work?

Water level sensor:

It works by measuring conductivity. As the water rises, more traces on the sensor are exposed to water, changing the electrical resistance.

image3.png

Analog read pin block:

It can read the water level change as an analog value (0-400).

image4.png

Peristaltic pump: How does it work?

When the rotor turns, rollers squeeze the soft tube to form sealed sections. These squeezing forces push the liquid inside the tube forwards.

image5.pngimage6.jpeg

 

What is the difference between a peristaltic pump and a normal pump?

1. For peristaltic pumps, liquid only touches the tubing, while ordinary water pumps have internal components exposed to fluid, raising the risk of cross-contamination.

2. Peristaltic pumps deliver highly precise flow control, whereas ordinary water pumps cannot achieve accurate quantitative liquid transfer.

image7.png Teacher Note:

The water level sensor should NOT be fully submerged - only the portion lower than the Max line should contact the water.

The relationship between water depth and sensor reading is approximately linear in the effective range.


 

3. Engineer: Teacher Demo - Read Water Level in a Loop

The teacher demonstrates the core program while students observe and learn:

Step 1: Make the hardware connection

image8.png

Step 2: Build the program in MakeCode

Rebuild the program and download it to the micro:bit.

image9.png

program4-1

Step 3: Observe the relationship

Change the water level in the container and watch how the sensor reading changes. When water touches more traces, the reading increases; when water recedes, the reading decreases.


 

4. Experience & Challenge: Monitor and Control Water Level

Key Question

How does the water level (mm) relate to the sensor reading?

 

Experience: Record Water Level vs. Sensor Value

Activity 1

• Ask students to modify program4-1 to make the micro:bit display the water level reading in real time.

image10.png

program4-2

• Guide students to change the water level in 10 mm increments and record the sensor reading at each level:

Water Level (mm)Sensor Reading
0 (empty) 
10 
20 
30 
40 

• Ask students: What pattern do you notice? Is the relationship linear? At what water level does the sensor reading change the most?

image7.png Teacher Note:

The gap between each pair of metal strips is approximately 5 mm. Students can read the analog value as water covers each successive pair of strips.

image11.png

Key Question

What if we're not around to check the water level? How can the system take care of itself?

 

Challenge: Auto Water Refilling with Pump Control

Teacher Preparation: Two containers; one for hydroponic planting, the other for the water tank.

image7.png Teacher Note: If you mount the pump as shown below, the water will circulate clockwise as illustrated in the diagram.

image12.pngimage13.jpeg

 

Here is the block structure you can refer to;

image14.png

Activity 2

• Connect the pump to the BOSON expansion board (M3). Program the micro:bit to keep the water at an ideal level.

• 1. Add extensions

• https://github.com/cdjq/pxt-expansion-board-for-microbit-k10

image15.png

• 2. Challenge students to program the system to maintain the desired water level.

image16.png

program4-3

Students should calibrate the threshold value based on their Activity 1 observations. The pump should run only long enough to restore the water level, then stop automatically. Discuss what could happen if the pump runs continuously (overflow!)—this introduces safety considerations in system design.

image7.png Teacher Note:

The speed setting for the peristaltic pump generally needs to be higher than 200; otherwise, the pump may stall.


 

5. Elaborate: Automatic Water Level Control in the Real World

Key Question

What other functions can a peristaltic pump perform in hydroponic planting?

Guide students to discuss what other roles it can play in hydroponic systems apart from maintaining a stable water level.

Example answer:

1. It can deliver nutrient solutions automatically and adjust the dosage accurately.

2. It can also work as an aerator. Dropping water from a height increases the oxygen content in the water.

 

 

Next Lesson: Lesson 5

Cuurent Tutorial

icon Lesson 4.zip 5.58MB Download(0)
License
All Rights
Reserved
licensBg
0