This project aims to develop a solution which waters the plant automatically whenever needed.
Hardware Required
Arduino Uno
Soil Moisture Sensor
Relay
Jumper Wires
LED
Software Required
Arduino IDE
int SoilValue= 0 ;
const int LED = 13
int Sisoil= 0 ;
int S1=800; // upper limit of moisture
int S2=500; // Lower limit of mositure
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(Soil, INPUT);
}
void loop() {
Serial.print("soil value = ");
Serial.println(ReadSoil());
Sisoil= WetDry();
if(Sisoil==1){
(1);
}else {
LEDf(0);
}
delay(1000);
}
int ReadSoil(){
SoilValue =analogRead(Soil);
delay(100);
return SoilValue;
}
int WetDry(){
if ( SoilValue > S1) {
digitalWrite(LED, HIGH);
return 1;
} else if ( SoilValue < S2){
digitalWrite(LED, LOW);
return 0;
}
}
int LEDf(int act){
if(act==1){
digitalWrite(LED, HIGH);
return 1;
}else{
digitalWrite(LED, LOW);
return 0;
}
}