int DatosSH=0;
String infoYL69="";
int rele= 12;
int datosrele=0;
int comprobar=0;
int bombaAgua=0;
unsigned long timepoEsp;
unsigned long tiempoTarea1;
unsigned long tiempoTarea2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(32,INPUT);
}
void loop() {
timepoEsp = millis();
// put your main code here, to run repeatedly:
delay(1000);
DatosSH=analogRead(32);
DatosSH=map(DatosSH, 0,4095,0,100);
if(DatosSH>=100){
infoYL69="S.fuera de tierra";
}else if(DatosSH>=80 && DatosSH<99 ){
infoYL69="Suelo seco";
}else if(DatosSH>=70 && DatosSH<85 ){
infoYL69="Suelo Humedo";
}else if(DatosSH<70 ){
infoYL69="Totalmente mojado";
}
if ( timepoEsp-tiempoTarea1>=1000){
//tarea
tiempoTarea1=timepoEsp;
if(DatosSH>=80 && DatosSH<99 ){
comprobar++;
}
if(comprobar>=5){
bombaAgua++;
if(bombaAgua<=6){
//digitalWrite(rele,HIGH);
Serial.println("bomba de agua ACTIVADA"+ bombaAgua);
}else {comprobar=0;
Serial.println("DESACTIVADO____");
}
}
}
Serial.println(String(DatosSH));
Serial.println(infoYL69);
}
//AO= 32 //Sensor YL-69
//Rele= 12