0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

熱指数(Heat Index) の計算のみを移植してみた

Posted at

熱指数(Heat Index) ... 熱指数は温度と相対湿度を用い、気温が実際にどのくらい暑く感じられるかを決める体感温度です

DHT11を使うときに、複数のクラスがあります。

DHT dht(DHTPIN, DHTTYPE);

DHT_Unified dht(DHTPIN, DHTTYPE);

DHT_Unifiedを使いたいが熱指数(Heat Index)の計算が無いそこで,DHTのcomputeHeatIndexを移植してみました。

湿度と温度(摂氏)のみです。


float computeHeatIndex(float temperature, float percentHumidity) {
  float hi; // heat-index
  temperature = ((temperature * 9 / 5) + 32);

  hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) +
              (percentHumidity * 0.094));

  if (hi > 79) {
    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.05882);

    else if ((percentHumidity > 85.0) && (temperature >= 80.0) &&
             (temperature <= 87.0))
      hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
  }
  return (hi- 32) * 5/9 ;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?