DHT22 Heat index

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

DHT22 Heat index

Post by fmbfla »

Has any one found a way to use this sensor to calculate the Heat Index?
I've not tried anything as of yet as most code I've seen is using 2 or more separate readings/sensors and mathematically calculating the HI and with the DHT22 being one-wire I'm wondering if it is possible to use the DHT22
I've looked hi and low and only see examples of it using 2 or more separate sensors.
Thnx for any info :-)

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: DHT22 Heat index

Post by adafruit_support_bill »

The Heat Index formula is based on heat and humidity. It doesn't care if you use one sensor or two to measure them.
http://en.wikipedia.org/wiki/Heat_index

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: DHT22 Heat index

Post by fmbfla »

Thank you :-)

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: DHT22 Heat index

Post by fmbfla »

Code: Select all

//Using an Arduino R3 a DHT22, and Reading the results and calculating the Heat Index

#include <DHT.h>// ADAfruit Library
#define DHTTYPE DHT22 // Tell the Duino which DHT ver you have 11 or 22
#define DHTPIN (A2) // Tell the Duino that the DHT is on Analog pin 2
DHT dht(DHTPIN, DHTTYPE);

// Heat Index Function
// http://en.wikipedia.org/wiki/Heat_index
double heatIndex(double Temperature, double Humidity)
{
  double c1 = -42.38, c2 = 2.049, c3 = 10.14, c4 = -0.2248, c5= -6.838e-3, c6=-5.482e-2, c7=1.228e-3, c8=8.528e-4, c9=-1.99e-6 ; 
  double T = Temperature;// Your outside Temp sensor reading
  double R = Humidity;// Your Outside Humidity sensor reading
  double T2 = T*T;
  double R2 = R*R;
  double TR = T*R;
  double rv = c1 + c2*T + c3*R + c4*T*R + c5*T2 + c6*R2 + c7*T*TR + c8*TR*R + c9*T2*R2;
  return rv;
}
void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
  dht.begin();// Start the DHT22 sensor
   Serial.print("BOOTING!");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
      delay(500);
   Serial.print(".");
   Serial.println("");
   Serial.println ("getting Data..");
      delay(2000);// makes it fun looking :-)
}

void loop() {
  
  // put your main code here, to run repeatedly: 
    float Humidity =    (dht.readHumidity()); //Read the DHT humidity sensor
    float Temperature = (dht.readTemperature()* 9.0 / 5.0 + 32.0); //Read the DHT Temp sensor (OutSide)convert deg C to deg F 
    float HI =          (heatIndex(Temperature, Humidity));
    Serial.print("heatIndex   : ");
    Serial.println(HI);
    Serial.print("Outside     : ");
    Serial.println(Temperature);
    Serial.print("Humidity    : ");
    Serial.println(Humidity);
    delay(1000);//slow it down a bit so you can read it.
}

User avatar
hatters
 
Posts: 2
Joined: Tue Mar 15, 2016 7:35 am

Re: DHT22 Heat index

Post by hatters »

Hi fmbfla,

is it required to to make the conversion to Fahrenheit for Heat Index Function to work properly?

If I am working in Celsius, can i skip the conversion and still have the heat index properly calculated?

Many thanks in advance for your kind cooperation,

Hatters

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: DHT22 Heat index

Post by adafruit_support_bill »

That formula assumes that the temperatures are in Fahrenheit. Converting from Fahrenheit to Celsius and back is pretty straightforward.

Fahrenheit = 1.8 * Celsius + 32;

Celsius = (Fahrenheit - 32) / 1.8;

User avatar
CGrover
 
Posts: 188
Joined: Mon Dec 07, 2015 2:52 am

Re: DHT22 Heat index

Post by CGrover »

I used the DHT library's built-in heat index function call:

float hif = dht.computeHeatIndex(f, h) ; for Fahrenheit heat index calc (default call)

float hic = dht.computeHeatIndex(c, h, false) ; for Celsius heat index calc ( isFahrenheit = false )


Where f is the measured temperature in Fahrenheit; h is the measured relative humidity; c is the measured temperature in Celsius.

User avatar
CGrover
 
Posts: 188
Joined: Mon Dec 07, 2015 2:52 am

Re: DHT22 Heat index

Post by CGrover »

Oh, and dew point is a useful parameter, too. I incorporated dew point to determine potential corrosion risk. Dew point isn't included in the library, so I used:

double c_dp = pow( (h/100.0D), (0.125D) )*(112.0D+(0.9D*c))+(0.1D*c)-112.0D ; dew point in Celsius

User avatar
hatters
 
Posts: 2
Joined: Tue Mar 15, 2016 7:35 am

Re: DHT22 Heat index

Post by hatters »

Noted, thanks a lot.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”