7. Case 04: Toilet Water Leakage Detection System¶
Level:
7.1. Goal¶
Make a toilet water leakage detection system by checking the conductivity of device connected.
7.2. Background¶
What is a Toilet Water Leakage Detection System?
Toilet water leakage detection system is a system that can trigger alert upon unwanted water leakage situations.
Toilet Water Leakage Detection System Principle
One crocodile clip installed to “P1” while another one crocodile clip installed to “GND”. If the water is full, water will become a conductor to connect “P1” and “GND” (Pin 1 is pressed). It will alert the sound. Otherwise, no sound emitted.
Conductor Water vs Air
The system consists of two crocodile clips each with one side connected to the board (P1 and GND), with two clips physically disconnected. We can imagine there is a conductor in between the 2 crocodile clips.
When nothing is happening, air is an excellent insulator, the conductor would be air, the circuit between P1 and GND will become an open circuit. No Current can be passed through.
When water is raised up, water is a good conductor, the water will connect the P1 and GND between two clips, thus becoming a closed circuit, electricity will flow from P1 to GND.
Know more: What is an Electrical circuit?
Electrical Circuit is one of basic concepts in electronic engineering. When something can let electric current pass through, it builds up a circuit.
Generally, a circuit will have two states. If the circuit is complete, able to let the current pass, it is called a closed circuit. If the circuit has a breakpoint, and cannot let the current pass through, it becomes an open circuit.
However, how to let the current pass through? It is related to the material of the circuit. In daily life, metal wire usually has a high conductivity, so it can be used to build the circuit. In addition, some ionic material such as tap water also takes the same property, able to become a conductor to build a circuit. But air has very bad conductivity, so it is hard to let current pass through.
7.3. Part List¶
7.4. Assembly step¶
Step 1
In this case, “Open Style Model” is used as a home base to start with.
Step 2
Let’s build a toilet room. Put Model E2 onto model A, align with the holes at it.
Step 3
Put Model E1 onto model A, align with the holes at model A, B3.
Step 4
Find a plastic bottle and cut it to become a water tank. Cut the bottle at red line as shown.
Step 5
Place the water tank in the toilet.
Step 6
Place two crocodile clips on the both sides of the water tank to detect water flowing.
Step 7
Assembly Completed!
7.5. Hardware connect¶
Connect the two crocodile clip cables to P1 and GND
Pull down the buzzer switch to connect the buzzer
7.6. Programming (MakeCode)¶
Step 1
Step 1. Check the Pin state
In
Forever
, put aif
statementPut
pin P1 is pressed = true
as condition
Step 2. Alert warning
If in
if
segment, that’s means the water was connected two clipsUse
play tone High A for 2 beat
to play warning sound
Full Solution
MakeCode: https://makecode.microbit.org/_bPw0ViLrR6Jm
You could also download the program from the following website:
7.7. Results¶
When the water level rises to the crocodile clip’s position, the warning sound is triggered to warn the user.
7.8. Think¶
Q1. Apart from the warning by buzzer, any other method can be used to notify the house owner? i.e. showing red LED