How to use humidity and temparature (DH11) sensor




Materials:- 


Diagram:-




Connections:-

 LCD display to Arduino
  • LCD Vss = Arduino GND
  • LCD VDD = Arduino 5V
  • LCD V0 = Potentiometer center pin
  • LCD RS = Digital pin  3
  • LCD RW = Arduino GND
  • LCD E =   Digital pin 4
  • LCD D4 = Arduino digital pin  5
  • LCD D5  = Arduino digital pin 6
  • LCD D6 = Arduino digital pin 7
  • LCD D7 = Arduino digital pin 8
  • LCD A = Arduino  5V
  • LCD K = Arduino GND
DH11 to Arduino
  • DH11 VCC = Arduino 5V
  • DH11 GND = Arduino GND
  • DHT11 out = Arduino A0
Potentiometer to Arduino
  • Potentiometer Left = Arduino 5V
  • Potentiometer Right = Arduino GND
  • Potentiometer Center = LCD V0

Downloads:-

Code


#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
#define dhtpin A0// the output pin of DH11
dht DHT;
void setup() {
  Serial.begin(9600);
 lcd.begin(16,2);
}

void loop() {
  int val= DHT.read11(7);
 int cel= DHT.temperature;
 int humi=DHT.humidity;

  lcd.print("Temperature: ");
  lcd.print(cel);// display the temperature
  lcd.print((char)223);
  lcd.setCursor(0, 1);
  lcd.print("humidity:  ");
  lcd.print(humi); // display the humidity
  delay(1000);
  lcd.clear();
}