DIY SOIL MOISTURE SENSOR CHEAP YET ACCURATE !

21,514

31

24

Introduction: 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

1 Person Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

24 Discussions

0
LarryF24
LarryF24

Answer 14 days ago

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,

IMG_2991.jpg
0
ParthK2
ParthK2

Answer 1 year ago

Not sure about that

0
LarryF24
LarryF24

Question 14 days ago on Step 4

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

3
RichardPillay
RichardPillay

10 months ago

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.

0
ParthK2
ParthK2

Reply 10 months ago

You are smart 👍😁

1
Asmodeo
Asmodeo

1 year ago

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.

0
msheppard
msheppard

Reply 11 months ago

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)

0
msheppard
msheppard

11 months ago

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.

1
cian45lewis
cian45lewis

Question 1 year ago

i would love to see you post the complete project with pump ect. Would you consider?

1
Branislav308
Branislav308

Question 1 year ago

Hello sir. You made a great project. I have one question about moisture percentage formula. How did you get this formula int percent = 2.718282 * 2.718282 * (.008985 * moistVal + 0.207762); and this numbers 2.718282, 008985 and 0.207762. Best regards!

2
ATHAANA
ATHAANA

1 year ago on Step 3

Hello, I would like to ask you to give me the mathematical formula calculating soil moisture(%) from the measured soil resistance.

Thank you in advance

Athanasios Anastasiou

0
ChristianI1
ChristianI1

2 years ago

Hey ! thanks for this guide. Isn't the drawing from Step 2 wrong ? It says to connect to GND but at the same time to 5V (I know it must be 5v but...)
Just to prevent some misunderstandings. Keep on with the awesome work tho.

0
ParthK2
ParthK2

Reply 2 years ago

Hi, sorry for that bro thanks for pointing that out I will take care of these thing from next time

0
Droid9117
Droid9117

Question 2 years ago on Step 2

if you replaced the galvanized nails with stainless steel screws would this improve the corrosion factor?

0
ParthK2
ParthK2

Answer 2 years ago

According to chemistry stainless steel is alloy of iron and carbon where as galvanization is process of electroplating of a metal with zinc as zinc is placed low in activity series it is less prone to oxidation insense rusting than the stainless steel so i will recommend to use galvanised nail or else plated the nail with chromium or nickel. The best way to avoid rust in cheap way is to add some soldier on the sensor. Let me know if you need more help on it

1
somEonEneWherE
somEonEneWherE

2 years ago

Nice and cheap idea, but in my experiance the big problem with these sensors is corrosion and also galvanized nails will corrode. Do you have experience how long it will take until these are no more usable or need recalibration?

0
ParthK2
ParthK2

Reply 2 years ago

I know that the galvanized nail may also corroded after 6 month the the quick fix is to upgrade to chrominium plate nail or else cover the whole nail with a solder. Talking about calibration it takes 5 min and in most cases it doesn't need calibration

0
somEonEneWherE
somEonEneWherE

Reply 2 years ago

Sounds very good,so I think I will try it. And if it lasts 6 Month, this is should be long enough although solder seams to be also cheap and might help.

Thank you very much for your answer! :)

0
ParthK2
ParthK2

2 years ago

It needs a little bit of calibration it can be done by taking a soil completely wet making it as reference and to make sure that you have above 95% of moisture if not try changing the distance between probe or change the variable in code