Translate

Arduino Temperature and Humidity Monitor using DHT22 and I2C LCD

 1. Introduction

Monitoring environmental conditions like temperature and humidity is very important in modern applications such as smart homes, agriculture, weather stations, and industrial automation.

In this project, we build a real-time temperature and humidity monitoring system using:

  • DHT22 sensor (high accuracy)
  • 16x2 I2C LCD display (less wiring)
  • Arduino as the controller

The system continuously reads data and displays it on the LCD, along with serial monitoring for debugging.


2. Components

  • Arduino Uno
  • DHT22 Temperature & Humidity Sensor
  • 16x2 I2C LCD Display
  • Jumper wires
  • Breadboard
  • USB cable

3. Circuit and Connections

Circuit Diagram
Circuit Diagram

Pin Diagram
Pin Diagram

Pin-out Diagram DHT22
Pin-out Diagram DHT22

Pinout Diagram of LCD with I2C
PIN-OUT Diagram LCD WITH I2C

🔌 DHT22 Connections

DHT22 PinArduino
VCC5V
GNDGND
DATAPin 15 (A1)

👉 Use a 10k pull-up resistor between VCC and DATA (recommended)


🔌 I2C LCD Connections

LCD PinArduino
VCC5V
GNDGND
SDAA4
SCLA5

4. Detailed Step By Step Circuit Working

  1. The DHT22 sensor measures temperature and humidity.
  2. Arduino reads the sensor data every 2 seconds.
  3. Data is processed and checked for validity.
  4. The I2C LCD displays:
    • Temperature in °C
    • Humidity in %
  5. If sensor fails:
    • Error message is displayed
  6. If temperature exceeds threshold:
    • Warning message is printed in Serial Monitor

5. Libraries to be Included

#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

6. Code

#include "DHT.h" #include <Wire.h> #include <LiquidCrystal_I2C.h> #define DHTPIN 15 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); LiquidCrystal_I2C lcd(0x27, 16, 2); const float TEMP_THRESHOLD = 35.0; void setup() { Serial.begin(115200); Serial.println("--- SYSTEM STARTED ---"); dht.begin(); lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Reading data..."); } void loop() { delay(2000); float humidity = dht.readHumidity(); float temperature = dht.readTemperature(); if (isnan(humidity) || isnan(temperature)) { Serial.println("Error: Sensor read failed!"); lcd.setCursor(0, 0); lcd.print("Sensor Error! "); return; } Serial.print("Temperature: "); Serial.print(temperature); Serial.print(" C | Humidity: "); Serial.print(humidity); Serial.println(" %"); lcd.setCursor(0, 0); lcd.print("Temp: "); lcd.print(temperature, 1); lcd.print(" C "); lcd.setCursor(0, 1); lcd.print("Humidity: "); lcd.print(humidity, 1); lcd.print(" % "); if (temperature > TEMP_THRESHOLD) { Serial.println("WARNING: High Temperature!"); } else { Serial.println("Status: Normal"); } Serial.println("----------------------"); }

7. Detailed Step By Step Code Working

  • DHT.h → Reads temperature and humidity
  • Wire.h → I2C communication
  • LiquidCrystal_I2C.h → LCD control

Working Flow:

  1. Initialize sensor and LCD
  2. Read humidity and temperature
  3. Check if values are valid using isnan()
  4. Display values on LCD
  5. Print data on Serial Monitor
  6. Compare temperature with threshold
  7. Display warning if temperature exceeds limit

8. Tips

  • If LCD not working:
    • Change address from 0x27 to 0x3F
  • Use pull-up resistor (10k) for stable DHT readings
  • Keep wires short to avoid noise
  • Use external power for stable performance

9. Uses

  • Weather monitoring systems
  • Smart home automation
  • Greenhouse monitoring
  • Industrial temperature control
  • IoT-based environmental systems

10. Conclusion

This project demonstrates how to interface DHT22 sensor and I2C LCD with Arduino to build a simple yet powerful monitoring system. It is a great project for students to learn sensor interfacing, I2C communication, and real-time data display.

à´¤ുà´Ÿà´•്à´•à´•്à´•ാർക്à´•ാà´¯ി ഇലക്à´Ÿ്à´°ോà´£ിà´•്à´¸് ലളിതമാà´¯ി പഠിà´•്à´•ാം.

Empowering students in Kerala with hands-on technical skills.