{"id":43175,"date":"2025-06-11T08:56:01","date_gmt":"2025-06-11T00:56:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/43175.html"},"modified":"2025-06-11T08:56:01","modified_gmt":"2025-06-11T00:56:01","slug":"stm32%e4%b9%8bdht11%e6%b8%a9%e6%b9%bf%e5%ba%a6%e4%bc%a0%e6%84%9f%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/43175.html","title":{"rendered":"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668"},"content":{"rendered":"<p>\u76ee\u5f55<\/p>\n<p style=\"margin-left:0px\">\u4e00 DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u7b80\u4ecb<\/p>\n<p style=\"margin-left:40px\">1.1 \u4f20\u611f\u5668\u7279\u70b9<\/p>\n<p style=\"margin-left:40px\">1.2 \u4f20\u611f\u5668\u7279\u6027<\/p>\n<p style=\"margin-left:40px\">1.3 \u4f20\u611f\u5668\u5f15\u811a\u8bf4\u660e<\/p>\n<p style=\"margin-left:0px\">\u4e8c \u6d4b\u91cf\u539f\u7406\u53ca\u65b9\u6cd5<\/p>\n<p style=\"margin-left:40px\">2.1 \u5178\u578b\u5e94\u7528\u7535\u8def<\/p>\n<p style=\"margin-left:40px\">2.2\u00a0\u5355\u7ebf\u5236\u4e32\u884c\u7b80\u4ecb<\/p>\n<p style=\"margin-left:80px\">2.2.1 \u4e32\u884c\u63a5\u53e3\u00a0\u00a0(\u5355\u7ebf\u53cc\u5411)<\/p>\n<p style=\"margin-left:80px\">2.2.2 \u6570\u636e\u793a\u4f8b<\/p>\n<p style=\"margin-left:40px\">2.3 \u901a\u4fe1\u65f6\u5e8f\u00a0<\/p>\n<p style=\"margin-left:0px\">\u4e09 \u5355\u7247\u673a\u7b80\u4ecb<\/p>\n<p style=\"margin-left:40px\">3.1 STM32F103C8T6\u6700\u5c0f\u7cfb\u7edf\u677f<\/p>\n<p style=\"margin-left:0px\">\u56db \u63a5\u7ebf\u8bf4\u660e<\/p>\n<p style=\"margin-left:40px\">4.1 DHT11.C\u5b8f\u5b9a\u4e49<\/p>\n<p style=\"margin-left:40px\">4.2\u00a0\u00a0DHT11.H\u5b8f\u5b9a\u4e49<\/p>\n<p style=\"margin-left:0px\">\u4e94 \u7a0b\u5e8f\u8bbe\u8ba1<\/p>\n<p style=\"margin-left:40px\">5.1 DHT11.C<\/p>\n<p style=\"margin-left:80px\">5.1.1 \u590d\u4f4dDHT11<\/p>\n<p style=\"margin-left:80px\">5.1.2 \u68c0\u67e5DHT11\u5de5\u4f5c\u662f\u5426\u6b63\u5e38\u00a0<\/p>\n<p style=\"margin-left:80px\">\u00a05.1.3 \u8bfb\u53d6\u4e00\u4f4d\u6570\u636e<\/p>\n<p style=\"margin-left:80px\">5.1.4 \u8bfb\u53d6\u4e00\u4e2a\u5b57\u8282\u00a0<\/p>\n<p style=\"margin-left:80px\">5.1.5 \u8bfb\u53d6\u6e29\u6e7f\u5ea6\u503c\u00a0<\/p>\n<p style=\"margin-left:80px\">5.1.6 \u5b8c\u6574DHT11.C\u7a0b\u5e8f\u00a0<\/p>\n<p style=\"margin-left:40px\">5.2 DHT11.H<\/p>\n<p style=\"margin-left:40px\">5.3 \u6dfb\u52a0\u5934\u6587\u4ef6<\/p>\n<p style=\"margin-left:40px\">5.4 \u5b9a\u4e49\u53d8\u91cf<\/p>\n<p style=\"margin-left:40px\">\u00a05.5 \u521d\u59cb\u5316<\/p>\n<p style=\"margin-left:40px\">\u00a05.6 \u6d4b\u91cf\u6e29\u6e7f\u5ea6<\/p>\n<p style=\"margin-left:0px\">\u4e03 \u6d4b\u91cf\u6548\u679c<\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h2>\u4e00 DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u7b80\u4ecb<\/h2>\n<h3>1.1 \u4f20\u611f\u5668\u7279\u70b9<\/h3>\n<p style=\"margin-left:.0001pt;text-align:left\">\u00a0 \u00a0 \u00a0 \u00a0DHT11\u6570\u5b57\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u662f\u4e00\u6b3e\u542b\u6709\u5df2\u6821\u51c6\u6570\u5b57\u4fe1\u53f7\u8f93\u51fa\u7684\u6e29\u6e7f\u5ea6\u590d\u5408\u4f20\u611f\u5668\u3002\u5b83\u5e94\u7528\u4e13\u7528\u7684\u6570\u5b57\u6a21\u5757\u91c7\u96c6\u6280\u672f\u548c\u6e29\u6e7f\u5ea6\u4f20\u611f\u6280\u672f&#xff0c;\u786e\u4fdd\u4ea7\u54c1\u5177\u6709\u6781\u9ad8\u7684\u53ef\u9760\u6027\u4e0e\u5353\u8d8a\u7684\u957f\u671f\u7a33\u5b9a\u6027\u3002\u4f20\u611f\u5668\u5305\u62ec\u4e00\u4e2a\u7535\u963b\u5f0f\u611f\u6e7f\u5143\u4ef6\u548c\u4e00\u4e2aNTC\u6d4b\u6e29\u5143\u4ef6&#xff0c;\u5e76\u4e0e\u4e00\u4e2a\u9ad8\u6027\u80fd8\u4f4d\u5355\u7247\u673a\u76f8\u8fde\u63a5\u3002\u56e0\u6b64\u8be5\u4ea7\u54c1\u5177\u6709\u54c1\u8d28\u5353\u8d8a\u3001\u8d85\u5feb\u54cd\u5e94\u3001\u6297\u5e72\u6270\u80fd\u529b\u5f3a\u3001\u6027\u4ef7\u6bd4\u6781\u9ad8\u7b49\u4f18\u70b9\u3002DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41d1685c.png\" alt=\"407cafd1156d48c3aca2ced960f77c1d.png\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u6bcf\u4e2aDHT11\u4f20\u611f\u5668\u90fd\u5728\u6781\u4e3a\u7cbe\u786e\u7684\u6e7f\u5ea6\u6821\u9a8c\u5ba4\u4e2d\u8fdb\u884c\u6821\u51c6\u3002\u6821\u51c6\u7cfb\u6570\u4ee5\u7a0b\u5e8f\u7684\u5f62\u5f0f\u50a8\u5b58\u5728OTP\u5185\u5b58\u4e2d&#xff0c;\u4f20\u611f\u5668\u5185\u90e8\u5728\u68c0\u6d4b\u4fe1\u53f7\u7684\u5904\u7406\u8fc7\u7a0b\u4e2d\u8981\u8c03\u7528\u8fd9\u4e9b\u6821\u51c6\u7cfb\u6570\u3002\u5355\u7ebf\u5236\u4e32\u884c\u63a5\u53e3&#xff0c;\u4f7f\u7cfb\u7edf\u96c6\u6210\u53d8\u5f97\u7b80\u6613\u5feb\u6377\u3002\u8d85\u5c0f\u7684\u4f53\u79ef\u3001\u6781\u4f4e\u7684\u529f\u8017&#xff0c;\u4fe1\u53f7\u4f20\u8f93\u8ddd\u79bb\u53ef\u8fbe20\u7c73\u4ee5\u4e0a&#xff0c;\u4f7f\u5176\u6210\u4e3a\u5404\u7c7b\u5e94\u7528\u751a\u81f3\u6700\u4e3a\u82db\u523b\u7684\u5e94\u7528\u573a\u5408\u7684\u6700\u4f73\u9009\u5219\u3002\u4ea7\u54c1\u4e3a 4 \u9488\u5355\u6392\u5f15\u811a\u5c01\u88c5\u3002<\/p>\n<h3>1.2 \u4f20\u611f\u5668\u7279\u6027<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41d38a4f.png\" alt=\"06953e8c5c3e4bfaa21cee79d283912e.png\" \/><\/p>\n<h3 style=\"margin-left:.0001pt;text-align:left\">1.3 \u4f20\u611f\u5668\u5f15\u811a\u8bf4\u660e<\/h3>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align:top;width:47.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u5f15\u811a<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:77.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u540d\u79f0<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:212.65pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u6ce8\u91ca<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:47.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">1<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:77.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">VDD<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:212.65pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u4f9b\u7535 3&#xff0d;5.5VDC<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:47.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">2<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:77.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">DATA<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:212.65pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u4e32\u884c\u6570\u636e&#xff0c;\u5355\u603b\u7ebf<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:47.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">3<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:77.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">NC<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:212.65pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u7a7a\u811a&#xff0c;\u8bf7\u60ac\u7a7a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:47.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">4<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:77.95pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">GND<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:212.65pt\">\n<p style=\"margin-left:.0001pt;text-align:left\">\u63a5\u5730&#xff0c;\u7535\u6e90\u8d1f\u6781<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e8c \u6d4b\u91cf\u539f\u7406\u53ca\u65b9\u6cd5<\/h2>\n<h3>2.1 \u5178\u578b\u5e94\u7528\u7535\u8def<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41d6d0dd.png\" alt=\"0b89c1c91dcb4130a131cf5d629d4909.png\" \/><\/p>\n<p>\u5efa\u8bae\u8fde\u63a5\u7ebf\u957f\u5ea6\u77ed\u4e8e20\u7c73\u65f6\u75285K\u4e0a\u62c9\u7535\u963b,\u5927\u4e8e20\u7c73\u65f6\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4f7f\u7528\u5408\u9002\u7684\u4e0a\u62c9\u7535\u963b\u00a0\u3002<\/p>\n<p>\u7535\u6e90\u5f15\u811a&#xff1a;DHT11\u7684\u4f9b\u7535\u7535\u538b\u4e3a 3&#xff0d;5.5V\u3002\u4f20\u611f\u5668\u4e0a\u7535\u540e&#xff0c;\u8981\u7b49\u5f85 1s \u4ee5\u8d8a\u8fc7\u4e0d\u7a33\u5b9a\u72b6\u6001&#xff0c;\u5728\u6b64\u671f\u95f4\u65e0\u9700\u53d1\u9001\u4efb\u4f55\u6307\u4ee4\u3002\u7535\u6e90\u5f15\u811a&#xff08;VDD&#xff0c;GND&#xff09;\u4e4b\u95f4\u53ef\u589e\u52a0\u4e00\u4e2a100nF \u7684\u7535\u5bb9&#xff0c;\u7528\u4ee5\u53bb\u8026\u6ee4\u6ce2\u3002\u00a0<\/p>\n<h3>2.2\u00a0\u5355\u7ebf\u5236\u4e32\u884c\u7b80\u4ecb<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41d9214d.png\" alt=\"f9a42c32b1b34ff5a15f72a06e74d3b9.png\" \/><\/p>\n<h4 style=\"margin-left:.0001pt;text-align:left\">2.2.1 \u4e32\u884c\u63a5\u53e3\u00a0\u00a0(\u5355\u7ebf\u53cc\u5411)<\/h4>\n<p style=\"margin-left:.0001pt;text-align:left\">\u00a0 \u00a0 \u00a0 \u00a0DATA \u7528\u4e8e\u5fae\u5904\u7406\u5668\u4e0e DHT11\u4e4b\u95f4\u7684\u901a\u8baf\u548c\u540c\u6b65,\u91c7\u7528\u5355\u603b\u7ebf\u6570\u636e\u683c\u5f0f,\u4e00\u6b21\u901a\u8baf\u65f6\u95f44ms\u5de6\u53f3,\u6570\u636e\u5206\u5c0f\u6570\u90e8\u5206\u548c\u6574\u6570\u90e8\u5206,\u5177\u4f53\u683c\u5f0f\u5728\u4e0b\u9762\u8bf4\u660e,\u5f53\u524d\u5c0f\u6570\u90e8\u5206\u7528\u4e8e\u4ee5\u540e\u6269\u5c55,\u73b0\u8bfb\u51fa\u4e3a\u96f6\u3002\u64cd\u4f5c\u6d41\u7a0b:\u4e00\u6b21\u5b8c\u6574\u7684\u6570\u636e\u4f20\u8f93\u4e3a40bit,\u9ad8\u4f4d\u5148\u51fa\u3002<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u6570\u636e\u683c\u5f0f:8bit\u6e7f\u5ea6\u6574\u6570\u6570\u636e&#043;8bit\u6e7f\u5ea6\u5c0f\u6570\u6570\u636e&#043;8bi\u6e29\u5ea6\u6574\u6570\u6570\u636e&#043;8bit\u6e29\u5ea6\u5c0f\u6570\u6570\u636e&#043;8bit\u6821\u9a8c\u548c<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u6570\u636e\u4f20\u9001\u6b63\u786e\u65f6\u6821\u9a8c\u548c\u6570\u636e\u7b49\u4e8e\u201c8bit\u6e7f\u5ea6\u6574\u6570\u6570\u636e&#043;8bit\u6e7f\u5ea6\u5c0f\u6570\u6570\u636e&#043;8bi\u6e29\u5ea6\u6574\u6570\u6570\u636e&#043;8bit\u6e29<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u5ea6\u5c0f\u6570\u6570\u636e\u201d\u6240\u5f97\u7ed3\u679c\u7684\u672b8\u4f4d\u3002<\/p>\n<h4 style=\"margin-left:.0001pt;text-align:left\">2.2.2 \u6570\u636e\u793a\u4f8b<\/h4>\n<p>\u63a5\u6536\u5230\u7684\u6570\u636e\u4e3a&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41dc0a1d.png\" alt=\"3f3ef8b232b9487da749e4ceb825de7f.png\" \/><\/p>\n<p>\u8ba1\u7b97&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41dcb08c.png\" alt=\"5ce92a27d6984089a3d44d6ec4d893d3.png\" \/><\/p>\n<p>\u5bf9\u6bd4\u63a5\u6536\u5230\u7684\u6821\u9a8c\u4f4d&#xff0c;\u6570\u636e\u6b63\u786e&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41dd458f.png\" alt=\"6fac8b007ea34946a299c1f1322c07c6.png\" \/><\/p>\n<h3>2.3 \u901a\u4fe1\u65f6\u5e8f\u00a0<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u7528\u6237MCU\u53d1\u9001\u4e00\u6b21\u5f00\u59cb\u4fe1\u53f7\u540e,DHT11\u4ece\u4f4e\u529f\u8017\u6a21\u5f0f\u8f6c\u6362\u5230\u9ad8\u901f\u6a21\u5f0f,\u7b49\u5f85\u4e3b\u673a\u5f00\u59cb\u4fe1\u53f7\u7ed3\u675f\u540e,DHT11\u53d1\u9001\u54cd\u5e94\u4fe1\u53f7,\u9001\u51fa40bit\u7684\u6570\u636e,\u5e76\u89e6\u53d1\u4e00\u6b21\u4fe1\u53f7\u91c7\u96c6,\u7528\u6237\u53ef\u9009\u62e9\u8bfb\u53d6\u90e8\u5206\u6570\u636e.\u4ece\u6a21\u5f0f\u4e0b,DHT11\u63a5\u6536\u5230\u5f00\u59cb\u4fe1\u53f7\u89e6\u53d1\u4e00\u6b21\u6e29\u6e7f\u5ea6\u91c7\u96c6,\u5982\u679c\u6ca1\u6709\u63a5\u6536\u5230\u4e3b\u673a\u53d1\u9001\u5f00\u59cb\u4fe1\u53f7,DHT11\u4e0d\u4f1a\u4e3b\u52a8\u8fdb\u884c\u6e29\u6e7f\u5ea6\u91c7\u96c6.\u91c7\u96c6\u6570\u636e\u540e\u8f6c\u6362\u5230\u4f4e\u901f\u6a21\u5f0f\u3002<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u901a\u8baf\u8fc7\u7a0b\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\"><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41de33e0.png\" alt=\"169b3c59d4a746c7997514670acdf14f.png\" \/><\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u00a0 \u00a0 \u00a0 \u603b\u7ebf\u7a7a\u95f2\u72b6\u6001\u4e3a\u9ad8\u7535\u5e73,\u4e3b\u673a\u628a\u603b\u7ebf\u62c9\u4f4e\u7b49\u5f85DHT11\u54cd\u5e94,\u4e3b\u673a\u628a\u603b\u7ebf\u62c9\u4f4e\u5fc5\u987b\u5927\u4e8e18\u6beb\u79d2,\u4fdd\u8bc1DHT11\u80fd\u68c0\u6d4b\u5230\u8d77\u59cb\u4fe1\u53f7\u3002DHT11\u63a5\u6536\u5230\u4e3b\u673a\u7684\u5f00\u59cb\u4fe1\u53f7\u540e,\u7b49\u5f85\u4e3b\u673a\u5f00\u59cb\u4fe1\u53f7\u7ed3\u675f,\u7136\u540e\u53d1\u900180us\u4f4e\u7535\u5e73\u54cd\u5e94\u4fe1\u53f7.\u4e3b\u673a\u53d1\u9001\u5f00\u59cb\u4fe1\u53f7\u7ed3\u675f\u540e,\u5ef6\u65f6\u7b49\u5f8520-40us\u540e, \u8bfb\u53d6DHT11\u7684\u54cd\u5e94\u4fe1\u53f7,\u4e3b\u673a\u53d1\u9001\u5f00\u59cb\u4fe1\u53f7\u540e,\u53ef\u4ee5\u5207\u6362\u5230\u8f93\u5165\u6a21\u5f0f,\u6216\u8005\u8f93\u51fa\u9ad8\u7535\u5e73\u5747\u53ef, \u603b\u7ebf\u7531\u4e0a\u62c9\u7535\u963b\u62c9\u9ad8\u3002<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\"><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005558-6848d41e75bc5.png\" alt=\"7bf7670d1fe24c04af66c2dd72dcfb5f.png\" \/><\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u00a0 \u00a0 \u00a0 \u00a0\u603b\u7ebf\u4e3a\u4f4e\u7535\u5e73,\u8bf4\u660eDHT11\u53d1\u9001\u54cd\u5e94\u4fe1\u53f7,DHT11\u53d1\u9001\u54cd\u5e94\u4fe1\u53f7\u540e,\u518d\u628a\u603b\u7ebf\u62c9\u9ad880us,\u51c6\u5907\u53d1\u9001\u6570\u636e,\u6bcf\u4e00bit\u6570\u636e\u90fd\u4ee550us\u4f4e\u7535\u5e73\u65f6\u9699\u5f00\u59cb,\u9ad8\u7535\u5e73\u7684\u957f\u77ed\u5b9a\u4e86\u6570\u636e\u4f4d\u662f0\u8fd8\u662f1.\u683c\u5f0f\u89c1\u4e0b\u9762\u56fe\u793a.\u5982\u679c\u8bfb\u53d6\u54cd\u5e94\u4fe1\u53f7\u4e3a\u9ad8\u7535\u5e73,\u5219DHT11\u6ca1\u6709\u54cd\u5e94,\u8bf7\u68c0\u67e5\u7ebf\u8def\u662f\u5426\u8fde\u63a5\u6b63\u5e38.\u5f53\u6700\u540e\u4e00bit\u6570\u636e\u4f20\u9001\u5b8c\u6bd5\u540e&#xff0c;DHT11\u62c9\u4f4e\u603b\u7ebf50us,\u968f\u540e\u603b\u7ebf\u7531\u4e0a\u62c9\u7535\u963b\u62c9\u9ad8\u8fdb\u5165\u7a7a\u95f2\u72b6\u6001\u3002<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u6570\u5b570\u4fe1\u53f7\u8868\u793a\u65b9\u6cd5\u5982\u56fe\u6240\u793a&#xff0c;VCC\u4fdd\u6301\u9ad8\u7535\u5e7326-28\u5fae\u79d2&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u00a0\u00a0\u00a0\u00a0<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005558-6848d41ed058c.png\" alt=\"0bb26329061d4cab8d5b65764c25df65.png\" \/><\/p>\n<p style=\"margin-left:.0001pt;text-align:left\">\u6570\u5b571\u4fe1\u53f7\u8868\u793a\u65b9\u6cd5\u5982\u56fe\u6240\u793a&#xff0c;VCC\u4fdd\u6301\u9ad8\u7535\u5e7370\u5fae\u79d2&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;text-align:left\"><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005558-6848d41ee5e7b.png\" alt=\"e031746865284ebaa1e458e0e270fb0a.png\" \/><\/p>\n<h2>\u4e09 \u5355\u7247\u673a\u7b80\u4ecb<\/h2>\n<h3>3.1 STM32F103C8T6\u6700\u5c0f\u7cfb\u7edf\u677f<\/h3>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005559-6848d41f05903.jpg\" alt=\"aaec3c7f38d741c88cde6d81934fe72f.jpeg\" \/><\/p>\n<p>\u672c\u6587\u4f7f\u7528\u7684\u5f00\u53d1\u677f\u4e3aSTM32F103C8T6\u6700\u5c0f\u7cfb\u7edf\u677f&#xff0c;DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u4f7f\u7528\u5230\u7684\u5f15\u811a\u4e3aPA11\u5f15\u811a\u3002\u00a0<\/p>\n<h2>\u56db \u63a5\u7ebf\u8bf4\u660e<\/h2>\n<p>DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u4e0e\u5355\u7247\u673a\u7684\u63a5\u7ebf\u53d6\u51b3\u4e8eDHT11.C\u548cDHT11.H\u4e2d\u7684\u5f15\u811a\u5b8f\u5b9a\u4e49&#xff0c;\u672c\u6587\u4f20\u611f\u5668\u7684DATA\u5f15\u811a\u63a5\u5355\u7247\u673aPA11&#xff0c;VCC\u63a53.3V\u3002<\/p>\n<h3>4.1 DHT11.C\u5b8f\u5b9a\u4e49<\/h3>\n<p>\u5b9a\u4e49DATA\u5f15\u811a\u4e3a11:<\/p>\n<p>#define DT GPIO_Pin_11 <\/p>\n<h3>4.2\u00a0\u00a0DHT11.H\u5b8f\u5b9a\u4e49<\/h3>\n<p>\u5f15\u811a\u8f93\u5165\u8f93\u51fa\u6a21\u5f0f\u914d\u7f6e&#xff1a;\u5b9a\u4e49GPIOA\u5f15\u811a&#xff0c;CRH\u662f\u5f15\u811a\u9ad88\u4f4d\u5373PA8-PA15,\u5c068\u5de6\u79fb12\u4f4d\u662f\u914d\u7f6e\u6210\u8f93\u5165\u6a21\u5f0f&#xff0c;\u5c063\u5de6\u79fb12\u4f4d\u662f\u914d\u7f6e\u6210\u63a8\u633d\u8f93\u51fa\u6a21\u5f0f\u3002<\/p>\n<p>#define DHT11_IO_IN()  {GPIOA-&gt;CRH&amp;&#061;0XFFFF0FFF;GPIOA-&gt;CRH|&#061;8&lt;&lt;12;}<br \/>\n#define DHT11_IO_OUT() {GPIOA-&gt;CRH&amp;&#061;0XFFFF0FFF;GPIOA-&gt;CRH|&#061;3&lt;&lt;12;}  <\/p>\n<p>\u00a0IO\u5b8f\u5b9a\u4e49&#xff1a;<\/p>\n<p>#defineDHT11_DQ_OUT PAout(11)<br \/>\n#defineDHT11_DQ_IN  PAin(11)  <\/p>\n<h2>\u4e94 \u7a0b\u5e8f\u8bbe\u8ba1<\/h2>\n<h3>5.1 DHT11.C<\/h3>\n<h4>5.1.1 \u590d\u4f4dDHT11<\/h4>\n<p>\u5c06\u6570\u636e\u7ebf\u914d\u7f6e\u4e3a\u8f93\u51fa\u6a21\u5f0f&#xff0c;\u5148\u62c9\u4f4e\u6570\u636e\u7ebf20ms&#xff0c;\u7136\u540e\u5c06\u6570\u636e\u7ebf\u62c9\u9ad830\u5fae\u79d2&#xff0c;\u5bf9\u5e94\u65f6\u5e8f\u56fe\u5982\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005559-6848d41f23a22.png\" alt=\"2d8bbf4fcb9d4f76a053ee6f8975eb62.png\" \/><\/p>\n<p>void DHT11_Rst(void)<br \/>\n{<br \/>\nDHT11_IO_OUT(); \/\/SET OUTPUT<br \/>\nDHT11_DQ_OUT&#061;0; \/\/\u62c9\u4f4eDQ<br \/>\ndelay_ms(20);    \/\/\u62c9\u4f4e\u81f3\u5c1118ms<br \/>\nDHT11_DQ_OUT&#061;1; \/\/DQ&#061;1<br \/>\ndelay_us(30);     \/\/\u4e3b\u673a\u62c9\u9ad820~40us<br \/>\n} <\/p>\n<h4>5.1.2 \u68c0\u67e5DHT11\u5de5\u4f5c\u662f\u5426\u6b63\u5e38\u00a0<\/h4>\n<p>\u5c06\u6570\u636e\u7ebf\u914d\u7f6e\u4e3a\u8f93\u5165\u6a21\u5f0f&#xff0c;DHT11\u4f1a\u5148\u62c9\u4f4e80\u5fae\u79d2&#xff0c;\u7136\u540e\u518d\u62c9\u9ad880\u5fae\u79d2&#xff0c;\u5982\u679c\u8d85\u8fc780\u5fae\u79d2\u4ecd\u6ca1\u6709\u56de\u5e94&#xff0c;\u5219\u8fd4\u56de1&#xff0c;DHT11\u8bfb\u53d6\u5931\u8d25&#xff0c;\u5bf9\u5e94\u65f6\u5e8f\u56fe\u5982\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005559-6848d41f7996e.png\" alt=\"bac0e4e321b14c5d9ec5ccfc81daf9fc.png\" \/><\/p>\n<p>u8 DHT11_Check(void)<br \/>\n{<br \/>\nu8 retry&#061;0;<br \/>\nDHT11_IO_IN();\/\/SET INPUT<br \/>\n    while (DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/DHT11\u4f1a\u62c9\u4f4e40~80us<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n};<br \/>\nif(retry&gt;&#061;100)return 1;<br \/>\nelse retry&#061;0;<br \/>\n    while (!DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/DHT11\u62c9\u4f4e\u540e\u4f1a\u518d\u6b21\u62c9\u9ad840~80us<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n};<br \/>\nif(retry&gt;&#061;100)return 1;<br \/>\nreturn 0;<br \/>\n} <\/p>\n<h4>\u00a05.1.3 \u8bfb\u53d6\u4e00\u4f4d\u6570\u636e<\/h4>\n<p>\u8be5\u51fd\u6570\u91c7\u7528\u4e24\u4e2awhile\u5faa\u73af\u662f\u7b49\u5f85\u6bcf\u4e2a\u5468\u671f\u7684\u7535\u5e73\u53d8\u5316&#xff0c;\u5148\u7b49\u5f85\u4f4e\u7535\u5e73\u5230\u6765&#xff0c;\u540e\u7b49\u5f85\u9ad8\u7535\u5e73\u5230\u6765&#xff0c;\u5ef6\u65f640us\u540e\u5224\u65ad\u5f15\u811a\u7535\u5e73&#xff0c;\u6765\u5224\u65ad\u8be5\u4f4d\u6570\u636e\u4e3a1\u62160\u3002\u4e4b\u6240\u4ee5\u662f40\u5fae\u79d2\u662f\u56e0\u4e3a\u4f20\u611f\u5668\u6570\u5b570\u7684\u4fe1\u53f7\u6301\u7eed\u65f6\u95f4\u4e3a26-28us&#xff0c;\u6570\u5b571\u7684\u4fe1\u53f7\u6301\u7eed\u65f6\u95f4\u4e3a70us&#xff0c;\u9009\u62e9\u4e00\u4e2a\u4e2d\u503c\u6765\u533a\u5206\u4e24\u79cd\u4fe1\u53f7&#xff0c;\u5f53\u7136\u4e5f\u53ef\u4ee5\u9009\u62e9\u5176\u4ed6\u503c&#xff0c;\u4f46\u6700\u597d\u572840us\u9644\u8fd1\u3002<\/p>\n<p>u8 DHT11_Read_Bit(void)<br \/>\n{<br \/>\n u8 retry&#061;0;<br \/>\nwhile(DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/\u7b49\u5f85\u53d8\u4e3a\u4f4e\u7535\u5e73<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n}<br \/>\nretry&#061;0;<br \/>\nwhile(!DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/\u7b49\u5f85\u53d8\u9ad8\u7535\u5e73<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n}<br \/>\ndelay_us(40);\/\/\u7b49\u5f8540us<br \/>\nif(DHT11_DQ_IN)return 1;<br \/>\nelse return 0;<br \/>\n}<\/p>\n<h4>5.1.4 \u8bfb\u53d6\u4e00\u4e2a\u5b57\u8282\u00a0<\/h4>\n<p>\u8bfb\u53d6\u4e00\u4e2a\u5b57\u8282\u5c31\u662f\u8fde\u7eed\u8bfb\u53d68\u6b21\u6570\u636e\u4f4d&#xff0c;\u5e76\u5c06\u8bfb\u53d6\u5230\u7684\u6570\u636e\u4e0d\u65ad\u5de6\u79fb1\u4f4d\u653e\u5230\u9ad8\u4f4d\u3002<\/p>\n<p>u8 DHT11_Read_Byte(void)<br \/>\n{<br \/>\nu8 i,dat;<br \/>\ndat&#061;0;<br \/>\nfor (i&#061;0;i&lt;8;i&#043;&#043;)<br \/>\n{<br \/>\ndat&lt;&lt;&#061;1;<br \/>\ndat|&#061;DHT11_Read_Bit();<br \/>\n}<br \/>\nreturn dat;<br \/>\n} <\/p>\n<h4>5.1.5 \u8bfb\u53d6\u6e29\u6e7f\u5ea6\u503c\u00a0<\/h4>\n<p>\u5f53DHT11\u68c0\u67e5\u65e0\u8bef\u65f6&#xff0c;\u5c06\u8bfb\u53d6\u5230\u768440\u4f4d\u6570\u636e\u5b58\u653e\u57285\u4e2a\u5143\u7d20\u7684\u6570\u7ec4\u4e2d&#xff0c;\u6821\u9a8c\u65e0\u8bef\u540e&#xff0c;\u5c06\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u6570\u636e\u5b58\u653e\u5728temp\u53d8\u91cf\u7684\u5730\u5740\u4e2d&#xff0c;\u5373\u6e29\u5ea6\u7684\u6574\u6570\u90e8\u5206&#xff1b;\u5c06\u7b2c\u4e09\u4e2a\u5b57\u8282\u7684\u6570\u636e\u5b58\u653e\u5728humi\u53d8\u91cf\u7684\u5730\u5740\u4e2d&#xff0c;\u5373\u6e7f\u5ea6\u7684\u6574\u6570\u90e8\u5206\u3002<\/p>\n<p>u8 DHT11_Read_Data(u8 *temp,u8 *humi)<br \/>\n{<br \/>\n u8 buf[5];<br \/>\nu8 i;<br \/>\nDHT11_Rst();<br \/>\nif(DHT11_Check()&#061;&#061;0)<br \/>\n{<br \/>\nfor(i&#061;0;i&lt;5;i&#043;&#043;)\/\/\u8bfb\u53d640\u4f4d\u6570\u636e<br \/>\n{<br \/>\nbuf[i]&#061;DHT11_Read_Byte();<br \/>\n}<br \/>\nif((buf[0]&#043;buf[1]&#043;buf[2]&#043;buf[3])&#061;&#061;buf[4])<br \/>\n{<br \/>\n*humi&#061;buf[0];<br \/>\n*temp&#061;buf[2];<br \/>\n}<br \/>\n}<br \/>\nelse return 1;<br \/>\nreturn 0;<br \/>\n}<\/p>\n<h4>5.1.6 \u5b8c\u6574DHT11.C\u7a0b\u5e8f\u00a0<\/h4>\n<p>\/***************STM32F103C8T6**********************<br \/>\n * \u6587\u4ef6\u540d  &#xff1a;DHT11.c<br \/>\n * \u63cf\u8ff0    &#xff1a;DHT11\u4f20\u611f\u5668<br \/>\n * \u5907\u6ce8    : DHT11\u6e29\u5ea6\u6e7f\u5ea6\u4f20\u611f\u5668<br \/>\n * \u63a5\u53e3    &#xff1a;PA11-DATA<\/p>\n<p>********************LIGEN*************************\/<\/p>\n<p>#include &#034;dht11.h&#034;<br \/>\n#include &#034;delay.h&#034;<\/p>\n<p>#define DT GPIO_Pin_11<\/p>\n<p>\/\/\u590d\u4f4dDHT11<br \/>\nvoid DHT11_Rst(void)<br \/>\n{<br \/>\nDHT11_IO_OUT(); \/\/SET OUTPUT<br \/>\nDHT11_DQ_OUT&#061;0; \/\/\u62c9\u4f4eDQ<br \/>\ndelay_ms(20);    \/\/\u62c9\u4f4e\u81f3\u5c1118ms<br \/>\nDHT11_DQ_OUT&#061;1; \/\/DQ&#061;1<br \/>\ndelay_us(30);     \/\/\u4e3b\u673a\u62c9\u9ad820~40us<br \/>\n}<\/p>\n<p>\/\/\u7b49\u5f85DHT11\u7684\u56de\u5e94<br \/>\n\/\/\u8fd4\u56de1:\u672a\u68c0\u6d4b\u5230DHT11\u7684\u5b58\u5728<br \/>\n\/\/\u8fd4\u56de0:\u5b58\u5728<br \/>\nu8 DHT11_Check(void)<br \/>\n{<br \/>\nu8 retry&#061;0;<br \/>\nDHT11_IO_IN();\/\/SET INPUT<br \/>\n    while (DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/DHT11\u4f1a\u62c9\u4f4e40~80us<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n};<br \/>\nif(retry&gt;&#061;100)return 1;<br \/>\nelse retry&#061;0;<br \/>\n    while (!DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/DHT11\u62c9\u4f4e\u540e\u4f1a\u518d\u6b21\u62c9\u9ad840~80us<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n};<br \/>\nif(retry&gt;&#061;100)return 1;<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/\u4eceDHT11\u8bfb\u53d6\u4e00\u4e2a\u4f4d<br \/>\n\/\/\u8fd4\u56de\u503c&#xff1a;1\/0<br \/>\nu8 DHT11_Read_Bit(void)<br \/>\n{<br \/>\n u8 retry&#061;0;<br \/>\nwhile(DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/\u7b49\u5f85\u53d8\u4e3a\u4f4e\u7535\u5e73<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n}<br \/>\nretry&#061;0;<br \/>\nwhile(!DHT11_DQ_IN&amp;&amp;retry&lt;100)\/\/\u7b49\u5f85\u53d8\u9ad8\u7535\u5e73<br \/>\n{<br \/>\nretry&#043;&#043;;<br \/>\ndelay_us(1);<br \/>\n}<br \/>\ndelay_us(40);\/\/\u7b49\u5f8540us<br \/>\nif(DHT11_DQ_IN)return 1;<br \/>\nelse return 0;<br \/>\n}<\/p>\n<p>\/\/\u4eceDHT11\u8bfb\u53d6\u4e00\u4e2a\u5b57\u8282<br \/>\n\/\/\u8fd4\u56de\u503c&#xff1a;\u8bfb\u5230\u7684\u6570\u636e<br \/>\nu8 DHT11_Read_Byte(void)<br \/>\n{<br \/>\nu8 i,dat;<br \/>\ndat&#061;0;<br \/>\nfor (i&#061;0;i&lt;8;i&#043;&#043;)<br \/>\n{<br \/>\ndat&lt;&lt;&#061;1;<br \/>\ndat|&#061;DHT11_Read_Bit();<br \/>\n}<br \/>\nreturn dat;<br \/>\n}<\/p>\n<p>\/\/\u4eceDHT11\u8bfb\u53d6\u4e00\u6b21\u6570\u636e<br \/>\n\/\/temp:\u6e29\u5ea6\u503c(\u8303\u56f4:0~50\u00b0)<br \/>\n\/\/humi:\u6e7f\u5ea6\u503c(\u8303\u56f4:20%~90%)<br \/>\n\/\/\u8fd4\u56de\u503c&#xff1a;0,\u6b63\u5e38;1,\u8bfb\u53d6\u5931\u8d25<br \/>\nu8 DHT11_Read_Data(u8 *temp,u8 *humi)<br \/>\n{<br \/>\n u8 buf[5];<br \/>\nu8 i;<br \/>\nDHT11_Rst();<br \/>\nif(DHT11_Check()&#061;&#061;0)<br \/>\n{<br \/>\nfor(i&#061;0;i&lt;5;i&#043;&#043;)\/\/\u8bfb\u53d640\u4f4d\u6570\u636e<br \/>\n{<br \/>\nbuf[i]&#061;DHT11_Read_Byte();<br \/>\n}<br \/>\nif((buf[0]&#043;buf[1]&#043;buf[2]&#043;buf[3])&#061;&#061;buf[4])<br \/>\n{<br \/>\n*humi&#061;buf[0];<br \/>\n*temp&#061;buf[2];<br \/>\n}<br \/>\n}<br \/>\nelse return 1;<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/\u521d\u59cb\u5316DHT11\u7684IO\u53e3 DQ \u540c\u65f6\u68c0\u6d4bDHT11\u7684\u5b58\u5728<br \/>\n\/\/\u8fd4\u56de1:\u4e0d\u5b58\u5728<br \/>\n\/\/\u8fd4\u56de0:\u5b58\u5728<br \/>\nu8 DHT11_Init(void)<br \/>\n{<br \/>\n GPIO_InitTypeDef  GPIO_InitStructure;<br \/>\n RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); \/\/\u4f7f\u80fdPG\u7aef\u53e3\u65f6\u949f<br \/>\n GPIO_InitStructure.GPIO_Pin &#061; DT; \/\/PG11\u7aef\u53e3\u914d\u7f6e<br \/>\n GPIO_InitStructure.GPIO_Mode &#061; GPIO_Mode_Out_PP;  \/\/\u63a8\u633d\u8f93\u51fa<br \/>\n GPIO_InitStructure.GPIO_Speed &#061; GPIO_Speed_50MHz;<br \/>\n GPIO_Init(GPIOA, &amp;GPIO_InitStructure); \/\/\u521d\u59cb\u5316IO\u53e3<br \/>\n GPIO_SetBits(GPIOA,DT); \/\/PG11 \u8f93\u51fa\u9ad8<\/p>\n<p>DHT11_Rst();  \/\/\u590d\u4f4dDHT11<br \/>\nreturn DHT11_Check();\/\/\u7b49\u5f85DHT11\u7684\u56de\u5e94<br \/>\n} <\/p>\n<h3>5.2 DHT11.H<\/h3>\n<p>#ifndef DHT11_H<br \/>\n#define DHT11_H<\/p>\n<p>#include &#034;sys.h&#034;<\/p>\n<p>\/\/PA11<br \/>\n#define DHT11_IO_IN()  {GPIOA-&gt;CRH&amp;&#061;0XFFFF0FFF;GPIOA-&gt;CRH|&#061;8&lt;&lt;12;}<br \/>\n#define DHT11_IO_OUT() {GPIOA-&gt;CRH&amp;&#061;0XFFFF0FFF;GPIOA-&gt;CRH|&#061;3&lt;&lt;12;}<br \/>\n\/\/IO\u64cd\u4f5c\u51fd\u6570<br \/>\n#defineDHT11_DQ_OUT PAout(11)<br \/>\n#defineDHT11_DQ_IN  PAin(11) <\/p>\n<p>u8 DHT11_Init(void);\/\/\u521d\u59cb\u5316DHT11<br \/>\nu8 DHT11_Read_Data(u8 *temp,u8 *humi);\/\/\u8bfb\u53d6\u6570\u636e<br \/>\nu8 DHT11_Read_Byte(void);\/\/\u8bfb\u53d6\u4e00\u4e2a\u5b57\u8282<br \/>\nu8 DHT11_Read_Bit(void);\/\/\u8bfb\u53d6\u4e00\u4f4d<br \/>\nu8 DHT11_Check(void);\/\/\u68c0\u6d4bDHT11<br \/>\nvoid DHT11_Rst(void);\/\/\u590d\u4f4dDHT11   <\/p>\n<p>#endif<\/p>\n<h3>5.3 \u6dfb\u52a0\u5934\u6587\u4ef6<\/h3>\n<p>#include &#034;dht11.h&#034; <\/p>\n<h3>5.4 \u5b9a\u4e49\u53d8\u91cf<\/h3>\n<p>u8 temp;<br \/>\nu8 humi; <\/p>\n<h3>\u00a05.5 \u521d\u59cb\u5316<\/h3>\n<p>\u5982\u679c\u521d\u59cb\u5316\u9519\u8bef\u4e32\u53e3\u8f93\u51fa\u201cDHT11 Error\u201d<\/p>\n<p>while(DHT11_Init())<br \/>\n{<br \/>\nprintf(&#034;DHT11 Error \\\\r\\\\n&#034;);<br \/>\ndelay_ms(1000);<br \/>\n} <\/p>\n<h3>\u00a05.6 \u6d4b\u91cf\u6e29\u6e7f\u5ea6<\/h3>\n<p>\u4e32\u53e3\u8f93\u51fa\u6e29\u6e7f\u5ea6\u3002<\/p>\n<p>DHT11_Read_Data(&amp;temp,&amp;humi);<br \/>\nprintf(&#034;temp: %d C\\\\r\\\\nhumi: %d %%RH\\\\r\\\\n&#034;,temp,humi);<br \/>\n    delay_ms(1000); <\/p>\n<h2>\u4e03 \u6d4b\u91cf\u6548\u679c<\/h2>\n<p>temp\u8868\u793a\u6e29\u5ea6&#xff0c;humi\u8868\u793a\u6e7f\u5ea6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005559-6848d41fd1d23.png\" alt=\"24280f02efa14bff91064b519c2936b3.png\" \/><\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.9w\u6b21\uff0c\u70b9\u8d5e128\u6b21\uff0c\u6536\u85cf603\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3001\u63a5\u7ebf\u8bf4\u660e\u3001\u5355\u7ebf\u5236\u4e32\u884c\u901a\u4fe1\u3001STM32F103C8T6\u5355\u7247\u673a\u7684\u63a5\u53e3\u914d\u7f6e\u4ee5\u53ca\u5b8c\u6574\u7684\u7a0b\u5e8f\u8bbe\u8ba1\uff0c\u5305\u62ec\u590d\u4f4d\u3001\u6570\u636e\u8bfb\u53d6\u548c\u6821\u9a8c\u7b49\u6b65\u9aa4\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u987a\u5229\u96c6\u6210\u548c\u4f7f\u7528DHT11\u4f20\u611f\u5668\u3002<\/p>\n","protected":false},"author":2,"featured_media":43160,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[217,270,269,3992],"topic":[],"class_list":["post-43175","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-stm32","tag-270","tag-269","tag-3992"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/43175.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.9w\u6b21\uff0c\u70b9\u8d5e128\u6b21\uff0c\u6536\u85cf603\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3001\u63a5\u7ebf\u8bf4\u660e\u3001\u5355\u7ebf\u5236\u4e32\u884c\u901a\u4fe1\u3001STM32F103C8T6\u5355\u7247\u673a\u7684\u63a5\u53e3\u914d\u7f6e\u4ee5\u53ca\u5b8c\u6574\u7684\u7a0b\u5e8f\u8bbe\u8ba1\uff0c\u5305\u62ec\u590d\u4f4d\u3001\u6570\u636e\u8bfb\u53d6\u548c\u6821\u9a8c\u7b49\u6b65\u9aa4\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u987a\u5229\u96c6\u6210\u548c\u4f7f\u7528DHT11\u4f20\u611f\u5668\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/43175.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-11T00:56:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41d1685c.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/43175.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/43175.html\",\"name\":\"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-11T00:56:01+00:00\",\"dateModified\":\"2025-06-11T00:56:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/43175.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/43175.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/43175.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/43175.html","og_locale":"zh_CN","og_type":"article","og_title":"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.9w\u6b21\uff0c\u70b9\u8d5e128\u6b21\uff0c\u6536\u85cf603\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3001\u63a5\u7ebf\u8bf4\u660e\u3001\u5355\u7ebf\u5236\u4e32\u884c\u901a\u4fe1\u3001STM32F103C8T6\u5355\u7247\u673a\u7684\u63a5\u53e3\u914d\u7f6e\u4ee5\u53ca\u5b8c\u6574\u7684\u7a0b\u5e8f\u8bbe\u8ba1\uff0c\u5305\u62ec\u590d\u4f4d\u3001\u6570\u636e\u8bfb\u53d6\u548c\u6821\u9a8c\u7b49\u6b65\u9aa4\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u987a\u5229\u96c6\u6210\u548c\u4f7f\u7528DHT11\u4f20\u611f\u5668\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/43175.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-11T00:56:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250611005557-6848d41d1685c.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/43175.html","url":"https:\/\/www.wsisp.com\/helps\/43175.html","name":"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-11T00:56:01+00:00","dateModified":"2025-06-11T00:56:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/43175.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/43175.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/43175.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"STM32\u4e4bDHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/43175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=43175"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/43175\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/43160"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=43175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=43175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=43175"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=43175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}