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

This circuit integrates an Arduino UNO R4 WiFi microcontroller with an LCD display and a DHT11 Humidity and Temperature Sensor. The LCD display is used to show the temperature and humidity readings obtained from the DHT11 sensor. The Arduino UNO R4 WiFi is the central processing unit that reads the sensor data, processes it, and controls the LCD display to show the readings. A resistor is used for the backlight control of the LCD.

Component List

Arduino UNO R4 WiFi

LCD Display (16 pin)

DHT11 Humidity and Temperature Sensor

Resistor

Wiring Details

Arduino UNO R4 WiFi

LCD Display (16 pin)

DHT11 Humidity and Temperature Sensor

Resistor

Documented Code

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

// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// Define DHT11 pin and type
#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Set up the LCD's number of columns and rows
  lcd.begin(16, 2);
  // Initialize the DHT sensor
  dht.begin();
}

void loop() {
  // Read humidity and temperature
  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("Sensor error");
    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);
}

The code initializes the LCD and DHT11 sensor, reads the temperature and humidity, and displays the values on the LCD. If the sensor fails to read, it displays an error message.