
模块采用的温湿度传感器为:DHT11,DHT11 数字温湿度传感器是一款含有已校准数字信号输出的温湿度复
合传感器。它包括一个电阻式感湿元件和一个 NTC 测温元件。每个 DHT11 传
感器都在极为精确的湿度校验室中进行校准。校准系数以程序的形式储存在
OTP 内存中,传感器内部在检测信号的处理过程中要调用这些校准系数,用户
无需重新校准。单线制串行接口,使系统集成变得简易快捷。超小的体积、
极低的功耗,信号传输距离可达 20 米以上。
硬件准备: - UNO PLUS开发板
- Temperature-Humidity Sensor模块
- I/O Expansion Shield扩展板
硬件连接: 
将UNO PLUS的电压配置为5V, 模块引脚连接如下:
VCC - 5V
GND - GND
DOUT - D2
程序: 01 | double Fahrenheit( double celsius) |
03 | return 1.8 * celsius + 32; |
06 | double Kelvin( double celsius) |
08 | return celsius + 273.15; |
11 | double dewPoint( double celsius, double humidity) |
13 | double A0= 373.15/(273.15 + celsius); |
14 | double SUM = -7.90298 * (A0-1); |
15 | SUM += 5.02808 * log10(A0); |
16 | SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ; |
17 | SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ; |
18 | SUM += log10(1013.246); |
19 | double VP = pow(10, SUM-3) * humidity; |
20 | double T = log(VP/0.61078); |
21 | return (241.88 * T) / (17.558-T); |
24 | double dewPointFast( double celsius, double humidity) |
28 | double temp = (a * celsius) / (b + celsius) + log(humidity/100); |
29 | double Td = (b * temp) / (a - temp); |
42 | Serial.println( "DHT11 TEST PROGRAM " ); |
43 | Serial.print( "LIBRARY VERSION: " ); |
44 | Serial.println(DHT11LIB_VERSION); |
52 | int chk = DHT11.read(DHT11PIN); |
54 | Serial.print( "Read sensor: " ); |
60 | case DHTLIB_ERROR_CHECKSUM: |
61 | Serial.println( "Checksum error" ); |
63 | case DHTLIB_ERROR_TIMEOUT: |
64 | Serial.println( "Time out error" ); |
67 | Serial.println( "Unknown error" ); |
71 | Serial.print( "Humidity (%): " ); |
72 | Serial.println(( float )DHT11.humidity, 2); |
74 | Serial.print( "Temperature (oC): " ); |
75 | Serial.println(( float )DHT11.temperature, 2); |
77 | Serial.print( "Temperature (oF): " ); |
78 | Serial.println(Fahrenheit(DHT11.temperature), 2); |
80 | Serial.print( "Temperature (K): " ); |
81 | Serial.println(Kelvin(DHT11.temperature), 2); |
83 | Serial.print( "Dew Point (oC): " ); |
84 | Serial.println(dewPoint(DHT11.temperature, DHT11.humidity)); |
86 | Serial.print( "Dew PointFast (oC): " ); |
87 | Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity)); |
现象: 
附件: dht11.zip |