SHARE
TWEET

Acquisition température & humidité

vbprojects Oct 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <DHT.h>
  2.  
  3. #define DHTPIN 3;
  4. #define DHTTYPE DHT22
  5.  
  6. float humidite;
  7. float temperature;
  8.  
  9. DHT dht(DHTPIN, DHTTYPE);
  10.  
  11. void setup() {
  12.   Serial.begin(9600);
  13.   dht.begin();
  14. }
  15.  
  16. void loop() {
  17.   humidite = dht.readHumidity();
  18.   temperature = dht.readTemperature(true);
  19.  
  20.   if (isnan(humidite) ||  isnan(temperature)) {
  21.     Serial.println("Failed to read from DHT sensor!");
  22.   }
  23.  else{
  24.   Serial.println("Température : " + temperature);
  25.   Serial.println("Humidité : " + humidite);
  26.  }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top