Cảm biến nhiệt độ, độ ẩm DHT11
Cảm biến độ ẩm và nhiệt độ DHT11 là cảm biến rất thông dụng hiện nay vì chi phí rẻ và rất dễ lấy dữ liệu thông qua chuẩn giao tiếp 1 wire.
Chuẩn giao tiếp 1 wire là dùng 1 chân Digital để truyền dữ liệu.
Bộ tiền xử lý tín hiệu được tích hợp trong cảm biến giúp bạn có thể đọc dữ liệu chính xác mà không phải qua bất kỳ tính toán nào.
Thông số kỹ thuật của cảm biến:
- Điện áp hoạt động: 3V – 5V (DC)
- Dãi độ ẩm hoạt động: 20% – 90% RH, sai số ±5%RH
- Dãi nhiệt độ hoạt động: 0°C ~ 50°C, sai số ±2°C
- Khoảng cách truyển tối đa: 20m
Các bạn download và cài đặt thư viện hỗ trợ sử dụng DHT11: Tại đây
Code mẫu
#include “DHT.h” const int DHTPIN = 4; const int DHTTYPE = DHT11; DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); } void loop() { float h = dht.readHumidity(); float t = dht.readTemperature(); Serial.print(“Nhiet do: “); Serial.println(t); Serial.print(“Do am: “); Serial.println(h); Serial.println(); delay(1000); }
Giải thích code
Khai báo chân kết nối cho cảm biến DHT ở đây mình dùng chân D4 trên Arduino Uno.
const int DHTPIN = 4; const int DHTTYPE = DHT11;
Thư viện DHT.h được khai báo sử dụng cho 2 loại cảm biến là DHT11 và DHT22.
Trong bài viết mình giới thiệu cảm biến nhiệt độ, độ ẩm DHT11, nên chúng ta cần phải khai báo là DHTTYPE là DHT11.
float h = dht.readHumidity(); // Đọc giá trị nhiệt độ từ cảm biến float t = dht.readTemperature(); // Đọc giá trị độ ẩm từ cảm biến
Ở trên là hai biến đọc giá trị nhiệt độ và độ ẩm.
Serial.print(“Nhiet do: “); Serial.println(t); Serial.print(“Do am: “); Serial.println(h);
In giá trị nhiệt độ, độ ẩm lên màn hình (Serial Monitor).
- Để hiểu hơn về hàm Serial.print() và Serial.println() các bạn xem bài viết ở đây nhé:Xem ngay.
Chúng ta tiến hành Upload chương trình và bật Serial Monitor lên để xem kết quả nhé.
Sơ đồ đấu nối
Arduino Uno | Cảm biến nhiệt độ, độ ẩm DHT11 |
5V | VCC |
GND | GND |
D4 | DATA |
Các linh kiện cần thiết cho dự án:
Tên linh kiện | Số lượng | Shopee |
Arduino Uno R3 | Mua ngay | |
Dây cáp nạp | Mua ngay | |
Cảm biến nhiệt độ, độ ẩm DHT11 | Mua ngay | |
Breadboard (Board Test) | Mua ngay | |
Dây cắm (Đực – Đực) | Mua ngay |
Bạn sẽ học được gì
- Có kiến thức cơ bản về Robotics
- Chế tạo Robot dò đường thông minh
- Đánh thức nhà khoa học bên trong bạn
- Tìm hiểu thêm về Robotics, các thuật toán Robot tự động
- Kiến thức nền tảng để chế tạo các máy móc tự động phục vụ đời sống sinh hoạt, lao động sản xuất
- Kiến thức để chế tạo sản phẩm, tham gia các cuộc thi khoa học công nghệ trong nước và quốc tế
Documentation and doxygen
Documentation is produced by doxygen. Contributions should include documentation for any new code added.
Some examples of how to use doxygen can be found in these guide pages:
https://learn.adafruit.com/the-well-automated-arduino-library/doxygen
https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips
Written by Adafruit Industries based on work by:
- T. DiCola
- P. Y. Dragon
- L. Fried
- J. Hoffmann
- M. Kooijman
- J. M. Dana
- S. Conaway
- S. IJskes
- T. Forbes
- B. C
- T. J Myers
- L. Sørup
- per1234
- O. Duffy
- matthiasdanner
- J. Lim
- G. Ambrozio
- chelmi
- adams13x13
- Spacefish
- I. Scheller
- C. Miller
- 7eggert
MIT license, check license.txt for more information All text above must be included in any redistribution
To install, use the Arduino Library Manager and search for “DHT sensor library” and install the library.
Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors
Filename | Release Date | File Size |
DHT_sensor_library-1.4.6.zip | 2023-11-15 | 18.43 KiB |
DHT_sensor_library-1.4.4.zip | 2022-06-27 | 18.43 KiB |
DHT_sensor_library-1.4.3.zip | 2021-10-25 | 18.36 KiB |
DHT_sensor_library-1.4.2.zip | 2021-03-16 | 18.35 KiB |
DHT_sensor_library-1.4.1.zip | 2020-12-02 | 18.31 KiB |
DHT_sensor_library-1.4.0.zip | 2020-09-16 | 18.30 KiB |
DHT_sensor_library-1.3.10.zip | 2020-05-26 | 18.21 KiB |
DHT_sensor_library-1.3.9.zip | 2020-04-19 | 18.11 KiB |
DHT_sensor_library-1.3.8.zip | 2019-11-02 | 15.83 KiB |
DHT_sensor_library-1.3.7.zip | 2019-07-19 | 13.49 KiB |
Đọc nhiệt độ, độ ẩm (DHT11) sử dụng Arduino Uno
Cảm biến nhiệt độ, độ ẩm DHT11 là gì?
Ứng dụng trong thực tế ra sao?
Cảm biến dùng chuẩn giao tiếp gì?
Là những câu hỏi mà những ai mới nhập môn đều muốn biết.
Qua bài viết hôm này chúng ta cùng nhau tìm hiểu nhé.
Description
An Arduino library for the DHT series of low-cost temperature/humidity sensors.
You can find DHT tutorials here.
Dependencies
Contributing
Contributions are welcome! Not only you’ll encourage the development of the library, but you’ll also learn how to best use the library and probably some C++ too
Please read our Code of Conduct before contributing to help this project stay welcoming.
Lời kết
Qua bài hôm nay các bạn biết cách làm thế nào để đọc một cảm biến nhiệt độ, độ ẩm DHT11, và hiểu hơn về cách giao tiếp của chúng.
Để nhận được nhiều kiến thức mới các bạn Đăng ký để nhận được thông báo sớm nhất.
Tham gia Cộng đồng Arduino KIT để cùng nhau thảo luận và chia sẽ kiến thức về lập trình Arduino.
Nếu các bạn thấy bài viết bổ ích nhớ Like và Share cho mọi người cùng đọc nhé.
Chúc các bạn thành công.
Trân trọng.
Sensors
Arduino ESP library for DHT11, DHT22, etc Temp & Humidity Sensors
Optimized libray to match ESP32 requirements. Last changes: Fix negative temperature problem (credits @helijunky)
Maintainer: beegee_tokyo
This library is compatible with the esp8266, esp32, samd, avr architectures so you should be able to use it on the following Arduino boards:
Note: while the library is supposed to compile correctly on these architectures, it might require specific hardware features that may be available only on some boards.
To use this library, open the Library Manager in the Arduino IDE and install it from there.
Keywords searched by users: download library dht11 arduino
Categories: Khám phá 50 Download Library Dht11 Arduino
See more here: kientrucannam.vn
See more: https://kientrucannam.vn/vn/