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

Arduino UNO Based Temperature and Humidity Display with DHT11 and LCD

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Temperature and Humidity Display with DHT11 and LCD

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with a 16x2 LCD display and a DHT11 temperature and humidity sensor. The Arduino UNO is responsible for controlling the LCD to display the temperature and humidity readings obtained from the DHT11 sensor. The LCD is powered by the 5V supply from the Arduino and communicates with the Arduino through digital pins for data and control signals. The DHT11 sensor is connected to a digital pin on the Arduino for data transmission.

Component List

Arduino UNO

16X2 LCD

DHT11

Wiring Details

Arduino UNO

16X2 LCD

DHT11

Documented Code

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

// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Define the DHT11 sensor pin and type
#define DHTPIN 8
#define DHTTYPE DHT11

// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Start the LCD
  lcd.begin(16, 2);
  lcd.print("Initializing...");

  // Start the DHT sensor
  dht.begin();

  // Clear the LCD
  lcd.clear();
}

void loop() {
  // Read temperature and humidity from DHT11
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(humidity) || isnan(temperature)) {
    lcd.setCursor(0, 0);
    lcd.print("Failed to read");
    lcd.setCursor(0, 1);
    lcd.print("from DHT sensor");
    return;
  }

  // Print temperature and humidity to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");

  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print(" %");

  // Wait a few seconds between measurements.
  delay(2000);
}

This code initializes the LCD and DHT11 sensor, then enters a loop where it reads temperature and humidity data from the DHT11 sensor and displays it on the LCD. If the sensor fails to provide valid readings, an error message is displayed. The loop includes a delay to space out the readings.