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
- Description: A microcontroller board based on the ATmega328P with integrated WiFi capabilities.
- Purpose: Acts as the central processing unit for reading sensor data and controlling the LCD display.
LCD Display (16 pin)
- Description: A 16x2 character LCD display for showing alphanumeric characters.
- Purpose: Displays the temperature and humidity readings from the DHT11 sensor.
DHT11 Humidity and Temperature Sensor
- Description: A basic, ultra low-cost digital temperature and humidity sensor.
- Purpose: Measures the ambient temperature and humidity.
Resistor
- Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
- Value: 220 Ohms
- Purpose: Limits current to the LCD backlight.
Wiring Details
Arduino UNO R4 WiFi
- 5V connected to LCD Display VDD and DHT11 VDD.
- GND connected to LCD Display VSS, K, R_W, and DHT11 GND.
- D7 connected to LCD Display RS.
- D8 connected to LCD Display E.
- D9 connected to LCD Display DB4.
- D10 connected to LCD Display DB5.
- D11 connected to LCD Display DB6.
- D12 connected to LCD Display DB7.
- D2 connected to DHT11 DATA.
LCD Display (16 pin)
- VSS connected to Arduino GND.
- VDD connected to Arduino 5V.
- VO connected to one end of the Resistor.
- RS connected to Arduino D7.
- R_W connected to Arduino GND.
- E connected to Arduino D8.
- DB4 connected to Arduino D9.
- DB5 connected to Arduino D10.
- DB6 connected to Arduino D11.
- DB7 connected to Arduino D12.
- A connected to the other end of the Resistor.
- K connected to Arduino GND.
DHT11 Humidity and Temperature Sensor
- VDD connected to Arduino 5V.
- DATA connected to Arduino D2.
- GND connected to Arduino GND.
Resistor
- pin1 connected to LCD Display A.
- pin2 connected to LCD Display VO.
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.
