Introduction: Moisture Detection With Two Nails
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
delay(500);
}
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.
10 Comments
Question 8 months ago on Step 1
What's the purpose of the resistor??
8 years ago on Introduction
Worked! I didnt have a 10K resistor, instead I used a 10K potentiometer. And no soldering.
8 years ago
good work, but you have to prevent electrolysis from happening. I bet your nails are already corroded.
Reply 8 years ago on Introduction
Not yet, but I did read that it would inevitably happen. I'll keep an eye on them though to see how quickly the nails begin to deteriorate.
Reply 8 years ago on Introduction
Soil = minerals, water, electric current passing every 0.5 seconds?
I bet they already have.
Reply 8 years ago on Introduction
I can certainly see a bit of rust after about an hour.
I've since updated this circuit though to have traffic lights for output and the 'voltage' is now from a digital pin that I switch on/off once every hour for a check.
I'll keep an eye on the nails and see how they are with hourly checks. Might need to make it even less frequent. We'll see. :)
Reply 8 years ago on Introduction
The frequency doesn't matter. Your nails will be gone and become useless before you can say "corrosion", and you don't want to be changing your nails every other month.
You should switch the voltage flow as much as possible, much like AC current, to prevent electrolysis from eating away your nails. Take a look into that! :)
Reply 8 years ago on Introduction
For the most recent revision of my waterbot, I am switching the sense current on for a few seconds before a read, reading the resistance a number of times, reversing the current, letting it 'settle', reading it the same number of times in the other direction, then switching it off again and using the average of all of the reads as my soil moisture value.
Using only 14-gauge galvanized steel (electric fence wire) as my electrodes, it has run several times in this configuration for up to six months at a time with no significant corrosion evident.
Reply 8 years ago on Introduction
Sounds like a plan.
I've altered the system to only read when a button is pressed, so the nails should last a LOT longer:
https://www.instructables.com/id/SoilMoisture-Detection-System/
Reply 8 years ago on Introduction
http://www.simplecircuitdiagram.com/2010/10/19/cd4...
This should help you on your way!