• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » How to Measure Humidity and Temperature using Arduino and DHT11

How to Measure Humidity and Temperature using Arduino and DHT11

Last updated on 20 August 2024 by Admin-Lavi Leave a Comment

If we want to know how hot and humid it is, we can use an Arduino, a sensor called DHT11, a resistor and a LCD display to show the numbers.

The DHT11 sensor will measure the temperature in degrees Celsius and the humidity as a percentage.

The Arduino will understand the sensor and show the results on the LCD display.

Coding and Explanation:

#include <DHT.h>
#include <LiquidCrystal.h>

// Define pins
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11

// Define LCD pins (adjust according to your connections)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Create DHT instance
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize LCD
  lcd.begin(16, 2); // Set number of columns and rows

  // Initialize DHT sensor
  dht.begin();
}

void loop() {
  // Read data from DHT sensor
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // Check if readings are valid
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;   

  }

  // Display data on LCD
  lcd.setCursor(0, 0);
  lcd.print("Humidity: ");
  lcd.print(h);
  lcd.print("%");

  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print("C");

  // Print data to serial monitor for debugging
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print("%  ");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println("C ");

  delay(2000);
}
  • Libraries for LCD and DHT are included in the code.
  • The DHT and LCD pins are specified.
  • The setup() method initializes DHT and LCD.
  • Temperature and humidity are obtained from the DHT sensor and used in the loop() method.
  • Readings are written to the serial monitor and shown on the LCD if they are correct.

Circuit Working:

How to Measure Humidity and Temperature using Arduino and DHT11

Parts List:

ComponentQuantity
Arduino UNO1
IC 78091
DHT11 Sensor1
LCD Display 16×21
Resistor 1/4 watt 470Ω1

In this article DHT11 sensor, a unique component is used.

This section provides us with a temperature and moisture content measurement.

It resembles a single sensor that measures temperature and humidity.

This component provides us with accurate figures and has a lengthy operational life.

It contains a little computer inside and measures things using a unique method.

It is inexpensive and simple to use.

It uses signals, like as brief blinks, to communicate with the Arduino.

It requires our command to begin, and it need some time to complete its task.

The DHT11 sensors data is read by the microcontroller, which then processes and transmits it to the LCD.

LCD shows the temperature and humidity readings that have been measured.

Resistor 470Ω is to control the backlight illumination of the LCD.

How to Build:

To Measure Humidity and Temperature using Arduino and DHT11 following are the steps to follow:

  • Gather all the components mentioned in the above circuit diagram.
  • Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board
  • Connect a resistor 470Ω from LCD backlight anode to Arduino 5V.

Connections for DTH11 sensor:

  • Connect the DHT11s VCC pin to the Arduinos 5V pin.
  • Connect the DHT11s GND pin to the Arduinos GND pin.
  • Connect the DHT11s DATA pin to digital pin on the Arduino pin 2

Connections for LCD display to Arduino board:

  • Connect LCD VDD 5V pin to Arduino 5V
  • Connect LCD VSS GND pin to Arduino GND
  • Connect RS (Register Select) pin to Arduino digital pin 12
  • Connect R/W (Read/Write) pin to Arduino GND
  • Connect Enable (E) to Arduino digital pin 11
  • Connect D4 pin to Arduino digital pin 5
  • Connect D5 pin to Arduino digital pin 4
  • Connect D6 pin to Arduino digital pin 3
  • Connect D7 pin to Arduino digital pin 2

Conclusion:

The following tutorial effectively illustrates the use of an Arduino, DHT11 sensor, and LCD display for temperature and humidity measurement.

A basic foundation for data gathering and presentation is provided by the code, which may be extended for more sophisticated applications.

References:

Using DHT11 temp. and humidity sensor to measure & display the temp and humidity using an LCD without using any external libraries

Filed Under: Arduino Projects, Sensors and Detectors

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « Simple LED Flashing Circuit with Arduino Uno
Next Post: Arduino Temperature Controller Circuit using DC Fan »

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Categories

  • Alarm Circuits (30)
  • Amplifier Circuits (67)
  • Arduino Projects (29)
  • Audio Circuits (93)
  • Automobile Circuits (19)
  • Battery Charger Circuits (48)
  • Free Energy (13)
  • Heater and Temperature Controllers (9)
  • Indicator Circuits (38)
  • Inverter Circuits (13)
  • LDR Circuits (13)
  • LED and Lamps (111)
  • Meters and Testers (27)
  • Motor Controllers (18)
  • Oscillator Circuits (32)
  • Power Supply Circuits (91)
  • Remote Control Circuits (6)
  • Security and Protection (23)
  • Sensors and Detectors (71)
  • Solar Circuits (16)
  • Timer Circuits (27)
  • Transistor Circuits (56)
  • Transmitter Circuit (12)
  • Tutorials (4)
  • Water Level Controller (4)

Copyright © 2025 | New Circuit Ideas