概述:
DHT11数字温湿度传感器是一款含有已校准数字信号输出的温湿度复合传感器。它采用专用的数字模块采集技术和温湿度传感技术,确保产品具有极高的可靠性与卓越的长期稳定性。 DHT11采用单总线方式与arduino进行数据传输,单线制串行接口,使系统集成变得简易快捷。超小的体积、极低的功耗,信号传输距离可达20米以上,使其成为各类应用甚至最为苛刻的应用场合的最佳选则。
模块参数:
尺寸:35x25mm
工作电压:5V
信号类型:数字信号
模块特性:
供电电流:最大2.5Ma
温度范围:0-50℃误差±2℃
湿度范围:20-90%RH误差±5%RH
响应时间: 1/e(63%) 6-30s
采样周期间隔不得低于1秒钟
端口说明:
S:信号输出
+ :VCC
– :GND
Arduino示例程序:
double Fahrenheit(double celsius) { return 1.8 * celsius + 32; } //摄氏温度度转化为华氏温度</pre> <p>double Kelvin(double celsius)<br />{<br />return celsius + 273.15;<br />} //摄氏温度转化为开氏温度</p> <p>// 露点(点在此温度时,空气饱和并产生露珠)<br />// 参考: http://wahiduddin.net/calc/density_algorithms.htm<br />double dewPoint(double celsius, double humidity)<br />{<br />double A0= 373.15/(273.15 + celsius);<br />double SUM = -7.90298 * (A0-1);<br />SUM += 5.02808 * log10(A0);<br />SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;<br />SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;<br />SUM += log10(1013.246);<br />double VP = pow(10, SUM-3) * humidity;<br />double T = log(VP/0.61078); // temp var<br />return (241.88 * T) / (17.558-T);<br />}</p> <p>// 快速计算露点,速度是5倍dewPoint()<br />// 参考: http://en.wikipedia.org/wiki/Dew_point<br />double dewPointFast(double celsius, double humidity)<br />{<br />double a = 17.271;<br />double b = 237.7;<br />double temp = (a * celsius) / (b + celsius) + log(humidity/100);<br />double Td = (b * temp) / (a - temp);<br />return Td;<br />}<br /><br />#include <dht11.h><br />dht11 DHT11;<br />#define DHT11PIN 2</p> <p>void setup()<br />{<br />Serial.begin(9600);<br />Serial.println("DHT11 TEST PROGRAM ");<br />Serial.print("LIBRARY VERSION: ");<br />Serial.println(DHT11LIB_VERSION);<br />Serial.println();<br />}</p> <p>void loop()<br />{<br />Serial.println("n");</p> <p>int chk = DHT11.read(DHT11PIN);</p> <p>Serial.print("Read sensor: ");<br />switch (chk)<br />{<br />case DHTLIB_OK:<br />Serial.println("OK");<br />break;<br />case DHTLIB_ERROR_CHECKSUM:<br />Serial.println("Checksum error");<br />break;<br />case DHTLIB_ERROR_TIMEOUT:<br />Serial.println("Time out error");<br />break;<br />default:<br />Serial.println("Unknown error");<br />break;<br />}</p> <p>Serial.print("Humidity (%): ");<br />Serial.println((float)DHT11.humidity, 2);</p> <p>Serial.print("Temperature (oC): ");<br />Serial.println((float)DHT11.temperature, 2);</p> <p>Serial.print("Temperature (oF): ");<br />Serial.println(Fahrenheit(DHT11.temperature), 2);</p> <p>Serial.print("Temperature (K): ");<br />Serial.println(Kelvin(DHT11.temperature), 2);</p> <p>Serial.print("Dew Point (oC): ");<br />Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));</p> <p>Serial.print("Dew PointFast (oC): ");<br />Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));</p> <p>delay(2000);<br />}相关文档:
技术手册:DHT11
库文件:DHT111
原理图:DHT11-schematic
Mixly图形化示例程序: