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

Arduino UNO WiFi DHT11 Humidity and Temperature Display

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

Circuit Documentation

Summary

The circuit in question is designed to interface a DHT11 temperature and humidity sensor with an Arduino UNO R4 WiFi microcontroller, display the sensor readings on an LCD display, and adjust the display contrast using a rotary potentiometer. The Arduino UNO R4 WiFi is the central processing unit of the circuit, reading data from the DHT11 sensor and controlling the LCD display to show temperature and humidity values. The rotary potentiometer is used to adjust the contrast of the LCD display for better visibility.

Component List

DHT11 Temperature and Humidity Sensor

Arduino UNO R4 WiFi

LCD Display (16 pin)

Rotary Potentiometer

Wiring Details

DHT11 Temperature and Humidity Sensor

Arduino UNO R4 WiFi

LCD Display (16 pin)

Rotary Potentiometer

Documented Code

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

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

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

// Initialize the LCD (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // Start the DHT sensor
  dht.begin();
  
  // Start the LCD
  lcd.begin(16, 2);
  
  // Print a message to the LCD
  lcd.print("Temp & Humidity");
}

void loop() {
  // Wait a few seconds between measurements
  delay(2000);
  
  // 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(0, 1);
    lcd.print("Error reading");
    return;
  }
  
  // Clear the second line
  lcd.setCursor(0, 1);
  lcd.print("                ");
  
  // Set cursor to the beginning of the second line
  lcd.setCursor(0, 1);
  
  // Print temperature and humidity
  lcd.print("T:");
  lcd.print(t);
  lcd.print("C H:");
  lcd.print(h);
  lcd.print("%");
}

This code is designed to run on the Arduino UNO R4 WiFi microcontroller. It initializes the DHT11 sensor and the LCD display, reads temperature and humidity from the sensor, and displays the values on the LCD. If the sensor fails to provide valid readings, an error message is displayed.