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

Arduino UNO R4 WiFi Temperature and Humidity Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO R4 WiFi 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 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

Arduino UNO R4 WiFi

LCD Display (16 pin)

DHT11

Resistor

Potentiometer

Wiring Details

Arduino UNO R4 WiFi

LCD Display (16 pin)

DHT11

Resistor

Potentiometer

Documented Code

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

// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

// Define DHT11 sensor pin and type
#define DHTPIN 8
#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 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, 0);
    lcd.print("Error reading");
    lcd.setCursor(0, 1);
    lcd.print("sensor data");
    return;
  }

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

  // Wait a few seconds between measurements
  delay(2000);
}

This code initializes the LCD and DHT11 sensor, reads temperature and humidity from the DHT11, and displays the readings on the LCD. If the sensor fails to provide valid readings, an error message is displayed. The temperature is displayed in degrees Celsius, and the humidity is displayed as a percentage. Measurements are updated every 2 seconds.