Étape 3: Croquis pour Arduino
#include « DHT.h »
#define DHTPIN 30
int sensorPin = A0 ;
unsigned int sensorValue = 0 ;
#define DHTTYPE DHT11
DHT dht (DHTPIN, DHTTYPE) ;
void setup() {}
Serial.Begin(115200) ;
DHT.Begin() ;
}
void loop() {}
flotter h = dht.readHumidity() ;
flotteur t = dht.readTemperature() ;
sensorValue = analogRead(sensorPin) ;
Si (isnan(t) || isnan(h) || h == 0) {}
Serial.Print("\n") ;
} else {}
Serial.Print ("humidité:") ;
Serial.Print(h) ;
Serial.Print("%\n") ;
Serial.Print ("température:") ;
Serial.Print(t) ;
Serial.Print ("* C\n") ;
}
Serial.Print (« humidité du sol: ") ;
Serial.Print (flotteur (sensorValue) / 1024 * 100, 0) ;
Serial.Print("%\n\n") ;
Delay(500) ;
}