Example #1
0
float COZIR::HeatIndex(float temperature, float percentHumidity, bool isFahrenheit)
{
  float hi, a1, a2;

  if(!isFahrenheit) temperature = Fahrenheit();

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

  a1 = ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.0588);
  a2 = ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
  if(hi>= 80){
    hi = -42.379+ (2.0490152 * temperature) +
                    (10.14333127 * percentHumidity) -
                    (0.22475541 * temperature * percentHumidity) -
                    (0.00683783 * temperature * temperature) -
                    (0.05481717 * percentHumidity * percentHumidity) +
                    (0.00122874 * temperature * temperature * percentHumidity) +
                    (0.00085282 * temperature * percentHumidity * percentHumidity) -
                    (0.00000199 * temperature * temperature * percentHumidity * percentHumidity);

    //case1
    if((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0)) hi -= a1;
    else if ((percentHumidity > 85) && (temperature >= 80.0) && (temperature <= 87.0)) hi += a2;

  }

  return isFahrenheit? hi : convertFtoC(hi);
}
Example #2
0
void loop()
{
    Serial.println("\n");

    int chk = DHT11.read(DHT11PIN);

    Serial.print("Read sensor: ");
    switch (chk)
    {
    case 0:
        Serial.println("OK");
        break;
    case -1:
        Serial.println("Checksum error");
        break;
    case -2:
        Serial.println("Time out error");
        break;
    default:
        Serial.println("Unknown error");
        break;
    }

    Serial.print("Humidity (%): ");
    Serial.println((float)DHT11.humidity, 2);

    Serial.print("Temperature (oC): ");
    Serial.println((float)DHT11.temperature, 2);

    Serial.print("Temperature (oF): ");
    Serial.println(Fahrenheit(DHT11.temperature), 2);

    Serial.print("Temperature (K): ");
    Serial.println(Kelvin(DHT11.temperature), 2);

    Serial.print("Dew Point (oC): ");
    Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));

    Serial.print("Dew PointFast (oC): ");
    Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));

    delay(2000);
}