#include <SimpleDHT.h>
#include <LiquidCrystal.h> // include the libraries
LiquidCrystal lcd(7,8,9,10,11,12); //start the lcd code
byte customChar[8] = { // make a degrees symbol
0b00110,
0b01001,
0b01001,
0b00110,
0b00000,
0b00000,
0b00000,
0b00000
};
// for DHT11,
// VCC: 5V or 3V
// GND: GND
// DATA: 2
//for lcd follow picture because wiring is more complex
int pinDHT11 = 2;
SimpleDHT11 dht11;
void setup() {
Serial.begin(9600);
lcd.createChar(0, customChar);
lcd.begin(16, 2);
}
void loop() {
// start working...
// read without samples.
byte temperature = 0;
byte humidity = 0;
if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
lcd.print("Read DHT11 failed.");
return;
}
lcd.print((int)temperature * 1.8 + 32); lcd.write((uint8_t)0);
lcd.print("Fahrenheit"); // write the temperature note: just delete * 1.8 + 32 //to display
// in celcius
lcd.setCursor(0, 1); // now write on the bottom line
lcd.print((int)humidity); lcd.println("%Humidity");
// DHT11 sampling rate is 1HZ.
delay(1000);
lcd.clear();
}
Comments