Skip to content

Commit bf86a40

Browse files
Merge pull request #112 from SConaway/patch-1
Read Temp and Humidity if not specified
2 parents f8d3497 + 2dfa779 commit bf86a40

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

DHT.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
1919
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
2020
// reading pulses from DHT sensor.
2121
// Note that count is now ignored as the DHT reading algorithm adjusts itself
22-
// basd on the speed of the processor.
22+
// based on the speed of the processor.
2323
}
2424

2525
void DHT::begin(void) {
@@ -92,7 +92,13 @@ float DHT::readHumidity(bool force) {
9292
}
9393

9494
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
95-
float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) {
95+
float DHT::computeHeatIndex(isFahrenheit) {
96+
float hi = self.computeHeatIndex(self.readTemperature(isFahrenheit), self.readHumidity(), isFahrenheit);
97+
return isFahrenheit ? hi : convertFtoC(hi);
98+
}
99+
100+
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
101+
float DHT::computeHeatIndex(float temperature, floast percentHumidity, bool isFahrenheit) {
96102
// Using both Rothfusz and Steadman's equations
97103
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
98104
float hi;

DHT.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DHT {
4343
float readTemperature(bool S=false, bool force=false);
4444
float convertCtoF(float);
4545
float convertFtoC(float);
46+
float computeHeatIndex(bool isFahrenheit=true);
4647
float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true);
4748
float readHumidity(bool force=false);
4849
bool read(bool force=false);

0 commit comments

Comments
 (0)