กลับไปหน้ารวมไฟล์
temperature-and-humidity-sensor-with-led-lights-169e04.md

Hello. I've decided to create this project for the engineering class in university.

Things got exciting once I've added more code and linked it to the Air Conditioner.

The published project is to see the current temperature and humidity, and turn on led lights depending on the current temperature. It is not complex at all, but fun to make.

Hope you'll enjoy it as much as I did.


🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)

The Temperature LED Dashboard replaces complex text displays with a bold, instant visual indicator. By mapping the digital reading of a DHT11 sensor to an analog-like array of 10 LEDs, you create an incredibly legible, color-coded room thermometer.

Converting Arrays to Visuals (Map Function)

Wiring 10 LEDs to pins 2 through 11 is tedious, but programming the logic is brilliant.

  1. The Sensor Read: float tempC = dht.readTemperature();. (Current room is 26°C).
  2. The Output Array: You want to scale the room.
    • 20°C = 0 LEDs on.
    • 30°C = 10 LEDs on.
  3. The Mapping: int ledLevel = map(tempC, 20, 30, 0, 10); (This mathematically converts the 26°C reading into the raw number 6).
  4. The Illumination Loop: You write a for loop that cycles from 0 to 10. if(i < ledLevel), it turns that specific LED HIGH! Consequently, 6 LEDs light up simultaneously.

Thermal Color Coding

To make the display truly professional:

  • The first 3 LEDs (20-23°C) are BLUE.
  • The middle 4 LEDs (24-27°C) are GREEN or YELLOW.
  • The final 3 LEDs (28-30°C) are bright RED, warning you immediately from across the room that the A/C has broken!

Requirements

  • Arduino Uno/Nano.
  • DHT11 / DHT22 Sensor Module.
  • 10 x 5mm LEDs (Various Colors) and 10 x Resistors.
  • A large breadboard properly utilizing the shared ground rails.

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

title: "Temperature and Humidity sensor with LED Lights"
description: "This project project the temperature and the humidity level and turn on the LED Light depending on the temperature."
author: "r4lph127"
category: ""
tags:
  - "weather"
  - "entertainment system"
  - "data collection"
  - "monitoring"
views: 36540
likes: 11
price: 1499
difficulty: "Easy"
components:
  - "1x Alphanumeric LCD, 16 x 2"
  - "3x Resistor 330 ohm"
  - "1x DHT11 Temperature & Humidity Sensor (3 pins)"
  - "3x LED (generic)"
  - "30x Jumper wires (generic)"
  - "1x Breadboard (generic)"
  - "1x Arduino Mega 2560"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles:
  - "https://projects.arduinocontent.cc/31b198a1-7d5a-4521-821f-46cd2e16523e.ino"
  - "https://projects.arduinocontent.cc/31b198a1-7d5a-4521-821f-46cd2e16523e.ino"
documentationLinks: []
passwordHash: "d1c9328671bc6569a4e411b395a52f16caa7fc34de2e836058687fc40a427ed6"
encryptedPayload: "U2FsdGVkX1/rmbOh2FsACwb0FeGO4L6MfOqfgiOv5xTplXzcez4e1vdjA4E1CO0kEYzmqnzlFP6heY39vRSUHBKRrsznEo1aa7dNvoWVXlE="
seoDescription: "Arduino project: Monitor Temperature and Humidity and control LED Lights based on real-time sensor data. Step-by-step guide with code."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/temperature-and-humidity-sensor-with-led-lights-169e04_cover.jpg"
lang: "en"