void showLCD(){
int t1 = temp1;
int t2 = temp2;
int t3 = temp3;
int t4 = temp4;
int t5 = temp5;
int h1 = hygro1;
int nE = nivEau;
int c2 = co2;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("TEMP1:");
lcd.print(t1);
lcd.print(" ");
lcd.print("HYGRO1:");
lcd.print(h1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("TEMP2:");
lcd.print(t2);
lcd.print(" ");
lcd.print("Co2:");
lcd.print(c2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("INTER:");
lcd.print(t4);
lcd.print(" ");
lcd.print("EAU:");
lcd.print(t3);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print("NIVEAU EAU:");
lcd.print(nE);
}
float fmap(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
//ON REGARDE SI LA LAMPE EST ALLUME
boolean isJour(){
if(analogRead(LUM_PIN) > 100){
isJour1 = 1;
return true;
}
isJour1 = 0;
return false;
}
void actionsCorrectives(){
//NIVEAU EAU
if(nivEau >= 12 && etatRel4 == HIGH){
sendCMD("cmd=alerte&val=errormsg,Niveau%20eau%20trop%20bas.
Extinction%20pompe%20à%20eau.");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" NIVEAU EAU ");
lcd.setCursor(0,2);
lcd.print(" TROP BAS ! ");
digitalWrite(rel4, LOW);
etatRel4 = LOW;
}
//TEMP 1
if(temp1 <= temp1_min || temp2 <= temp2_min){
sendCMD("cmd=alerte&val=warning,Température%20trop%20basse
Extinction%20extraction");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" TEMPERATURE ");
lcd.setCursor(0,2);
lcd.print(" TROP BASSE ! ");
digitalWrite(rel0, LOW);
etatRel0 = LOW;
}
else if(temp1 >= temp1_max || temp2 >= temp2_max){
sendCMD("cmd=alerte&val=warning,Température%20trop%20haute
Allumage%20extraction
Extinction%20Co2");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" TEMPERATURE ");
lcd.setCursor(0,2);
lcd.print(" TROP HAUTE ! ");
digitalWrite(rel0, HIGH);
etatRel0 = HIGH;
digitalWrite(rel3, LOW);
etatRel3 = LOW;
}
//HYGROMETRIE
if(hygro1 <= hygro1_min){
sendCMD("cmd=alerte&val=warning,Taux%20hygrometrie%20trop%20bas
Allumage%20brumisateur");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" HYGROMETRIE ");
lcd.setCursor(0,2);
lcd.print(" TROP BASSE ! ");
digitalWrite(rel1, HIGH);
etatRel1 = HIGH;
}
else if(hygro1 >= hygro1_max){
sendCMD("cmd=alerte&val=warning,Taux%20hygrometrie%20trop%20haut
Allumage%20extraction");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" HYGROMETRIE ");
lcd.setCursor(0,2);
lcd.print(" TROP HAUTE ! ");
digitalWrite(rel0, HIGH);
etatRel0 = HIGH;
digitalWrite(rel3, LOW);
etatRel3 = LOW;
digitalWrite(rel1, LOW);
etatRel1 = LOW;
}
//CO2
if(co2 <= co2_min && isJour() && (etatRel0==LOW || (etatRel0==HIGH &&(temp1 <= temp1_max && temp2 <= temp2_max)) )){
sendCMD("cmd=alerte&val=warning,Taux%20Co2%20trop%20bas
Extinction%20extraction
Allumage%20Electrovanne");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" TAUX Co2 ");
lcd.setCursor(0,2);
lcd.print(" TROP BAS ! ");
digitalWrite(rel3, HIGH);
etatRel3 = HIGH;
digitalWrite(rel0, LOW);
etatRel0 = LOW;
}
else if(co2 >= co2_max && isJour()){
sendCMD("cmd=alerte&val=warning,Taux%20Co2%20trop%20haut
Extinction%20Electrovanne");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" TAUX Co2");
lcd.setCursor(0,2);
lcd.print(" TROP HAUT ! ");
digitalWrite(rel0, HIGH);
etatRel0 = HIGH;
digitalWrite(rel3, LOW);
etatRel3 = LOW;
}else if(!isJour()){
digitalWrite(rel3, LOW);
etatRel3 = LOW;
}
//TEMP INTERNE
if(temp4 >= temp4_max){
//ALERTE CIRCUIT CHAUD
sendCMD("cmd=alerte&val=errormsg,Temperature%20interne%20elevee
Allumage%20extraction%20module.");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" TEMP INTERNE ");
lcd.setCursor(0,2);
lcd.print(" TROP HAUTE ! ");
}
if(temp3 >= temp3_max){
Serial.println("TEMP EAU ELEVE");
sendCMD("cmd=alerte&val=warning,Temperature%20Eau%20trop%20haute
Extinction%20pompe%20eau");
lcd.clear();
delay(50);
lcd.setCursor(0,1);
lcd.print(" TEMP EAU ");
lcd.setCursor(0,2);
lcd.print(" TROP HAUTE ! ");
digitalWrite(rel4, LOW);
etatRel4 = LOW;
}
delay(1000);
showLCD();
}