Arduino Soil Moisture Sensor
by goks_lf in Circuits > Sensors
192480 Views, 122 Favorites, 0 Comments
Arduino Soil Moisture Sensor
![8.png](/proxy/?url=https://content.instructables.com/F9S/AKX2/J5OD5IEN/F9SAKX2J5OD5IEN.png&filename=8.png)
![11.png](/proxy/?url=https://content.instructables.com/FFT/MAI8/J5OD5V8W/FFTMAI8J5OD5V8W.png&filename=11.png)
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.
Components Required
![9.png](/proxy/?url=https://content.instructables.com/FD5/XYA8/J5OD5MHB/FD5XYA8J5OD5MHB.png&filename=9.png)
![6.png](/proxy/?url=https://content.instructables.com/F6X/JHE6/J5SA8KVB/F6XJHE6J5SA8KVB.png&filename=6.png)
![12.png](/proxy/?url=https://content.instructables.com/FJX/JQXH/J5OD60JB/FJXJQXHJ5OD60JB.png&filename=12.png)
![13.png](/proxy/?url=https://content.instructables.com/F1P/H5LC/J5OD67G5/F1PH5LCJ5OD67G5.png&filename=13.png)
For this project, you will need :
- Arduino Uno
- Soil Moisture Sensor
- Hook up Wires
- Bread Borad.
About the Soil Moisture Sensor
![1.png](/proxy/?url=https://content.instructables.com/FGY/X7ED/J5MQJ1W9/FGYX7EDJ5MQJ1W9.png&filename=1.png)
![2.png](/proxy/?url=https://content.instructables.com/FCE/FNJK/J5MQJ2TF/FCEFNJKJ5MQJ2TF.png&filename=2.png)
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.
How Does the Sensor Work
![10.png](/proxy/?url=https://content.instructables.com/F6B/AF3N/J5OD5SLF/F6BAF3NJ5OD5SLF.png&filename=10.png)
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.
Connections
![4.png](/proxy/?url=https://content.instructables.com/F84/5UJ9/J5SA8GC6/F845UJ9J5SA8GC6.png&filename=4.png)
![5.png](/proxy/?url=https://content.instructables.com/FUT/HB2C/J5SA8JFK/FUTHB2CJ5SA8JFK.png&filename=5.png)
- 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.
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 }
Output
![Measure the moisture content in Soil](/proxy/?url=https://content.instructables.com/FHE/MMEM/J5OD6DGM/FHEMMEMJ5OD6DGM.jpg&filename=Measure the moisture content in Soil)
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 !!