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
| DHT22 Pin | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| DATA | Pin 15 (A1) |
👉 Use a 10k pull-up resistor between VCC and DATA (recommended)
🔌 I2C LCD Connections
| LCD Pin | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
4. Detailed Step By Step Circuit Working
- The DHT22 sensor measures temperature and humidity.
- Arduino reads the sensor data every 2 seconds.
- Data is processed and checked for validity.
- The I2C LCD displays:
- Temperature in °C
- Humidity in %
- If sensor fails:
- Error message is displayed
- 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 humidityWire.h→ I2C communicationLiquidCrystal_I2C.h→ LCD control
Working Flow:
- Initialize sensor and LCD
- Read humidity and temperature
- Check if values are valid using
isnan() - Display values on LCD
- Print data on Serial Monitor
- Compare temperature with threshold
- Display warning if temperature exceeds limit
8. Tips
- If LCD not working:
- Change address from
0x27to0x3F
- Change address from
- 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.