“(SKU:SEN030005)DHT22数字温湿度传感器”的版本间的差异
来自YwRobot Studio Wiki
YWrobot WM(讨论 | 贡献) (创建页面,内容为“DHT22 ==简介== DHT22数字温湿度传感器是一款含有已校准数字信号输出的温湿度复合传感器。它应...”) |
YWrobot WB1(讨论 | 贡献) (→更多) |
||
(未显示2个用户的3个中间版本) | |||
第20行: | 第20行: | ||
===连接图=== | ===连接图=== | ||
− | [[File: | + | [[File:Dht22接线图-04.jpg|400px|]] |
+ | |||
+ | [[File:Dht22接线图-05.jpg|400px|]] | ||
+ | |||
===样例代码=== | ===样例代码=== | ||
+ | <pre style="color:blue"> | ||
+ | // Example testing sketch for various DHT humidity/temperature sensors | ||
+ | // Written by ladyada, public domain | ||
+ | |||
+ | #include "DHT.h" | ||
+ | |||
+ | #define DHTPIN 2 // what pin we're connected to | ||
+ | |||
+ | // Uncomment whatever type you're using! | ||
+ | //#define DHTTYPE DHT11 // DHT 11 | ||
+ | #define DHTTYPE DHT22 // DHT 22 (AM2302) | ||
+ | //#define DHTTYPE DHT21 // DHT 21 (AM2301) | ||
+ | |||
+ | // Connect pin 1 (on the left) of the sensor to +5V | ||
+ | // Connect pin 2 of the sensor to whatever your DHTPIN is | ||
+ | // Connect pin 4 (on the right) of the sensor to GROUND | ||
+ | // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor | ||
+ | |||
+ | DHT dht(DHTPIN, DHTTYPE); | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | Serial.println("DHTxx test!"); | ||
+ | |||
+ | dht.begin(); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // Reading temperature or humidity takes about 250 milliseconds! | ||
+ | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) | ||
+ | float h = dht.readHumidity(); | ||
+ | float t = dht.readTemperature(); | ||
+ | // check if returns are valid, if they are NaN (not a number) then something went wrong! | ||
+ | if (isnan(t) || isnan(h)) { | ||
+ | Serial.println("Failed to read from DHT"); | ||
+ | } else { | ||
+ | Serial.print("Humidity: "); | ||
+ | Serial.print(h); | ||
+ | Serial.print(" %\t"); | ||
+ | Serial.print("Temperature: "); | ||
+ | Serial.print(t); | ||
+ | Serial.println(" *C"); | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
==更多== | ==更多== | ||
− | [ YWRobot产品资料下载] | + | [ [YWRobot产品资料下载]https://pan.baidu.com/s/1-okE16DOQLJBvJCZFtJW9w ] |
+ | 提取码:7auz | ||
<br> | <br> | ||
购买 [https://item.taobao.com/item.htm?spm=2013.1.20141001.1.8C96xX&id=36280654791&scm=1007.10115.22552.100200300000000&pvid=4b438bc8-faf1-4cd4-9bc2-782075393e5d YWRobot商城购买链接] | 购买 [https://item.taobao.com/item.htm?spm=2013.1.20141001.1.8C96xX&id=36280654791&scm=1007.10115.22552.100200300000000&pvid=4b438bc8-faf1-4cd4-9bc2-782075393e5d YWRobot商城购买链接] | ||
<br><br> | <br><br> |
2019年1月30日 (三) 15:53的最新版本
简介
DHT22数字温湿度传感器是一款含有已校准数字信号输出的温湿度复合传感器。它应用专用的数字模块采集技术和温湿度传感技术,确保产品具有极高的可靠性与卓越的长期稳定性。
传感器包括一个电容式感湿元件和一个NTC测温元件,并与一个高性能8位单片机相连接。因此该产品具有品质卓越、超快响应、抗干扰能力强、性价比极高等优点。单线制串行接口,使系统集成变得简易快捷。超小的体积、极低的功耗,信号传输距离可达20米以上,使其成为各类应用甚至最为苛刻的应用场合的最佳选则。产品连接方便,可直接插接到Arduino传感器扩展板上。
DHT22数字温湿度传感器精度较高,可以替代昂贵的进口SHT10温湿度传感器。在对环境温度与湿度测量要求较高的情况下使用,该产品具有极高的可靠性和出色的稳定性。与Arduino专用传感器扩展板结合使用,可以非常容易地实现与温度和与湿度感知相关的互动效果。
产品参数
- 尺寸:40*23mm
- 重量:4g
- 电压:5V
- 端口:数字双向单总线
- 温度范围:-40-80℃ ±0.5℃
- 湿度范围:20-90%RH ±2%RH
- 平台:Arduino、单片机
使用教程
连接图
样例代码
// Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain #include "DHT.h" #define DHTPIN 2 // what pin we're connected to // Uncomment whatever type you're using! //#define DHTTYPE DHT11 // DHT 11 #define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) // Connect pin 1 (on the left) of the sensor to +5V // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin(); } void loop() { // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); float t = dht.readTemperature(); // check if returns are valid, if they are NaN (not a number) then something went wrong! if (isnan(t) || isnan(h)) { Serial.println("Failed to read from DHT"); } else { Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" *C"); } }
更多
[ [YWRobot产品资料下载]https://pan.baidu.com/s/1-okE16DOQLJBvJCZFtJW9w ]
提取码:7auz