Update example to show temp in Fahrenheit and add computeHeatIndex function to resolve issue #9.

This commit is contained in:
Tony DiCola
2014-06-02 12:54:54 -07:00
parent 633eb08654
commit ffac2f15b7
3 changed files with 28 additions and 1 deletions

View File

@ -28,7 +28,13 @@ void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Read temperature as Fahrenheit
float f = dht.readTemperature(true);
// Compute heat index
// Must send in temp in Fahrenheit!
float hi = dht.computeHeatIndex(f, h);
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
@ -39,6 +45,12 @@ void loop() {
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hi);
Serial.println(" *F");
}
}