Automatic Plant Watering System Using a Micro:bit




Introduction: Automatic Plant Watering System Using a Micro:bit

In this Instructable, I'm going to be showing you how to build an automatic plant watering system using a Micro:bit and some other small electronic components.

The Micro:bit uses a moisture sensor to monitor the moisture level in the plant's soil and then switches on a small pump to water the plant if the soil gets too dry. This way, your plant is always looked after, even when you've forgotten about it or you're away.

If you like this Instructable, please vote for it in the Block Code contest!


I’ve used the MicroBit version 2, but this project can be made using the first version as well.

Step 1: Preparing Your Components

MicroBit is a small programmable micro-controller that has a number of onboard sensors and buttons, making getting started with programming really easy.

You can use block coding for children and less experienced programmers and JavaScript or Python for those who are more experienced with programming and want to get more functionality out of it. It also has a range of IO pins available for sensors and devices along it’s bottom edge.

The capacitive moisture sensor I’m using runs on 3.3V, which is perfect to be used directly with the MicroBit.

Note: These capacitive sensors generally state that they operate between 3.3V and 5V, and output a maximum of 3.3V as they have an onboard voltage regulator. I've found that a lot of the cheaper versions of these sensors don't actually work with an input voltage of 3.3V, but require 3.5-4V before they actually "switch on". You'll need to be careful with this as the Micro:bit is only designed for an input voltage of up to 3.3V.

The pump will need to be turned on and off using a relay module. The relay module switches power to the pump so that the current isn’t flowing through the MicroBit.

Step 2: Designing the Circuit & Code in TinkerCAD

I designed the circuit and did the block coding in TinkerCAD since they’ve recently added the MicroBit to their platform. Block coding is a really easy way to build basic programs by just dragging and dropping function blocks.

I used a DC motor to represent the pump and a potentiometer to simulate the moisture sensor input as it also requires the same three connections.

In my final version of the block code, the Micro:bit shows a smiley face when it’s turned on then starts taking moisture readings every 5 seconds and plotting them on the graph on the display. It also checks whether the moisture level is below the set limit, and if it is then it turns on the pump for 3 seconds. It continues to cycle the pump, with a 5-second break between cycles, until the moisture level is again above the limit.

I also added functions to the two buttons where button A turns the pump on for 3 seconds to manually water the plant, and button B shows the moisture level reading on the display.

Step 3: Testing the Circuit and Code

Once I was happy with the simulation running in TinkerCAD, I connected the components together on my desk to check that they worked in the same way. I made temporary connections using some jumpers and alligator clips to attach to the Micro:bit pins.

This was mainly to test that the Micro:bit was reading the correct values from the sensor and that the relay was able to be turned on and off.

Step 4: Making the Water Tank

Once I was happy with the test setup, I got to work on making a water tank, building the components into a housing, and doing the permanent electrical connections.

I found these two containers in a local discount store. They stack together so that I could use the bottom one as a tank and the top one to house the electronics.

To make the tank, I needed to mount the pump into the tank with the water inlet as close to the bottom as possible, while still leaving enough room for the water to flow. I glued the pump in place using a glue gun.

I then drilled holes for the wires to the motor and the tube for the water outlet.

Step 5: Assemble the Electronics

I wanted the MicroBit to be mounted onto the front of the housing so that it was easy to see, as I’m using the LED display on the front as a graph of the water level.

I drilled some holes through the front to hold the MicroBit and act as the connections to the IO pins on the bottom. I used some long M3 x 20mm button head screws to screw into the terminals on the IO pins and connect to the wiring on the inside of the case. I connected the wiring to the screws by wrapping some of the exposed wiring around the screws and then using heat shrink tubing to hold it in place.

I also drilled holes for the power lead to the Micro:bit, for the power socket at the back and for the pump and moisture sensor wires.

I then connected all of the wiring, soldering the joints, and connected the components together inside the housing.

Step 6: Testing the Watering System

Now that all of the components are assembled, it's time for a bench test.

I filled the tank with water and turned on the power supply.

The Micro:bit powered up and began taking readings. Because the moisture sensor was not in soil, the Micro:bit immediately registered the "soil" as dry and turned the pump on.

So it looks like it's all working correctly and we can try it out on a plant.

Step 7: Setting the Watering System Up on a Plant

To set the Micro:bit up on a plant, I pushed the moisture sensor into the soil, making sure that the electronics were above the soil level. I then positioned the water outlet over the centre of the soil, so that the water would be evenly distributed around the plant's roots.

Step 8: Using the Automatic Plant Watering System

The graph on the front shows the moisture level being measured by the sensor as the soil dries out. When it gets below the threshold set in the code, the pump comes on automatically in 3-second intervals until the moisture level goes above the threshold again. You should quickly notice the soil moisture level increasing again once the pump has been run.

You can also press Button A on the front of the MicroBit to turn the pump on for 3 seconds and water the plant manually.

You could even chain multiple MicroBits together using their radio link to view your plant's moisture level from a different room or water them remotely. A nice idea would be to use a separate Micro:bit as a dashboard and control hub for a couple of other Micro:bits running as Automatic Plant Watering Systems.

Have you built anything using a Micro:bit? Let me know in the comments section.

Please also remember to vote for this Instructable in the Block Code contest if you enjoyed it!

Block Code Contest

Second Prize in the
Block Code Contest

Be the First to Share


    • Lamps Challenge

      Lamps Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Rice & Grains Challenge

      Rice & Grains Challenge



    9 months ago

    Hello. I really want to make this project but I am having trouble with the circuit. I don't really understand the circuit from the picture. can you please explain it to me? thank you


    1 year ago

    is there any other things left


    Question 1 year ago on Step 3

    Question can I modify the circuit just to use moisture sensor as an on-off switch to turn on/off circuit instead of a pump 12 volt DC?
    Sensor detects water then turns circuit off.
    Sensor dries out and turns circuit back on?
    Please advise thank you...

    I did the coding part and the micro bit is coming in soon. I am so excited to not have to worry about my desk plant when I am gone.

    I really want to make one for my cactus. Could you please make it so we can see the whole image.


    Question 1 year ago

    Hey just wanna ask how many wires were used in the project how long they each were


    1 year ago on Introduction

    Beautiful work on this. I was wondering if at some point you might design a solar panel and battery pack versus AC power needed please. That would allow it to be more portable, to be placed at windows and such. Love the simplicity, and thanks for sharing!


    Reply 1 year ago

    Thank you. That's a great idea, this would run well on a small battery pack and indoor plants are generally in a sunny area, so a solar panel would work well to charge it. I'll have a look at this!