     //Particle.publish("DEBUG", "Failed to read from DHT sensor!");
     return -1;
   }
-  // get the felt temperature only if relevant: humidity readings
-  // tend to be skewed towards excessively low values, and in that
-  // case the calculate heat index may become inaccurate
-  if(temp > 25 && hum > 25) {
-    hi = dht.getHeatIndex();
+  // apply a correction factor to the humidity reading, following
+  // experimental observations: the factor is 2 up to 30C and 2.2 at 40C
+  hum = hum * (2 + (temp > 30 ? (temp-30)/50 : 0));
+  // get the felt temperature only when it makes sense
+  if(temp >= 25 && hum >= 35) {
+    // this equation comes from the DHT library at:
+    // https://github.com/zackzachariah/hacknest/blob/master/sensor/Adafruit_DHT.cpp
+    float tempF = dht.getTempFarenheit();
+    hi = ((-42.379 +
+             2.04901523 * tempF +
+            10.14333127 * hum +
+            -0.22475541 * tempF * hum +
+            -0.00683783 * pow(tempF, 2) +
+            -0.05481717 * pow(hum, 2) +
+             0.00122874 * pow(tempF, 2) * hum +
+             0.00085282 * tempF * pow(hum, 2) +
+            -0.00000199 * pow(tempF, 2) * pow(hum, 2)
+          ) - 32) * 5/9;    // convert back to Celsius
   }
   else {
     hi = 0.0;

}


void readout(bool button) {
  http_request_t request;
  http_response_t response;
  // wake up WiFi

/******************************************************************************
 * Project THDweeter
 * Description: temperature & umidity dweeter
 * Author: Giuseppe Lo Presti, glopresti@gmail.com
