adafruit / DHT-sensor-library

Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
https://learn.adafruit.com/dht
MIT License
1.96k stars 1.43k forks source link

HeatIndex for lower values of temperature and humidity #153

Open frankielc opened 4 years ago

frankielc commented 4 years ago

The current algorithm used for calculating heat index takes into account Rothfusz equation to achieve the values that Robert G. Steadman came up by experimentation. It then has some refinements done by the NWS but doesn't consider the other refinements that NWS did for lower values of temperature and humidity.

That's the reason why heat index for common house-hold values, like 74.84F and 68.5H give a heat index of 66.38F when in reality it should be somewhere in the range of 75.23F - which makes more sense.

NWS full algo is very well detailed in this paper: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3801457/

I also submited a pull request: https://github.com/adafruit/DHT-sensor-library/pull/154

Daryavahus commented 1 year ago

I changed used library DHT11 Asair using that diagram shown above: And my code looks like this:

float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) { float hi;

if (!isFahrenheit) temperature = convertCtoF(temperature);

if (temperature <= 40){ hi = temperature; } else{ float var_A = -10.3 + (1.1 temperature) + (0.047 percentHumidity); if(var_A < 80){ hi = var_A; }

else{ hi = -42.379 + 2.04901523 temperature + 10.14333127 percentHumidity + -0.22475541 temperature percentHumidity + -0.00683783 pow(temperature, 2) + -0.05481717 pow(percentHumidity, 2) + 0.00122874 pow(temperature, 2) percentHumidity + 0.00085282 temperature pow(percentHumidity, 2) + -0.00000199 pow(temperature, 2) pow(percentHumidity, 2);

if ((percentHumidity < 13) && (temperature >= 80.0) &&
    (temperature <= 112.0)){
  hi -= ((13.0 - percentHumidity) * 0.25) *
        sqrt((17.0 - abs(temperature - 95.0)) * 0.05882353);
    }

if ((percentHumidity > 85.0) && (temperature >= 80.0) &&
         (temperature <= 87.0)){
  hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);

} } } return isFahrenheit ? hi : convertFtoC(hi); }