Soil moisture sensors measure the volumetric water content in soil
Ideal to monitor the urban gardenMoisture sensor uses two probes to pass current through the soil, and then it reads the resistance to get the moisture level. More water makes the soil to conduct the electricity more easily (Less resistance), While dry soil conducts electricity poorly (More resistance)
http://www.fut-electronics.com/wp-content/plugins/fe_downloads/Uploads/moisture-sensor-arduino.pdf
Circuit
Arduino | Sensor |
5V | VCC (Pin 1) |
GND | GND (Pin 2) |
A0 | S (Pin 3) |
Code
void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: int soilmoisture=analogRead(A0); Serial.println(soilmoisture); if(soilmoisture < 500) { Serial.println(" good Moisture Level"); } else if((soilmoisture >600)&& (soilmoisture <800)) { Serial.println("Lesser than Good"); } else Serial.println("I want Water....Alarm"); delay(1000); }