< 返回 ?传感器目录页
- ?DHT11温度模块湿度模块基本介绍
HT11数字温湿度传感器是一款含有已校准数字信号输出的温湿度复合传感器。它应用专用的数字模块采集技术和温湿度传感技术,确保产品具有极高的可靠性与卓越的长期稳定性。该产品可应用于:暖通空调,测试及检测设备,汽车,数据记录器,自动控制,气象检测, 医疗设备,除湿器等 - 工作参数
- 尺寸:长28mmX宽12mmX高7.2mm
- 工作电压:直流5V
- 湿度测量范围:20—90%RH
- 湿度测量精度:±5%RH
- 温度测量范围:0—50℃
- 温度测量精度:±2℃
- 数字信号输出,数据端口带上拉电阻
- Arduino 接线方法:
DHT11 引脚 “+” – Arduino 5v
DHT11 引脚 “-” – Arduino GND
DHT11 引脚 “Out” – Arduino D2
注意:切勿将VCC与GND接反,否则电路将会损坏!
- Arduino驱动DHT11温度/湿度模块程序代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
/* Arduino Uno DHT11 Temeperature Sensor Created 2014 by 太极创客 http://www.taichi-maker.com 使用Arduino Uno驱动DHT11温度/湿度模块。 程序运行后,传感器将感应测试的温度湿度结 果通过Arduino IDE的串口监视器显示。 接线方法: Pin Setup: DHT11 pin "+" - Arduino 5v DHT11 pin "-" - Arduino GND DHT11 pin "Out" - Arduino D2 获得DHT11温度/湿度模块和Arduino的更多信息 请参阅太极创客网站:http://www.taichi-maker.com This example code is in the public domain. */ double Fahrenheit(double celsius) { return 1.8 * celsius + 32; } //摄氏温度度转化为华氏温度 double Kelvin(double celsius) { return celsius + 273.15; } //摄氏温度转化为开氏温度 // 露点(点在此温度时,空气饱和并产生露珠) // 参考: http://wahiduddin.net/calc/density_algorithms.htm double dewPoint(double celsius, double humidity) { double A0= 373.15/(273.15 + celsius); double SUM = -7.90298 * (A0-1); SUM += 5.02808 * log10(A0); SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ; SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ; SUM += log10(1013.246); double VP = pow(10, SUM-3) * humidity; double T = log(VP/0.61078); // temp var return (241.88 * T) / (17.558-T); } // 快速计算露点,速度是5倍dewPoint() // 参考: http://en.wikipedia.org/wiki/Dew_point double dewPointFast(double celsius, double humidity) { double a = 17.271; double b = 237.7; double temp = (a * celsius) / (b + celsius) + log(humidity/100); double Td = (b * temp) / (a - temp); return Td; } #include <dht11.h> dht11 DHT11; #define DHT11PIN 2 void setup() { Serial.begin(9600); Serial.println("DHT11 TEST PROGRAM "); Serial.print("LIBRARY VERSION: "); Serial.println(DHT11LIB_VERSION); Serial.println(); } void loop() { Serial.println("\n"); int chk = DHT11.read(DHT11PIN); Serial.print("Read sensor: "); switch (chk) { case DHTLIB_OK: Serial.println("OK"); break; case DHTLIB_ERROR_CHECKSUM: Serial.println("Checksum error"); break; case DHTLIB_ERROR_TIMEOUT: Serial.println("Time out error"); break; default: Serial.println("Unknown error"); break; } Serial.print("Humidity (%): "); Serial.println((float)DHT11.humidity, 2); Serial.print("Temperature (oC): "); Serial.println((float)DHT11.temperature, 2); Serial.print("Temperature (oF): "); Serial.println(Fahrenheit(DHT11.temperature), 2); Serial.print("Temperature (K): "); Serial.println(Kelvin(DHT11.temperature), 2); Serial.print("Dew Point (oC): "); Serial.println(dewPoint(DHT11.temperature, DHT11.humidity)); Serial.print("Dew PointFast (oC): "); Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity)); delay(2000); } |
运行结果:
- 资料下载
DHT11温度湿度传感器说明书 百度网盘下载
< 返回 ?传感器目录页