esp32-garden-basics/01-resistance/sketch.ino
2024-05-02 22:51:50 +02:00

64 lines
872 B
C++

/*
C1 : humidité du sol
I1 : Circuit alimenté si On
I2 : Substrat sec si On
*/
#define AOUT_PIN A0
#define LED_POWER 12
#define LED_ALERT 4
#define THRESHOLD 530 // CHANGE YOUR THRESHOLD HERE
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
int value = analogRead(AOUT_PIN); // read the analog value from sensor
digitalWrite(LED_POWER, HIGH);
if (value > THRESHOLD){
Serial.print("The soil is DRY (");
digitalWrite(LED_ALERT, HIGH);
}else{
Serial.print("The soil is WET (");
digitalWrite(LED_ALERT, LOW);
}
Serial.print(value);
Serial.println(")");
delay(500);
}
/*
C1 : humidité du sol
C2 : remplissage du réservoir
I1 : Circuit alimenté si On
I2 : Substrat sec si On
I3 : Réservoir vide si On
P1 : Pompe réservoir -> substrat
*/