How to make a soil humidity sensor

The micro:bit board is an incredible and powerful microcontroller device that is the perfect for creating home experiments and projects, both basic and advanced. In this project, Enrico Miglano combines programming and gardening and shows us how to make a soil humidity sensor.


Plant care and programming
Depending on the kind of plants we are growing, the terrain humidity is a good indicator of the health of the plant and helps us know when it’s time to water it. It wouldn’t be difficult for this simple project to evolve into something more complex, including checking the environment temperature and the daylight intensity, or adding a water pump, making an automated plant watering system.


The only part requiring assembly is the sensor itself. Here is a list of components to be used to assemble it, as shown in the step-by-step images:

  • A 3D printed soil sensor case — or a plastic box and a couple of wooden skewers

  • Electric cable

  • Copper adhesive tape or aluminium foil

  • 1M Ohm resistor

  • 10K Ohm resistor

  • Three crocodile clips

  • A potted plant

The build
The first step is the creation of the humidity soil sensor. This build requires some soldering and gluing. The board will power the sensor, then the soil resistance is read comparing the value with the internal resistance of the circuit. This circuit works in a similar way to a potentiometer, were the variable resistance is read from the soil.


The probes are 3D printed, then covered with adhesive copper tape. They are then inserted in the circuit box and hot-glued to fix them in place and remain water-resistant. After soldering the two resistors to the sensor cables, the box is closed and hot-glued, preventing dirt and humidity from damaging the circuit. The last step is crimping the crocodile clips to the sensor cables.

After assembly, connect it to the BBC micro:bit. Plug the GND (black) cable crocodile clip to the GND ring of the micro:bit. Then plug the data (yellow) cable crocodile clip to the ring one of the micro:bit.

If we power the circuit attaching the power (red) cable crocodile clip to the 3V ring of the micro:bit, the circuit works. A reading every five seconds is sufficient for our purpose. To do this, connect the circuit power to ring two of the board. Programming will set up this pin as digital output, powering the circuit only when it is needed.


Programming the board
Programming is easy — you don’t need to install anything; you only need a browser. To start writing down the code blocks you should go to the The web programming interface includes the main area where you put the blocks, a column with the available standard blocks organized by features, and a simulator that instantly runs the code you write to see what happens, step by step.

Before setting the final program, a test version has been created to see the numeric readings of the sensor in the three experimental conditions — dry, humid, and wet. The analogue values read in these three conditions, then have been used to set up the final program.

I have defined a range of readings to identify the three humidity soil conditions to monitor. Depending on the humidity level of the soil the micro:bit displays an arrow: up arrow, too much water, down arrow, too dry.

Read the full article in issue 79 of The Shed, a bi-monthly magazine that features how-to articles by experts, interviews with people undertaking amazing projects, and peeks into their sheds. A great read for the DIY enthusiast and those with a few tools after a bit of advice and inspiration. You can find out where to buy the latest issue here:

Click here to load this Caspio Cloud Database