DIY SOIL MOISTURE SENSOR CHEAP YET ACCURATE !

44K4555

Intro: DIY SOIL MOISTURE SENSOR CHEAP YET ACCURATE !

I am a plant lover and tech head. Recently I decided to grow some plants on my balcony. I decided to automate the watering system as I may forget to water them I didn't want to take any chance with my beautiful flower plants. so decided to get soil moisture sensor and water the plants accordingly for that matter I'll be using microcontroller I prefer Arduino nano as it is compact you may use another microcontroller.I found a lot of commercial soil moisture sensor which weren't cheap by any means as the idea behind this is pretty simple so in this instructable I take you through the steps of making this soil moisture sensor at cheap and readily available parts a home. I'll also be explaining the science behind the working of the resistive soil moisture sensor that we will be making.

So without any further ado let's get started

STEP 1: Gathering the Parts and Tools

Required parts:-
  1. galvanized nails 2" - 2piece
  2. A bottle cap 1" wide - 1 piece
  3. 10k ohm 1/4 watt resistor
  4. few female jumper wires
Required tools:-
  1. Soldering Iron
  2. hot glue gun
  3. solder wire

STEP 2: MAKING THE SENSOR

  1. After gathering all the required parts and tools lets get started with our making of a sensor.
  2. grab to nails and punch them through bottle cap 1 inch apart that's necessary the distance between the nails may affect your reading of moisture.
  3. hot glue them on the place.
  4. solder two wire to each nail/probe.
  5. fill the opening of the cap with the hot glue to make it sturdy so we could insert them in the soil.
  6. connect the 10kohm resistor between A0 and GND pin of nano connect it to probe 1 / nail 1 and connect probe 2 / nail2 to a 5v pin of an Arduino.

OOOH YES, THAT'S ALL ABOUT THE SENSOR PART ISNT IT EASY!

STEP 3: INTERFACING THE SENSOR WITH AN ARDUINO

  1. upload the code which I have made into your Arduino board
  2. Open the serial monitor and whoola you will see the sensor reading
  3. Now you would modify the code, you may take the variable that has the sensor value and can switch on or off any external components such as water pump and or some other thing just by making the pin high which the sensor value variable is below a certain threshold.

IF YOU WANT ME TO MAKE A INSTRUCTABLE ON THE COMPLETE GARDEN AUTOMATION USING A SUBMERSIBLE MOTOR WHICH IS AGAIN DIY AND TEMP SENSOR DTH11 WITH TRACKING THE STATUS WITH ANDROID APP. PLS LET ME KNOW IN COMMENTS, PLS LIKE AND FOLLOW FOR FURTHER INSTRUCTABLES. COMMENT IF YOU HAVE A QUESTION OR PROBLEMS ILL DEFINITELY HELP YOU!

STEP 4: SCIENCE BEHIND THE WORKING OF THE SENSOR

So as you had made the sensor I think its very essential to know the science behind the working of the sensor.

so, the 2 probe that we have created are energized with 5volts and other one grounded so when we will be dipped the sensor into the soil the medium between the 2 probes(soil)will be conductive in the sense the probes receive some electron. but we aren't calculating the current received as calculating is tendious and measuring the resistance between to probes is a lot easier than measuring current and the code is written accordingly to measure the resistance between 2 probes and that will determine the amount of moisture in soil and you may react accordingly be sure to use galvanized nail as it will not corrode easily . The 10kohm resistor between the pins A0 and gnd creates a reference resistance for us to calculate. SO THAT'S IT NOW YOU HAVE CREATED YOUR KNOW MOISTURE DETECTING SENSOR AND NOT JUST THAT YOU KNOW THE SCIENCE THE BEHIND THE ACTUAL WORKING OF THE SENSOR AND THATS A GREAT DEAL SO YOU COULD GIVE YOUR SELF THE TITLE OF TITLE SCIENTIST BUT ITS A LONG WAY TO GO FURTHER LET ME KNOW VIEW ABOUT MY INSTRUCTABLES IN COMMENT DOWN BELOW

34 Comments

I noticed the wiring diagram has a discrepancy, the picture with nails shows probe 1 connected to GND via a resistor, and the sketch in the bottom right shows probe 1 connected directly to GND

*The larger sketch works, the bottom right does not

Would it be possible to connect 1 probe to say D1 and the other to D2 with a 10k resistor to ground and code it like...

DigitalWrite D1, HIGH
DigitalRead D2

if D2 = HIGH
DO NOTHING

if D2 = LOW
PUMP

or am I understanding the science wrong?
i realized this would indiscriminately pump as long as its wet and does not give me the ability to pump only when a specific moisture level is met
Step 2 main drawing is correct but not the comment drawing below. The resistor must be between probe and ground or you will get a ground circuit.
I have 3 raised beds each with 8 plants in them. Is there a way to control 24 of these probes with a single Arduino? Is it just a matter of connecting each probe 1 to a different analog pin?
Well, as you don't have that many ports it gets complicated. You could use i2c with extenders to get 16,32,48... ports.
Maybe it's more realistic to measure each bed as one unit? Perhaps the middle pot in each bed can work as a reference for the rest? Watering is not rocket science as long as you have good drainage.
Works like a charm! I used an Electrical Connector Block instead of a bottle cap, helped me to hold the spikes straight and apart and easy connect cables while experimenting.
The formula confused me too, but I just measured the highest value in water and divided it by 100, kinda like this; int percent = (moistVal/factor); My max was between 750-790 so a factor of 7.5 worked fine with my probe. Perhaps not scientific but good enough.
Also using a digital port to active the probe when measuring only. Strongly advice that you do the same to avoid corrosion. Only activate current when needed. Great post, thank you!
Those of you that are worried about corrosion can change the circuit and the code. Instead of connecting Probe2 to 5V, connect it to one of the digital output pins. Then change the code to keep the pin at LOW level all the time, until you need to check how wet the soil is. When you need to check, you turn the pin to HIGH, read the analog input twice, and use the second reading. It is important to read the analog input twice with a delay between the reads, as sometimes the analog pins do not properly read the value on the first read

Since you don't need to check how wet the soil is very often you can read the moisture level two or three times a day. For the rest of the time, there is no voltage between the probes, so there is no corrosion building up. This can mean the difference between the probes requiring to be changed every 6 months to lasting 5 years or more.

It's also important to know that the probes should be changed every few years. This is because fertilisers and minerals from the soil will coat the nails over time, and change the resistance between them. You could re-calibrate instead of changing them, but if you do that, it means making the code more complex, to avoid having a number of these spread out throughout the garden, all with different versions of the code.
You are smart 👍😁
You could also make the probes out of stainless nails or bolts thus making the corrosion less of a concern.
Cool, I was wondering how hard it would to turn this into a moisture meter and use for say wood or concrete
Can I run this with 3,3v from a microbit?
Can this be made to work with a plc?
I don't see why not, I have made bigger projects with a pic ,I no longer do that because I don't have access to a serial parallel port . I have a pic programmer I built years ago but modern day computers don't use that technology as much,loved playing with the PIC,
Not sure about that
Ok I think I figured this out using some math ,so if i multiply the number given by the fracture I should get the result .In my case I am reading between 997 and 1000 on the monitor that shows a 67% moisture given the math would calculate that it is reading a resistance. So If I am right then for me to monitor 40% the reading should be around 596.Still don't understand the equation given in the sketch. I understand it is giving percentage I just dont understand the formula as to how it is worked out on paper. percent = 2.718282 * 2.718282 * (.008985 * moistVal + 0.207762).I would greatly appriciate it if someone could help me with this ,Thanks
Hi, I am making an irrigation system, my first "big step" with Arduino and I found this 'able that I will surely use because sensors here are too expensive. Concerning rusting of the electrodes, I used, years ago, for automated (all analogic) level control of water (and other non acidic substances), to feed alternate current to the sensors, that, in some projects , were 1/2 m long wires, sometimes bronze, sometimes plain iron, and once or twice were stainless steel. None of them corroded, ever. Some of them survived as long as 20 years without changing electrodes. Then, where I am pointing: Instead of reading resistance, couldn't We read presence or not of a pulse in the Arduino inputs? I hope there is anyone there still reading this excellent tutorial to answer my question. Thanks a lot from Argentina.
How would you control the voltage pulse? I just have it going straight from an ESP8266 3V pin and into the A0 (analog) pin. Would I need to use a transistor on one of the digital pins? If so, that might open the door to multiple sensors from a single ESP8266 which is interesting. (Obviously I have just enough EE training to be dangerous)
Built this, and it's working well. I did some research and read that a voltage based sensor will fail eventually because it is effectively an electroplating device and one of the probes will quickly corrode. I found some capacitive measuring devices but there like $8 each.

My question is - have you (or anyone) seen how quickly this corrosion happens? If it takes several months it might be OK to just design this so the nails are easy to replace.
i would love to see you post the complete project with pump ect. Would you consider?

More Comments