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

Arduino UNO R4 WiFi Controlled LCD Temperature and Humidity Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO R4 WiFi Controlled LCD Temperature and Humidity Display

Circuit Documentation

Summary

This circuit integrates an Arduino UNO R4 WiFi microcontroller with an LCD display and a DHT11 temperature and humidity sensor. The LCD display is used to show the temperature and humidity readings obtained from the DHT11 sensor. A potentiometer is included to adjust the contrast of the LCD, and a resistor is used to limit the current to the backlight of the LCD.

Component List

LCD Display (16 pin)

Arduino UNO R4 WiFi

Resistor

Potentiometer

DHT11

Wiring Details

LCD Display

Arduino UNO R4 WiFi

Resistor

Potentiometer

DHT11

Documented Code

/*
 * This Arduino sketch reads temperature and humidity data from a DHT11 sensor
 * and displays the values on a 16x2 LCD screen. The LCD is connected to the
 * Arduino UNO R4 WiFi, and the DHT11 sensor is also connected to the Arduino.
 */

#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 sensor pin and type
#define DHTPIN 2
#define DHTTYPE DHT11

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

void setup() {
  // Set up the LCD's number of columns and rows
  lcd.begin(16, 2);
  // Print a message to the LCD
  lcd.print("Temp:    C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity:   %");
  // Initialize the DHT sensor
  dht.begin();
}

void loop() {
  // Read temperature as Celsius
  float temp = dht.readTemperature();
  // Read humidity
  float humidity = dht.readHumidity();
  // Check if any reads failed and exit early (to try again)
  if (isnan(temp) || isnan(humidity)) {
    lcd.setCursor(0, 0);
    lcd.print("Error reading");
    lcd.setCursor(0, 1);
    lcd.print("sensor data");
    return;
  }
  // Display temperature
  lcd.setCursor(6, 0);
  lcd.print(temp);
  lcd.print(" "); // Clear any extra characters
  // Display humidity
  lcd.setCursor(10, 1);
  lcd.print(humidity);
  lcd.print(" "); // Clear any extra characters
  // Wait a few seconds between measurements
  delay(2000);
}

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