Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void dhtt(){
- delay(2000);
- // Reading temperature or humidity takes about 250 milliseconds!
- // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
- float hh = dht.readHumidity();
- // Read temperature as Celsius (the default)
- float tt = dht.readTemperature();
- // Read temperature as Fahrenheit (isFahrenheit = true)
- float ff = dht.readTemperature(true);
- // Check if any reads failed and exit early (to try again).
- if (isnan(hh) || isnan(tt) || isnan(ff)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- // Compute heat index in Fahrenheit (the default)
- float hif = dht.computeHeatIndex(ff, hh);
- // Compute heat index in Celsius (isFahreheit = false)
- float hic = dht.computeHeatIndex(tt, hh, false);
- Serial.print("Humidity: ");
- Serial.print(hh);
- Serial.print(" %\t");
- Serial.print("Temperature: ");
- Serial.print(tt);
- Serial.print(" *C ");
- Serial.print(ff);
- Serial.print(" *F\t");
- Serial.print("Heat index: ");
- Serial.print(hic);
- Serial.print(" *C ");
- Serial.print(hif);
- Serial.println(" *F");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement