DHT22 Temperature and Humidity on a 7-Segment Display with Arduino RJT43
This project demonstrates how to build a simple, yet effective, system for displaying temperature and humidity readings on a 7-segment display using an Arduino. This setup is useful for various applications where monitoring environmental conditions is crucial. The project combines the DHT22 temperature and humidity sensor with a TM1637 7-segment display, providing a clear and easily readable output.


Project Ideas:
- Monitoring a home environment for optimal comfort.
- Tracking conditions in a greenhouse or terrarium.
- Building a basic weather station.
- Displaying temperature and humidity in a data-logging project.
Hardware/Components
To build this project, you will need the following components:
- Arduino Uno (or compatible board)
- DHT22 Temperature and Humidity Sensor
- TM1637 7-Segment Display
- Connecting wires
- Breadboard (optional, but recommended)
Wiring Guide



The wiring is straightforward. Refer to the video (in video at 01:51) for a visual guide. The key connections are:
- TM1637 Display: VCC to 5V, GND to GND, CLK to Arduino pin 2, DIO to Arduino pin 3 (in video at 02:00).
- DHT22 Sensor: VCC to 5V, GND to GND, DATA to Arduino pin 9 (in video at 02:20). Note that the video uses Arduino pin 8 to provide 5V to the sensor (in video at 02:41).
Code Explanation
The Arduino code utilizes two libraries: TM1637Display for the 7-segment display and DHT for the DHT22 sensor. The code's configurable parameters are primarily located at the beginning:
// Module connection pins (Digital Pins)
#define CLK 2
#define DIO 3
#define DHTPIN 9 // DHT22 data pin
#define DHTTYPE DHT22 // DHT sensor type
These lines define the Arduino pins connected to the display and the DHT22 sensor. You may need to adjust these if you use different pins. The getTemp() function (in video at 07:03) is crucial. It allows you to retrieve different values from the DHT22 sensor by passing a string argument:
float getTemp(String req) {
// ... (Sensor reading code) ...
if(req =="c"){ return t; } // Celsius
else if(req =="f"){ return f; } // Fahrenheit
// ... (Other options for Kelvin, humidity, heat index) ...
}
This function simplifies reading different data from the sensor (Celsius, Fahrenheit, humidity, heat index). The main loop uses this function to fetch the data and display it on the 7-segment display, rounding floating-point values to integers for display purposes (in video at 07:14).
Live Project/Demonstration
The video (in video at 00:32) shows a live demonstration of the project. The 7-segment display clearly shows the temperature in Fahrenheit. The video also demonstrates how the code can be modified to display Celsius, Kelvin, humidity, and heat index values (in video at 08:21).
Chapters
- [00:06] Introduction and Project Overview
- [00:53] Getting Started and Component Overview
- [01:51] Wiring the TM1637 Display
- [02:20] Wiring the DHT22 Sensor
- [03:14] Code Explanation: TM1637 Setup
- [04:00] Code Explanation: DHT22 Setup
- [05:54] Code Explanation: Main Loop and Display Function
- [07:03] Code Explanation: getTemp() Function
- [08:21] Demonstration and Different Output Options
资源与参考
尚无可用资源。
文件📁
Arduino 库(zip 格式)
-
DHT22 PCB module red
DHT22-module-red.fzpz0.01 MB
Fritzing 文件
-
DHT22 Humidity and Temperature Sensor
DHT22 Humidity and Temperature Sensor.fzpz0.01 MB -
DHT22 PCB module red
DHT22-module-red.fzpz0.01 MB -
DHT22 module white
DHT22-module-white.fzpz0.01 MB -
TM1637 Seven Segment module
TM1637.fzpz0.01 MB -
DHT11 Humitidy and Temperature Sensor (3 pins)
DHT11 Humitidy and Temperature Sensor (3 pins).fzpz0.20 MB
用户手册
-
DHT22 Temperature and Humidity sensor user's manual
robojax-DHT22_manual.pdf0.36 MB