Skip to content

Instantly share code, notes, and snippets.

@shazin
Created March 3, 2016 15:36
Show Gist options
  • Save shazin/921636b72fdcf6f86aa2 to your computer and use it in GitHub Desktop.
Save shazin/921636b72fdcf6f86aa2 to your computer and use it in GitHub Desktop.
#include <dht.h>
#include <LiquidCrystal.h>
#define DHT11_PIN 8
dht DHT;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(8, 2);
Serial.begin(9600);
lcd.clear();
}
void loop() {
lcd.clear();
Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
case DHTLIB_ERROR_CONNECT:
Serial.print("Connect error,\t");
break;
case DHTLIB_ERROR_ACK_L:
Serial.print("Ack Low error,\t");
break;
case DHTLIB_ERROR_ACK_H:
Serial.print("Ack High error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
lcd.setCursor(0,0);
lcd.print("Tem:");
lcd.print((int) DHT.temperature);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Hum:");
lcd.print((int) DHT.humidity);
lcd.print("%");
delay(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment