Moisture sensor is used to detected the presence of water in soil. This project is used to Test the moisture level in the farming land.This sensor is easy to use and applicable for the commercial farming.
int Moisture_sensor = A0;
void setup()
{ pinMode(led,OUTPUT);
pinMode(Moisture_sensor,INPUT);
Serial.begin(9600);
}
void loop()
{
int value = analogRead(Moisture_sensor);
{
Serial.println(value);
if (value>500)
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
}
}
Sensor show its value low in the presence of moisture and its value is gradually increase in the absence of moisture.
Here when the sensor reading is higher then 500 then the LED is turn ON .
Component Required
- Moisture Sensor Module
- Arduino UNO
- Motor for irrigation(here we use LED for Testing)
- PC
Objectives
- To Calculate the Moisture Level in Soil
Circuit Diagram
Fig :- Circuit Diagram
Connect the component as shown in the figure.Connect A0 pin of sensor to A0 pin of Arduino , VCC to 3.5V and GND pin to GND pin of Arduino. Connect led in 12 pin of arduino to view the output.
Code
int led =13;int Moisture_sensor = A0;
void setup()
{ pinMode(led,OUTPUT);
pinMode(Moisture_sensor,INPUT);
Serial.begin(9600);
}
void loop()
{
int value = analogRead(Moisture_sensor);
{
Serial.println(value);
if (value>500)
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
}
}
Sensor show its value low in the presence of moisture and its value is gradually increase in the absence of moisture.
Here when the sensor reading is higher then 500 then the LED is turn ON .