Microsoft MakeCode

Micro:bit V2 and soil sensor using nails?

Hi! I am working with this project:

which is great and uses 2 nails connected to ‘0’ and ‘3V’ on the micro:bit but I am wondering if its possible to do this with just 1 nail? If yes, where would the nail be connected to and would the code change? Thanks!

The code in the example is using analogRead(), which reads the voltage on the P0 nail and compares it to the 3 volts from the 3V nail.

Here’s a way to think about it: The 3V (they use P1 at the end) “puts” three volts into the soil. The P0 measures how much of that 3 volts was “lost” as it travelled through the soil to the P0 nail. It is doing a comparison (somewhat like subtraction) to see how much it’s changed…it needs both the “start” (3V) and end (P0) to do the comparison needed here.

If you haven’t studied voltage and current before, you might take a look at some tutorials. I like SparkFun’s: Voltage, Current, Resistance, and Ohm’s Law, which has a few videos that may help.


1 Like


I was working on a similar project and ended up making a video for it.
As mentioned you will need to measure the current flowing between two probes (hence the two nails). Using a ready made gives better contact and more sensitivity though it can definitely be done without.
Micro:bit self watering

WOW love this, will take a look now!