ArduinoDHT11SensorTest

#include <dht11.h>

dht11 DHT11;

#define DHT11PIN A0
#define TEMPHIGH 24
#define TEMPLOW 22
#define HUMIDITYHIGH 50
#define HUMIDITYLOW 49

#define RELAY1 5
#define RELAY2 6
#define RELAY3 7
#define RELAY4 8

void setup()
{
  Serial.begin(9600);
  Serial.println("DHT11 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
  Serial.println();
  delay(2000);
  pinMode(RELAY1, OUTPUT);//digitalWrite(RELAY1, HIGH);
  pinMode(RELAY2, OUTPUT);//digitalWrite(RELAY2, HIGH);
  pinMode(RELAY3, OUTPUT);//digitalWrite(RELAY3, HIGH);
  pinMode(RELAY4, OUTPUT);//digitalWrite(RELAY4, HIGH);
}

double Fahrenheit(double celsius)
{
  return 1.8 * celsius + 32;
}

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);

  if(DHT11.temperature > TEMPHIGH)
  {
    Serial.print("Temperature HIGH");
    digitalWrite(RELAY1, HIGH);
  }
  if(DHT11.temperature < TEMPLOW)
  {
    Serial.print("Temperature LOW");
    digitalWrite(RELAY1, LOW);
  }
  if(DHT11.humidity > HUMIDITYHIGH)
  {
    Serial.print("humidity HIGH");
    digitalWrite(RELAY2, HIGH);
  }
  if(DHT11.humidity < HUMIDITYLOW)
  {
    Serial.print("humidity LOW");
    digitalWrite(RELAY2, LOW);
  }


  delay(2000);
}