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

Arduino UNO WiFi DHT11 Temperature and Humidity Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO WiFi DHT11 Temperature and Humidity Display

Circuit Documentation

Summary

The circuit in question is designed to interface an Arduino UNO R4 WiFi microcontroller with a DHT11 temperature and humidity sensor and an LCD display. The LCD is used to display the temperature and humidity readings obtained from the DHT11 sensor. A rotary potentiometer is included to adjust the contrast of the LCD display. The Arduino board manages the sensor data acquisition and controls the LCD display to update the readings periodically.

Component List

DHT11

LCD Display (16 pin)

Arduino UNO R4 WiFi

Rotary Potentiometer

Wiring Details

DHT11

LCD Display (16 pin)

Rotary Potentiometer

Arduino UNO R4 WiFi

Documented Code

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

// Initialize DHT sensor
#define DHTPIN 2     // DHT11 data pin connected to D2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// Initialize the LCD
const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // Start the DHT sensor
  dht.begin();
  
  // Start the LCD
  lcd.begin(16, 2);
  lcd.print("Temp: ");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
}

void loop() {
  // Read temperature and humidity
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    lcd.setCursor(6, 0);
    lcd.print("Error");
    lcd.setCursor(10, 1);
    lcd.print("Error");
    return;
  }
  
  // Print temperature and humidity to LCD
  lcd.setCursor(6, 0);
  lcd.print(t);
  lcd.print(" C");
  lcd.setCursor(10, 1);
  lcd.print(h);
  lcd.print(" %");
  
  // Wait a few seconds between measurements.
  delay(2000);
}

This code initializes the DHT11 sensor and the LCD display, then enters a loop where it reads temperature and humidity from the DHT11 sensor and displays the values on the LCD. If the sensor fails to provide valid readings, an error message is displayed instead.