DHT11 Temperature and Humidity Sensor Arduino Code with LCD Display

Share This

Hello friends! Welcome back to ElectroDuino. This blog is based on DHT11 Temperature and Humidity Sensor Arduino Code with LCD Display. Here we will discuss Introduction Temperature and Humidity Monitoring System, Circuit diagram, Working and DHT11 Temperature and Humidity sensor Arduino Code with LCD Display.

Introduction

In the previous blog posts, we were learning about the “DHT11 Temperature and Humidity Sensor Module” and “Interfacing DHT11 with Arduino”. In this project, we will discuss how to make a Temperature and Humidity Monitoring System. Where we will print the Temperature and Humidity value on a 16×2 LCD display using DHT11 and Arduino. DHT11 is the cheapest humidity and temperature sensor, it provides high reliability and long-term stability output. This is a very small and portable Temperature and Humidity Monitoring system so we can use it at home, office, school, etc. places. It gives us the Temperature and Humidity value of around it 24 x7. Here we will build this system and learn how to write the DHT11 Temperature and Humidity Sensor Arduino Code with LCD Display.

You can also see:

Components Required

Components NameQuantity
Arduino UNO (you can use other types of Arduino like Arduino Nano, MEGA, pro mini, etc)1
Arduino USB Cable (USB A to B)
1
DHT11 Temperature and Humidity Sensor Module1
16×2 LCD Display Module1
10k Potentiometer1
220 ohm Resistor1
Slide Switch (SW1)1
9V Power Supply 
Connecting wiresAs required in the circuit diagram

Circuit Diagram of DHT11 Temperature and Humidity Sensor Arduino with LCD Display

DHT11 Temperature and Humidity Sensor Arduino with LCD Display Circuit Diagram
DHT11 Temperature and Humidity Sensor Arduino with LCD Display Circuit Diagram

Circuit Wiring

Components PinArduino pin
DHT11 sensor VCC pin, LCD  Display (Vdd, LED +) Pins Arduino 5V Pin, but LCD  Display LED + Pins connected to Arduino 5V Pin through 220ohm resistor.
DHT11 sensor GND pin, LCD  Display (Vss, Rw and LED -) PinsGND (ground) Pin
DHT11 sensor DATA pinDigital Pin “D3”
LCD  Display RS, E, D4, D5, D6, D7Respectively  Digital Pin “D12”, “D11”, “D10”, “D9”, “D8”, “D7”
LCD  Display V0 pin  10k Potentiometer Signal pin, Potentiometer one pin is connected to 5V and another pin is connected to GND(ground)
9v battery positive (+) terminalConnected to Arduino “Vin” pin through a slide switch
9v battery negative () terminalGND (ground) Pin

Library Required :

Before writing the Arduino Code we need to install two Libraries in our Arduino IDE Software, one is ” dht.h ” DHT11 sensor Library and Another one is “LiquidCrystal.h” 16×2 LCD Display Library You can Download the Library file by click on the Download Button.

Download ” dht.h ” DHT11 sensor Library:

Download Button Download LiquidCrystal.h” 16×2 LCD Display Library:Download Button
After downloading the Library, now we can install it by following few steps.
Open the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library, and then select the Library ZIP file that you just downloaded. 

DHT11 Temperature and Humidity Sensor Arduino Code with LCD Display

/* Interfacing DHT11 with Arduino
   DHT11 Temperature and Humidity sensor Arduino Code
   WWW.Electroduino.com  */
//libraries for LCD Display
#include <LiquidCrystal.h>
// Define LCD display pins
LiquidCrystal lcd(12,11,10,9,8,7);

#include <dht.h>  // Include DHT11 library
#define DATApin 2  // Defines Arduino pin which is connected to the sensor

dht DHT;      // Creates a DHT object

void setup() 
 {
  //Sets the baud for serial data transmission between Arduino and your computer
  Serial.begin(9600);

  // Print massage on LCD Display 
  lcd.clear();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Temp and Humi");
  lcd.setCursor(0,1);
  lcd.print("Monitoring System");
  delay(2000);
 }

void loop() 
 {
  // Read data from Sensor
  int readData = DHT.read11(DATApin);

  float t = DHT.temperature;  // Read Temperature in Degree Celsius unit
    
  float h = DHT.humidity;   // Read humidity

  //Print Tempareture Value on Serial Monitor Window
  Serial.print("Temperature = ");
  Serial.print(t);  // Temperature value in Degree Celsius
  Serial.print("°C");

  //Print Humidity Value on Serial Monitor Window
  Serial.print("Humidity = ");
  Serial.print(h);
  Serial.println("% ");
  Serial.println("");
  lcd.clear();
   //Print Tempareture Value on LCD Display
   lcd.setCursor(0, 0);  // start to print at the first row
   lcd.print("Temp: ");
   lcd.print(t);     // print the temperature
   lcd.print((char)223); // print ° character
   lcd.print("C");
   //Print Humidity Value on LCD Display
   lcd.setCursor(0, 1);  // start to print at the second row
   lcd.print("Humi: ");
   lcd.print(h);      // print the humidity
   lcd.print("%");

  delay(2000); // wait two seconds
}

 

Share This

Leave a Reply

Your email address will not be published. Required fields are marked *