8. case 05 Water Level Alarming#

../../_images/ll8HfKH.jpg

8.1. Goal#

Make a water level alarming.

8.2. Materials#

1 x ELECFREAKS micro:bit Smart Home Kit 1 x tank

8.3. Background#

What is water level alarming#

We can’t live without water, but much water will cause flood. Water level alarming can detect water level, micro:bit will received signals when the water level over security line and control lift pump to pumping.

Water level alarming operation#

When micro:bit received signal of soil moisture sensor,relay will drive and supply power to lift pump for pumping redundant water.

../../_images/OsjzuWx.png

8.4. Practical operation#

Preparing a tank and paste devices as below piture:

../../_images/ztW3W42.jpg

8.5. Hardware connect#

../../_images/LRBAV68.png

While connecting the cables with the Relay, please use screwdrivers to loosen the screws on the Relay first to make sure the cables get connected properly.

../../_images/smart_home_kit_case_05_06.png

8.6. Software#

makecode

Edge Connector Data Sheet

8.7. Programming#

Step 1#

Go to MakeCode page, click Advanced in the code block and click on Extensions.

../../_images/2qCyzQ73.png

We need to add a new codebase for programming of smart home. Finding “Add Package” in the bottom of code block and click it. Then a message box will show up, search “smart home”, and download this new codebase.

../../_images/QR2s7LD.png

Note: If there is a hint says some codebase will be deleted because of incompatibility. Don’t worry. You could go ahead as the hint or build a new item in item menu bar.

Step 2#

Snap if statement into forever,set analog read pin P2 > 500, that’s say when P2 > 500, the water level is higher than security line.

../../_images/xa3pCF4.png

Step 3#

Set start melody “ba ding” repeating once as alarming voice, set digital write pin P1 to 1 as driving the pumping.

../../_images/zhdgMcI.png

Step 4#

Else,set digital write pin P1 to 0 as turning off the pump.

../../_images/lfQVbVh.png

Programming#

Make code:https://makecode.microbit.org/_9KqHhp1J45ho

You also could directly download program visit website as below:

8.8. Result#

When the water level over security line,micro:bit will control lift pump to pumping.

Pumping:

../../_images/991WoLx.jpg

Stop pumping:

../../_images/hPf3xtQ.jpg

8.9. Think#

How to use micro:bit control water level in fish tank ?

8.10. Questions#

8.11. More information#