Compute Heat Index with Arduino and DHT Sensor

 Author:   Posted on:   Updated on:  2019-06-16T12:50:09Z

Using an Arduino with LCD display and DHT11 or DHT22 temperature and humidity sensor to compute heat index (humiture).

The heat index is a parameter that takes into account temperature and relative humidity, to determine the apparent temperature or the human perceived equivalent temperature. Heat index was developed in 1978 by George Winterling and was adopted next year. It is also known as humiture, according to Wikipedia contributors.

To compute this index, you need to know current temperature and relative humidity. An easy way to find both is by using an Arduino development board with a DHT sensor (DHT11, DHT22). These sensors measure temperature and humidity and send it to the microcontroller using a digital protocol. Thus, there is no need for calibration. You can read the values directly from the sensor module. However, you should take into account that the accuracy of these sensors is not the best. DHT11 has an accuracy of +/-5% for humidity and +/-2 degrees Celsius for temperature. DHT22 (AM2302) is slightly better with an accuracy of +/-2% for humidity and +/-0.5 degrees Celsius for temperature. More than that, DHT22 has extended ranges for both temperature and humidity.

Compute Heat Index with Arduino and DHT Sensor

There is also the option to use Bosch BME280 sensor for this purpose. This one is a bit more expensive, but it has better accuracy and can measure atmospheric pressure. A different library is needed and a level shifter is required with 5 V development boards since BME280 is a 3.3 V device. Besides the sensor, you need some way of displaying the heat index value. I used an alphanumeric LCD, but for a test setup, you can send data through serial port. For a quick indication, my circuit also contains three LEDs that turn on depending on heat index value. If you want, you can extend this project by adding a RTC module and SD card to log temperature and humidity data over time. Or you can replace the development board with one that has network (internet) connectivity.

Schematic of humiture calculator with DHT22

Schematic of humiture calculator with DHT22

The LCD is connected to the development board using 4 data wires (D4-D7) and two control signals (E, RS). A trimmer potentiometer is used to adjust contrast and a 220-470 ohms resistor is connected in series with the backlight LED. The sensor is powered from 5 V and its data pin needs to be pulled-up with a resistor. If you're using a module (breakout) with this sensor, the resistor is fitted on the module PCB.

Once you got all this together on the breadboard, you need to program the Arduino. Heat index formula is not that easy. The equations were developed by Rothfusz and Steadman and you can find them at National Weather Service. Luckily, both equations are included in Adafruit DHT library. You can install this library from Arduino IDE using the Library Manager Ctrl+Shift+I. You need Adafruit Unified Sensor too. The code becomes very easy now. At the beginning of the sketch, we declare the sensor and set its data pin and type.

#define SENSOR_PIN   2

DHT sensor(SENSOR_PIN, DHT22);

If using DHT11, replace the second argument of sensor declaration with DHT11. For BME280, a different library is needed. Still, you can use DHT library only for humiture calculation.

  t = sensor.readTemperature(false);
  h = sensor.readHumidity();
  hi = sensor.computeHeatIndex(t, h, false);

The above code gets temperature, humidity and heat index in Celsius degrees. By setting the argument to true, we can get Fahrenheit values from sensor. The sketch displays temperature and humiture in Celsius degrees if #define CELSIUS_DEGREES is found. Delete or comment this line to display Fahrenheit degrees.

There are also three indicator LEDs in this circuit. All LEDs are off as long as heat index is less than 27 degrees Celsius (80 degrees Fahrenheit). The green LED turns on when heat index is below 32 degrees Celsius (90 degrees Fahrenheit) to indicate caution level. When humiture exceeds this, but it is less than 41 degrees Celsius (105 degrees Fahrenheit) extreme caution is indicated by turning on yellow LED. At last, when humiture exceeds 41 degrees Celsius (105 degrees Fahrenheit), the red LED indicates danger. These thresholds can be found on Wikipedia.

Humiture equations can be found in library code (MIT license). Adafruit library implements both Rothfusz regression and Steadman equation.

Resources

2 comments :

  1. sensor.readTemperature (false) is in Fahrenheit and () or (true) is in Celsius
    Study the Adafruit DHT library twice before spreading incorrect info

    ReplyDelete
    Replies
    1. You're the one who should study the DHT library from Adafruit.

      By default, the first argument of readTemperature is false, according to https://github.com/adafruit/DHT-sensor-library/blob/master/DHT.h#L51.

      When this argument is set to true, the conversion from C to F takes place according to the conditional found at https://github.com/adafruit/DHT-sensor-library/blob/bcb7767e4f70c8f99ee4ca544f24a4d4932462e0/DHT.cpp#L114.

      Delete

Please read the comments policy before publishing your comment.