1 of 26

Making a Self-Watering Plant System with Micro:bit

Our plant takes care of itself — with a little help from technology!

2 of 26

What is a Self-Watering Plant?

  • A self-watering system helps a plant get water even when nobody is around to do it!

​

  • Sensors and micro:bit work together to “know” when the plant is thirsty.

​

  • When the soil gets dry… the system gives the plant a drink automatically.

3 of 26

How Does it Work?

  1. Sensor checks how wet or dry the soil is.
  2. micro:bit decides when the plant needs water.
  3. Water pump and servo motor turns on and waters the plant from a case full of water
  4. Everything is powered by batteries or USB for automatic care!

​

4 of 26

What You'll Need

Sensor:bit

Soil moisture sensor

A BBC micro:bit V2

A USB cable to connect it to a computer

A battery pack 

​

A plant that needs

a high-tech friend!

Relay

2 jumper wires

1 single jumper wire

Screwdriver

5 of 26

What You'll Need

Sensor:bit

Soil moisture sensor

A BBC micro:bit V2

A USB cable to connect it to a computer

A battery pack 

​

A plant that needs

a high-tech friend!

Relay

2 jumper wires

1 single jumper wire

Screwdriver

6 of 26

Connect the Soil Sensor

  • Connect the jumper wire to the soil moisture

Soil moisture sensor

Jumper wire

7 of 26

Connect the Relay

  • Connect the jumper wire to the relay

Jumper wire

Relay

8 of 26

Connect the sensor bit to the micro:bit

9 of 26

Connect the soil moisture to the sensor bit

  • Connect the soil moisture sensor to the P1 of sensor:bit.
  • The colors of the wires should match the ones of the sensor bit.

​

10 of 26

Connect the relay to the sensor bit 1/2

  • Connect the relay using the jumper wire to the P2 of sensor:bit (near P1, where moisture sensor connection).
    • Use the screwdriver for the screws of the relay.
  • The colors of the wires should again match the ones of the sensor bit.

​

11 of 26

Connect the relay to the sensor bit 2/2

  • Connect a single wire (take color red) from the jumper and connect the middle terminal of the relay to the V pin of P16 on the sensor:bit.

12 of 26

We need to connect the pump to the sensor bit

  • Connect the black wire (ground) of the submersible pump to the G pin at the P16 of sensor bit.

13 of 26

We need to connect the pump to the relay

  • Connect the red cable (VCC) from the pump to the NO (normal open) input of the relay.

14 of 26

Connect the micro:bit to the micro B cable

15 of 26

Coding the Self-Watering System

  • How does the code work?
    • It checks the soil moisture every few minutes.
    • If the soil is dry (sensor value is low), micro:bit turns on the pump/relay for a short time.
    • Then it waits and checks again.
  • Block code example:
    • Read moisture value from P0.
    • If value < 30 (dry), turn on P1 pin for 10 seconds (activates pump).
    • Wait for next cycle.

​

16 of 26

Connect the USB to the computer and...�Let’s Get Coding!

  • Time to tell the micro:bit what to do.
    • Open your web browser and go to: makecode.microbit.org
    • Click on New Project and give it a name like “Water Plant".

​

17 of 26

Coding the Soil Moisture

  • Let's check if the plant is thirsty.

​

  • Access Extensions and search for smarthome.

​

  • From Basic, get show number block.
  • From Smarthome select value of soil moisture (0~100) at pin P1 and place it in the show number block.
  • Put the show number block in the forever loop block.

​

  • Test the code and put the moisture sensor in the water, then dry it.

18 of 26

Coding the Soil Moisture�Let’s add avatars!

  • We'll show a happy face 😊 for wet soil and a sad face 😟 for dry soil.

​

  • From Logic, drag an if <true> then... else block and place it inside a forever loop.
  • From Logic again, get a 0 < 0 comparison block.
  • In the first slot add value of soil moisture (0~100) at pin P1 and in the second one put a number, like 30.
    • This is our "dry" threshold (you can experiment with this number!).

​

​

​

19 of 26

Coding the Soil Moisture (cont)�Let’s add avatars!

  • In the then section, use a show icon block to show a sad face (for when the reading is low, meaning dry).
  • In the else section, use show icon to show a happy face (for when the reading is high, meaning wet).
  • Again, wet, then dry the moisture sensor!

​

20 of 26

Bring the water to the plant!

  • Access Advanced -> Pins, then select digital write pin P2 to 1 (this switches your relay and the pump ON)
    • Put it in the case where the plant is thirsty (if moisture is below 30).
    • Also add a pause (ms) 2000, meaning 2 seconds
      • or 5000 for 5 seconds, we can experiment with it.
  • In the else case, include digital write pin P2 to 2.
    • Add a pause (ms) 30000 (30 seconds)
      • This is for experimenting only, in practice, we should

put it for 600 000 ms (10 minutes) of even 1 hour.

21 of 26

Water the plant and save the battery!

  • Let’s figure out what the program does!

22 of 26

Plant monitoring & Avatar

23 of 26

Plant monitoring

  • When we had the trip to the Danube, the sensors collected data for a plant.

​

24 of 26

Plant monitoring

  • When we had the trip to the Danube, the sensors collected data for a plant.

​

25 of 26

Plant monitoring

  • When we had the trip to the Danube, the sensors collected data for a plant.

​

26 of 26

Using the data for a plant avatar