Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

DHT22 Temperature and Humidity Monitor with I2C LCD Display

View and Edit Project In Cirkit DesignerImage of DHT22 Temperature and Humidity Monitor with I2C LCD Display

Circuit Documentation

Summary

This circuit is designed to interface a DHT22 temperature and humidity sensor with an Arduino UNO microcontroller, displaying the readings on a 16x2 I2C LCD. The DHT22 sensor provides accurate temperature and humidity data, while the LCD allows for easy visualization of this information. A resistor is used in the circuit to ensure proper signal levels from the DHT22 sensor.


Component List

DHT22


Arduino UNO


16x2 I2C LCD


Resistor


Wiring Details

DHT22


Arduino UNO


16x2 I2C LCD


Resistor


Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2       // DHT22 data on Arduino D2
#define DHTTYPE DHT22  // DHT 22 (AM2302)

LiquidCrystal_I2C lcd(0x27, 16, 2);  // Change 0x27 to 0x3F if your module uses that address
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Initialize LCD
  lcd.init();
  lcd.backlight();
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("DHT22 Demo");
  lcd.setCursor(0, 1);
  lcd.print("Init...");
  
  // Start DHT
  dht.begin();

  delay(1500);
  lcd.clear();
}

void loop() {
  // DHT22 max sample rate ~0.5 Hz; wait at least 2s between reads
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // Celsius

  if (isnan(h) || isnan(t)) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Sensor error");
    lcd.setCursor(0, 1);
    lcd.print("Check wiring");
  } else {
    // Line 1: Temperature
    lcd.setCursor(0, 0);
    lcd.print("T:");
    printFixed(lcd, t, 1);  // one decimal
    lcd.print((char)223);   // degree symbol
    lcd.print("C   ");      // pad to clear remnants

    // Line 2: Humidity
    lcd.setCursor(0, 1);
    lcd.print("H:");
    printFixed(lcd, h, 1);
    lcd.print("%   ");
  }

  delay(2000);
}

// Helper to print fixed-point with trimming
void printFixed(LiquidCrystal_I2C &lcd, float val, uint8_t decimals) {
  char buf[12];
  dtostrf(val, 0, decimals, buf);
  lcd.print(buf);
}

This documentation provides a comprehensive overview of the circuit, detailing each component, its connections, and the code used to operate the system.