You are on page 1of 3

#include "DHT.

h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN , DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht.begin();
}

void loop()
{
// put your main code here, to run repeatedly:
float R = dht.readHumidity();
float t =dht.readTemperature();
float T=t*(9/5)+32;
float HeatIndex = -42.379+(2.04901523*T)+(10.14333127*R)(0.22475541*T*R)-(6.83783*pow(10,-3)*pow(T,2))-(5.481717*pow(10,-2)*pow(R,2))
+(1.22874*pow(10,-3)*pow(T,2)*R)+(8.5282*pow(10,-4)*T*pow(R,2))(1.99*pow(10,-6)*pow(T,2)*pow(R,2));
if(isnan(t) || isnan(R))
{
Serial.println("Sensor disconnected");
}
else
{
Serial.print("Temperature ");

Serial.print(t);
Serial.print(" c");
Serial.println(" ");
Serial.print("Humidity ");
Serial.print(R);
Serial.print(" %");
Serial.println("");
Serial.print("Heat Index");
Serial.print(HeatIndex);
Serial.println(" ");
}
if (HeatIndex> 0 && HeatIndex<81)
{

Serial.println("Free to go out");
}
if(HeatIndex>82 && HeatIndex<90)
{

Serial.println("Caution - Not to get Exposure to Heat");


}
else if(HeatIndex>90 && HeatIndex<103)
{

Serial.println("Extreme Caution - painful contraction of a muscle" );


}

else if(HeatIndex>103 && HeatIndex<124)


{

Serial.println("Danger -Painful contraction of a muscle and possibility of Heat


Stroke");
}
else if(HeatIndex>=124)
{

Serial.println("Extreme Danger - Heat Stroke");


}
delay(1200);
}

You might also like