Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Temperature and Humidity Display with DHT11 and LCD

Image 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

  • Description: A microcontroller board based on the ATmega328P.
  • Purpose: Acts as the central processing unit of the circuit, reading sensor data and controlling the LCD display.
  • Pins Used: IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0.

16X2 LCD

  • Description: A liquid crystal display capable of displaying 16 characters per line across 2 lines.
  • Purpose: To visually present the temperature and humidity data read from the DHT11 sensor.
  • Pins Used: VSS, VDD, V0, RS, RW, E, D0, D1, D2, D3, D4, D5, D6, D7, A, K.

DHT11

  • Description: A basic, ultra low-cost digital temperature and humidity sensor.
  • Purpose: To measure the ambient temperature and humidity.
  • Pins Used: DATA, GND, VCC.

Wiring Details

Arduino UNO

  • 5V supplies power to the 16X2 LCD (VDD) and DHT11 (VCC).
  • GND is connected to the 16X2 LCD (VSS, K, RW) and DHT11 (GND).
  • A0 is connected to the 16X2 LCD (V0) for contrast adjustment.
  • D12 is connected to the 16X2 LCD (RS) for register select.
  • D11 is connected to the 16X2 LCD (E) for enabling the LCD.
  • D8 is connected to the DHT11 (DATA) for data transmission.
  • D5, D4, D3, D2 are connected to the 16X2 LCD (D4, D5, D6, D7) for data lines.

16X2 LCD

  • VDD and A are connected to the 5V supply from the Arduino UNO.
  • VSS, K, and RW are connected to GND on the Arduino UNO.
  • V0 is connected to the A0 pin on the Arduino UNO for contrast adjustment.
  • RS is connected to D12 on the Arduino UNO.
  • E is connected to D11 on the Arduino UNO.
  • D4, D5, D6, D7 are connected to D5, D4, D3, D2 on the Arduino UNO respectively.

DHT11

  • VCC is connected to the 5V supply from the Arduino UNO.
  • GND is connected to GND on the Arduino UNO.
  • DATA is connected to D8 on the Arduino UNO.

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.