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

Arduino UNO with DHT11 Sensor and I2C LCD Display Temperature and Humidity Monitor

Image of Arduino UNO with DHT11 Sensor and I2C LCD Display Temperature and Humidity Monitor

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with a DHT11 Humidity and Temperature Sensor and an LCD screen (16x2 with I2C interface) to display environmental data. The Arduino UNO reads the temperature and humidity from the DHT11 sensor and outputs the readings to the LCD screen. The LCD uses the I2C communication protocol, which simplifies the wiring by using only two data lines.

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: 5V, GND, A4 (SDA), A5 (SCL), D2.

DHT11 Humidity and Temperature Sensor

  • Description: A basic, low-cost digital temperature and humidity sensor.
  • Purpose: Measures the ambient temperature and humidity.
  • Pins Used: VDD, DATA, GND.

LCD screen 16x2 I2C

  • Description: A 16-character by 2-line display with an I2C interface.
  • Purpose: Displays the temperature and humidity readings from the DHT11 sensor.
  • Pins Used: SCL, SDA, VCC, GND.

Wiring Details

Arduino UNO

  • 5V to DHT11 VDD and LCD VCC.
  • GND to DHT11 GND and LCD GND.
  • A4 (SDA) to LCD SDA.
  • A5 (SCL) to LCD SCL.
  • D2 to DHT11 DATA.

DHT11 Humidity and Temperature Sensor

  • VDD connected to Arduino UNO 5V.
  • DATA connected to Arduino UNO D2.
  • GND connected to Arduino UNO GND.

LCD screen 16x2 I2C

  • SCL connected to Arduino UNO A5.
  • SDA connected to Arduino UNO A4.
  • VCC connected to Arduino UNO 5V.
  • GND connected to Arduino UNO GND.

Documented Code

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

// Initialize the DHT11 sensor
#define DHTPIN 2     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

// Initialize the LCD on address 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize the LCD and DHT11 sensor
  lcd.init();
  lcd.backlight();
  dht.begin();
}

void loop() {
  // Read humidity and temperature values
  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.clear();
    lcd.print("Failed to read");
    return;
  }

  // Display the humidity and temperature on the LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print("%");

  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print("C");

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

This code is designed to run on the Arduino UNO microcontroller. It initializes the DHT11 sensor and the LCD screen, reads the temperature and humidity data from the sensor, and displays the readings on the LCD. If the sensor fails to provide valid readings, an error message is displayed. The measurements are updated every two seconds.