Introduction: Moisture Detection With Two Nails

About: Self-taught part-time artist who paints, draws and doodles.

Here's a really simple way to detect moisture in plant soil.

You'll need:

  • An Arduino
  • Two steel nails
  • one 10k ohm resistor
  • some lengths of wire
  • soldering iron
  • solder

Step 1: The Contraption

The layout is dead simple:

One nail goes to the +5V line on the Arduino. The other nail goes to an analogue pin (zero in my case) but also to the 10K resistor and then to ground.

Easy as that!

What we're effectively doing is putting +5V through the soil (with one nail) and detecting what we can with the other nail. The more water in the soil, the less resistance we'll get (and vice versa).

Step 2: The Code

Here's the simple code:

int moistureSensor = 0; //one nail goes to +5V, the other nail goes to this analogue pin
int moisture_val;

void setup() {
Serial.begin(9600); //open serial port

void loop() {
moisture_val = analogRead(moistureSensor); // read the value from the nails
Serial.print("moisture sensor reads ");
Serial.println( moisture_val ); // print the moisture level to the serial monitor

Step 3: The Result

To view the output you need to open the Arduino IDE serial monitor.

I have the nails all the way down in my plant pot, but play around with one nail part in, both part in, and you'll see that you get different results depending on the placement and depth of the nails.

For my little plant the sweet spot was around 695 to 705.

I've already upgraded this to a version with three LEDs to give a visual representation of the soil using red, green and yellow lights. I'll upload that if people want to see it.