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

Arduino UNO R4 WiFi Controlled Temperature and Humidity Display

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

Circuit Documentation

Summary

The circuit in question is designed to interface an Arduino UNO R4 WiFi 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 rotary potentiometer is included to adjust the contrast of the LCD display, and a resistor is used to provide the necessary current limiting for the backlight of the LCD.

Component List

Arduino UNO R4 WiFi

LCD Display (16 pin)

DHT11

Rotary Potentiometer

Resistor

Wiring Details

Arduino UNO R4 WiFi

LCD Display (16 pin)

DHT11

Rotary Potentiometer

Resistor

Documented Code

Arduino UNO R4 WiFi 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 sensor 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);
  // Print a message to the LCD
  lcd.print("Temp & Humidity");

  // Initialize the DHT sensor
  dht.begin();
}

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;
  }

  // Print the temperature and humidity to the LCD
  lcd.setCursor(0, 1);
  lcd.print("T: ");
  lcd.print(t);
  lcd.print("C H: ");
  lcd.print(h);
  lcd.print("%");
}

This code is responsible for initializing the LCD and DHT11 sensor, reading temperature and humidity data from the DHT11 sensor, and displaying the readings on the LCD. If the sensor fails to provide valid readings, an error message is displayed on the LCD.