กลับไปหน้ารวมไฟล์
display-temperature-and-humidity-on-lcd-786556-en.md

Room Climate: Temperature & Humidity LCD

The Temperature and Humidity LCD project is the rite of passage for all Arduino beginners. It transitions the maker from sending raw data to the invisible Serial Monitor onto a standalone, physical display that can be placed on a desk.

lcd_distance_sensor_sr04_view_1772706727668.png

The Single-Wire Protocol

The DHT11 (or the more accurate DHT22) looks like a simple 3-pin component, but it contains its own microscopic processor!

  • Unlike an analog probe that outputs variable voltages, the DHT uses a proprietary digital pulse train.
  • Utilizing the <DHT.h> library, the Arduino says, "Send me the data."
  • The DHT sensor shoots back a rapid stream of 40 binary bits encoding the exact temperature and humidity. The library parses this into two floating-point numbers: 24.5C and 60.0%.

LiquidCrystal Display Formatting

A standard 16x2 LCD requires 6 data pins (RS, EN, D4, D5, D6, D7). Using an I2C backpack is highly recommended to reduce this to 2 wiring pins!

  • The Arduino must format the screen precisely to prevent ghosting.
  • Row 1: lcd.setCursor(0,0); lcd.print("Temp: 24.5 C");
  • Row 2: lcd.setCursor(0,1); lcd.print("Humidity: 60 %");
  • Crucial Tip: You must only update the screen every 2000 milliseconds (delay(2000);). The DHT11 physical sensor is extremely slow and will crash if you demand its temperature millions of times a second.

Required Setup

  • Arduino Uno/Nano.
  • DHT11 or DHT22 Sensor.
  • 16x2 LCD Display (with I2C Module strongly advised).

ข้อมูล Frontmatter ดั้งเดิม

title: "Display Temperature and Humidity on LCD"
description: "The classic weather station! Safely wire a DHT11 sensor and output real-time room climate data onto a 16x2 Text LCD without flickering."
category: "Sensors & Environment"
difficulty: "Easy"