Arduino UNO R4 WiFi Controlled LCD Temperature and Humidity Display
View and Edit Project In Cirkit Designer
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)
- Description: A 16-pin liquid crystal display for showing alphanumeric characters.
- Purpose: To display temperature and humidity data from the DHT11 sensor.
Arduino UNO R4 WiFi
- Description: A microcontroller board based on the ATmega328P with WiFi capabilities.
- Purpose: To control the LCD display and read data from the DHT11 sensor.
Resistor
- Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
- Properties: 220 Ohms resistance.
- Purpose: To limit the current flowing through the LCD backlight.
Potentiometer
- Description: A three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider.
- Purpose: To adjust the contrast of the LCD display.
DHT11
- Description: A basic, ultra low-cost digital temperature and humidity sensor.
- Purpose: To measure the temperature and humidity in the environment.
Wiring Details
LCD Display
- VSS, R_W, K: Connected to ground (GND).
- VDD: Connected to 5V through a 220 Ohm resistor.
- VO: Connected to the output of the potentiometer for contrast adjustment.
- RS: Connected to digital pin D7 of the Arduino UNO R4 WiFi.
- E: Connected to digital pin D8 of the Arduino UNO R4 WiFi.
- DB4: Connected to digital pin D9 of the Arduino UNO R4 WiFi.
- DB5: Connected to digital pin D10 of the Arduino UNO R4 WiFi.
- DB6: Connected to digital pin D11 of the Arduino UNO R4 WiFi.
- DB7: Connected to digital pin D12 of the Arduino UNO R4 WiFi.
- A: Connected to 5V through a 220 Ohm resistor for backlight.
Arduino UNO R4 WiFi
- GND: Connected to the ground pins of the LCD display, potentiometer, and DHT11 sensor.
- 5V: Connected to the VDD pin of the LCD display and VCC pin of the potentiometer.
- D7, D8, D9, D10, D11, D12: Connected to the corresponding data and control pins of the LCD display.
- D2: Connected to the signal pin (S) of the DHT11 sensor.
Resistor
- Pin1: Connected to the VDD pin of the LCD display.
- Pin2: Connected to the A pin of the LCD display.
Potentiometer
- GND: Connected to ground.
- Output: Connected to the VO pin of the LCD display for contrast control.
- VCC: Connected to 5V.
DHT11
- 5V: Connected to 5V.
- S: Connected to digital pin D2 of the Arduino UNO R4 WiFi.
- GND: Connected to ground.
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.