BBC micro:bit – Plant watering

This is the beginning of a larger project to provide a greenhouse control system. It monitors the soil and when it is sufficiently dry, runs a small pump for a few seconds to water the plant.

Click to enlarge
Click to enlarge

The script waits for button A to be pressed to start.

It reads the water sensor attached to Pin 0

If the level is too low, it displays a W for watering, turns on the pump attached to Pin 1 for 2 seconds and then P for pauses for 10 seconds to let the water soak in.

This pause to allow time for the water to act is a key concept in terms of control engineering.

If the soil is damp enough, it shows G for good.

This is wrapped up in the while loop that is checking that button B has not been pressed. Once it is pressed, it drops out the sense/water loop, displays a S for stop and is then idle, pending another press of button A

The script can be found here.

You will need:

  • A plant
  • A water sensor
  • A pump
  • A plastic bottle to house the pump & water supply
  • Battery power – a 4 AA battery pack is simplest

The water sensor is attached to Pin 0 and the pump trigger lead is attached to Pin 1. The pump black lead needs to go on to 0V on the micro:bit. The battery pack positive (red) lead goes to the pump red lead and the battery pack 0V (black) lead goes to the 0V on the micro:bit so there is a common ground for all the circuitry.

Extensions to the script include checking for light levels – so that watering is not done in the middle of the day, or checking temperature levels so that watering does not occur if it will just evaporate.