Water your plants automatically!
- 1 micro:bit with battery pack and batteries
- 2 long nails or silver
- 2 crocodile clips
- 1 micro servo + 3 female-to-croc clips
- 1 ice cream wooden stick
- 2 elastics
- 1 clear tape roll
- 1 straw
- 1 pair of scissors
Follow the instructions in the video to build a mini water-pump using a micro:bit and a servo.
The soil moisture sensor¶
Use the instructions of the soil moisture project to make a soil moisture sensor and upload the code to your micro:bit.
The final wiring should look like this:
Let’s add code so that when the soil moisture level is low, the servo waters the plant.
From the soil moisture project, we know that the moisture is low when the
reading is roughly less than
500. We can use this number to add an if
reading < 500 in the code to decect a dry condition.
The servo is connected to pin P2 so we can use the
||pins:servo write|| block to change the angle of the servo. We want the angle to change to
0, wait until the water pours off, and then move the angle back to
Insert the code above in the
||basic:forever|| loop of the soil moisture code.
Here’s a video showing the micro:bit watering a plant.