Merge pull request #112 from SConaway/patch-1

Read Temp and Humidity if not specified
This commit is contained in:
Paint Your Dragon 2019-01-11 16:33:11 -08:00 committed by GitHub
commit bf86a4068c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

10
DHT.cpp
View File

@ -19,7 +19,7 @@ DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for _maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
// reading pulses from DHT sensor. // reading pulses from DHT sensor.
// Note that count is now ignored as the DHT reading algorithm adjusts itself // Note that count is now ignored as the DHT reading algorithm adjusts itself
// basd on the speed of the processor. // based on the speed of the processor.
} }
void DHT::begin(void) { void DHT::begin(void) {
@ -92,7 +92,13 @@ float DHT::readHumidity(bool force) {
} }
//boolean isFahrenheit: True == Fahrenheit; False == Celcius //boolean isFahrenheit: True == Fahrenheit; False == Celcius
float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) { float DHT::computeHeatIndex(isFahrenheit) {
float hi = self.computeHeatIndex(self.readTemperature(isFahrenheit), self.readHumidity(), isFahrenheit);
return isFahrenheit ? hi : convertFtoC(hi);
}
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
float DHT::computeHeatIndex(float temperature, floast percentHumidity, bool isFahrenheit) {
// Using both Rothfusz and Steadman's equations // Using both Rothfusz and Steadman's equations
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml // http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
float hi; float hi;

1
DHT.h
View File

@ -43,6 +43,7 @@ class DHT {
float readTemperature(bool S=false, bool force=false); float readTemperature(bool S=false, bool force=false);
float convertCtoF(float); float convertCtoF(float);
float convertFtoC(float); float convertFtoC(float);
float computeHeatIndex(bool isFahrenheit=true);
float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true);
float readHumidity(bool force=false); float readHumidity(bool force=false);
bool read(bool force=false); bool read(bool force=false);