Skip to content

Commit 5fb1668

Browse files
committed
Merge branch 'jmdana-master'
2 parents 6c0c723 + c57f0c8 commit 5fb1668

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

DHT.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,17 @@ float DHT::readHumidity(bool force) {
8888

8989
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
9090
float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) {
91-
// Adapted from equation at: https://github.com/adafruit/DHT-sensor-library/issues/9 and
92-
// Wikipedia: http://en.wikipedia.org/wiki/Heat_index
93-
if (!isFahrenheit) {
94-
// Celsius heat index calculation.
95-
return -8.784695 +
96-
1.61139411 * temperature +
97-
2.338549 * percentHumidity +
98-
-0.14611605 * temperature*percentHumidity +
99-
-0.01230809 * pow(temperature, 2) +
100-
-0.01642482 * pow(percentHumidity, 2) +
101-
0.00221173 * pow(temperature, 2) * percentHumidity +
102-
0.00072546 * temperature*pow(percentHumidity, 2) +
103-
-0.00000358 * pow(temperature, 2) * pow(percentHumidity, 2);
104-
}
105-
else {
106-
// Fahrenheit heat index calculation.
107-
return -42.379 +
91+
// Using both Rothfusz and Steadman's equations
92+
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
93+
float hi;
94+
95+
if (!isFahrenheit)
96+
temperature = convertCtoF(temperature);
97+
98+
hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094));
99+
100+
if (hi > 79) {
101+
hi = -42.379 +
108102
2.04901523 * temperature +
109103
10.14333127 * percentHumidity +
110104
-0.22475541 * temperature*percentHumidity +
@@ -113,7 +107,15 @@ float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFah
113107
0.00122874 * pow(temperature, 2) * percentHumidity +
114108
0.00085282 * temperature*pow(percentHumidity, 2) +
115109
-0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2);
110+
111+
if((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0))
112+
hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882);
113+
114+
else if((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0))
115+
hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
116116
}
117+
118+
return isFahrenheit ? hi : convertFtoC(hi);
117119
}
118120

119121
boolean DHT::read(bool force) {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=DHT sensor library
2-
version=1.2.0
2+
version=1.2.1
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors

0 commit comments

Comments
 (0)