Arduino Soil Moisture Sensor

119,991

95

17

Introduction: Arduino Soil Moisture Sensor

About: My team has developed a new product. PLEASE CHECK IT OUT ON INDIEGOGO AND SHOW YOUR SUPPORT. CAMPAIGN LINK: https://igg.me/p/2165733/x/17027489. I'm a tech and food enthusiast and also a Soccer Player. I lo...

When you hear the word Smart Garden, one of the things that pop up to your mind is the automatic measurement of the moisture content of the soil. If you're building a Smart Garden that waters plants automatically and give you the readings of the wetness of the soil, then you will definitely need a Soil Moisture Sensor.

In this Instructable, I'll show you how to interface the Soil Moisture Sensor to an Arduino Uno and read the values on a Serial Monitor.

Step 1: Components Required

For this project, you will need :

  • Arduino Uno
  • Soil Moisture Sensor
  • Hook up Wires
  • Bread Borad.

Step 2: About the Soil Moisture Sensor

A typical Soil Moisture Sensor consist of two components. A two legged Lead, that goes into the soil or anywhere else where water content has to be measured. This has two header pins which connect to an Amplifier/ A-D circuit which is in turn connected to the Arduino.

The Amplifier has a Vin, Gnd, Analog and Digital Data Pins. This means that you can get the values in both Analog and Digital forms.

Step 3: How Does the Sensor Work

Most soil moisture sensors are designed to estimate soil volumetric water content based on the dielectric constant (soil bulk permittivity) of the soil. The dielectric constant can be thought of as the soil's ability to transmit electricity. The dielectric constant of soil increases as the water content of the soil increases. This response is due to the fact that the dielectric constant of water is much larger than the other soil components, including air. Thus, measurement of the dielectric constant gives a predictable estimation of water content.

Step 4: Connections

  • Connect the two pins from the Sensor to the two pins on the Amplifier circuit via hook up wires.
  • Connect the Vcc from the Amplifier to the 3.3V pin on the Arduino and the Gnd pin to the Gnd pin on the Arduino.
  • Now connect the Analog Data Pin to the A0 pin on the Arduino (Since I'm interested in Analog Data).

Refer the Pictures and build the circuit.

Step 5: Code

For simply reading the values I'll be using the AnalogRead sketch from the Examples menu. You can modify the code as per your requirements.

void setup() {

// initialize serial communication at 9600 bits per second: Serial.begin(9600); }

// the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); delay(1); // delay in between reads for stability }

Step 6: Output

After verifying the code, upload it to the board and open the serial monitor. You will see the sensor data on the monitor being changed when you dip the sensor leads in water and when dry. You can use these values as threshold if you intend to trigger an action bases on these values.

That's All Folks !! Stay Tuned for More !!


Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

1 Person Made This Project!

Recommendations

  • Pocket-Sized Speed Challenge

    Pocket-Sized Speed Challenge
  • Audio Challenge 2020

    Audio Challenge 2020
  • Maps Challenge

    Maps Challenge

17 Discussions

0
HelloImaGirl
HelloImaGirl

Question 1 year ago on Step 6

for me it kind of works but the data given in the serial monitor keeps giving the same number even if we wet it or dry it. Please help!

0
RgxH
RgxH

Answer 2 months ago

Greetings;
For me I was using a resistor on the circuit.
When I removed it; the sensor started reading the values correctly.

0
RgxH
RgxH

Question 2 months ago on Step 5

I’ve found a issue on my project (and so in this one), that I have no idea how to fix it properly. Perhaps someone could help me improve this project.
The minimum value range on my project is 0 to 125. Between this range (low moisture); the microcontroller should activate a relay that will make a water pump to run but:
If I disconnect the data pin (from where we read the values); serial monitor will still read bogus values (either higher or lower values). If value is the lowest (0 to 125) the water pump will still be running without really reading the sensor. Thus Water pump will for no reason and run plants will drown... How can we overcome this problem?

1
Shahrul.
Shahrul.

Question 2 years ago

just curious about the yellow and red led on the amplifier..what are them

0
JosephA193
JosephA193

Question 2 years ago on Introduction

Hi! you have an interesting project. may i request if you can make a diagram for the circuit connection so i can build it easily?

0
domain1419
domain1419

2 years ago

tnx for the great work done on this platform. am having an issue with my soil moisture sensor, instead of giving me zero when out of water, it is giving me values like 900,898... what do i do to have the correct reading?

0
rawjackass
rawjackass

Question 2 years ago on Step 6

Is this moisture sensor specifically used for soil? Can I use it to measure moisture content of grain such as flour?

0
himasa
himasa

Question 2 years ago on Step 4

if the values are displayed on the led screen it comes under which output?analog or display

0
buddynfo
buddynfo

2 years ago

did he forget to say about connecting the ground?

0
LarryP27
LarryP27

2 years ago

Has anyone written any more sophisticated code?

0
diy_bloke
diy_bloke

2 years ago

I hope you do not mind me making a few remarks on your project:
1. the sensor. The sensor is a resistance sensor, not a capacitive. so it does not measure the dielectric constant but simply the resistance of the soil between the two 'legs'
If it were a capacitive sensor it would need to be isolated from the soil and you could not simply measure it with an analog port.

2. As you are reading it with an analog port, the module itself (the module in between the sensor and your arduino) becomes redundant and just uses power for nothing.
The Analog pin on the module, is directly connected to the sensor, bypassing the electronics on that module. better connect the sensor directly to the analog port on your arduino.

3. As the sensor will be fed current oon a continous bas, it will corrode due to electrolysis very rapidly. One can use an Arduinopin rather than a continous 5Volt to feed the sensor and switch it off in between readings. That will seriously enhance the time your sensor will last.

I hope you do not mind me making these essential remarks

0
Gökhan Türkeli
Gökhan Türkeli

Reply 2 years ago

Nr 3 sounds right but when I try that I get nonsense sensor value. In the air sensor value just random. In the soil it is between 0 and 10 no matter how wet the soil is.

Any idea why?

0
diy_bloke
diy_bloke

Reply 2 years ago

Hmm sounds like unstable connection. check all yr connections and check what the voltage is on the bin you are using

0
AsdOmega
AsdOmega

Reply 2 years ago

good comment! thx

0
diy_bloke
diy_bloke

Reply 2 years ago

thank you

0
Evanvruggink
Evanvruggink

Reply 2 years ago

Thanks for tip 3, i will use that in my project.