Measure Humidity and Temperature with DHT11 Sensor

In this project, I will show you that how to measure room temperature and environmental humidity with a DHT11 sensor, where the Arduino measure digital data is displayed on a 16x2 LCD screen.

Let's make it!

Components List

For the interfacing DHT11 sensor with Arduino and LCD, we need the following components.
  1. KY-015 DHT11 sensor module (1 pcs)
  2. Arduino board (1 pcs)
  3. 16x2 LCD module (1 pcs)
  4. R1: 330Ω resistor (1 pcs)
  5. R2: 4.7KΩ resistor (1 pcs)
  6. Breadboard (1 pcs)
  7. Jumper wires (as per required)

Circuit Diagram

Schematic of interfacing DHT11 Humidity-Temperature sensor with Arduino and LCD showed below.

Connection Instructions

Now, after managing all require components do the following connections.
  • LCD Pins RW, K, VSS — Arduino GND
  • LCD Pin VDD — Arduino 5V
  • LCD Pin D4 — Arduino pin D5
  • LCD Pin D5 — Arduino pin D4
  • LCD Pin D6 — Arduino pin D3
  • LCD Pin D7 — Arduino pin D2
  • LCD Pin RS — Arduino pin D7
  • LCD Pin E — Arduino pin D6
  • Sensor Pin -ve — Arduino GND
  • Sensor Pin +ve — Arduino 5V
  • Sensor Pin Signal — Arduino Pin D8
  • Connect R1 between LCD pins VDD, A
  • Connect R2 between LCD pins VSS, V0

Circuit Explanation

The DHT11 sensor consists of a humidity sensing component, an NTC temperature sensor (or thermistor), and an IC on the backside of the sensor. The term "NTC" means "Negative Temperature Coefficient", which means that the resistance decreases with the increase of the temperature. Also, It has an extremely accurate calibration of the humidity calibration chamber. Its technology ensures high reliability and excellent long-term stability.

A high-performance 8-bit microcontroller i.e. Arduino is connected with a DHT11 sensor pin signal. When the circuit gets +5V DC, the sensor starts to detect the surrounding humidity and temperature and sends the digital data to the Arduino board. Then, the calculations are made in the programming part. After, the processing data values will be display on the 16x2 LCD screen.

For LCD module safety a resistor R1 is connected, and a resistor R2 to control the brightness of the display.

Installing Arduino IDE and DHT11 Sensor Libaries

First of all, you need to install the open-source Arduino Software (IDE) on your PC. It easy to write code and upload it to the board. This software can be used with any Arduino board.

To read from the DHT11 sensor, you will use the DHT sensor library from Adafruit. To use this library you also need to install the Adafruit Unified Sensor library.

Follow the following steps to install those libraries.
  • Step 1: Open your Arduino IDE and go to menu Sketch > Include Library > Manage Libraries or Press ctrl + shift + I on the keyboard. The Library Manager should open.
  • Step 2: Search for "DHT sensor library" on the Search box and install the DHT library from Adafruit.
  • Step 3: Now, type "Adafruit Unified Sensor" in the search box and install it.
  • Step 4: After, installing the libraries, restart your Arduino IDE.
  • Step 5: All Done!

Program/Source Code

The DHT11 sensor humidity and temperature measuring code/program for Arduino is given below. Copy the following code and upload it to the Arduino board.

//Arduino based Humidity and Temperature measuring system with DHT11 sensor and 16x2 LCD

#include <dht.h> //include DHT library code
#include <LiquidCrystal.h> //include LCD library code
#define DHTPIN 8 //DHT11 data pin is connected to Arduino pin 8
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); //LCD module connections (RS, E, D4, D5, D6, D7)
#define DHTTYPE DHT11 //DHT11 sensor is used
DHT dht(DHTPIN, DHTTYPE); //Initialize DHT library

char temperature[] = "Temp = 00.0 C";
char humidity[]    = "Humi = 00.0 %";

void setup() {
  lcd.begin(16, 2); //set up the LCD's number of columns and rows
void loop() {
  delay(1000); //wait 1s between readings
  byte Humi = dht.readHumidity(); //Read humidity
  byte Temp = dht.readTemperature(); //Read temperature in degree Celsius

// Check if any reads failed and exit early (to try again)
  if (isnan(Humi) || isnan(Temp)) {
    lcd.setCursor(5, 0);
  temperature[7] = Temp / 10 + 48;
  temperature[8] = Temp % 10 + 48;
  temperature[11] = 223;
  humidity[7] = Humi / 10 + 48;
  humidity[8] = Humi % 10 + 48;
  lcd.setCursor(0, 0);
  lcd.setCursor(0, 1);

Demo and Testing

Now, I simply assembled all the components and connected with the jumper wires according to the circuit diagram, and test it.

Showing a demo of this simple Arduino based Humidity and Temperature measuring system, where the data values (Temp. & Humi.) have shown on the 16x2 LCD screen.

No comments