{"id":598,"date":"2022-11-18T23:56:44","date_gmt":"2022-11-18T15:56:44","guid":{"rendered":"http:\/\/wordpress.loc\/?p=598"},"modified":"2023-02-22T20:48:15","modified_gmt":"2023-02-22T12:48:15","slug":"esp32_ch1-13","status":"publish","type":"post","link":"https:\/\/www.nmking.io\/index.php\/2022\/11\/18\/598\/","title":{"rendered":"\u7b2c07\u7bc7 ESP32\u74e6\u65af\u8b66\u5831\u5668mq2"},"content":{"rendered":"\n<figure class=\"wp-block-pullquote\"><blockquote><p>\u4e3b\u8981\u8ac7\u7684\u662fmq\u7cfb\u5217\u7684\u6c23\u9ad4\u611f\u6e2c\u5668\uff0c\u76f8\u540c\u7684\u662f\u4f7f\u7528\u985e\u6bd4\u8b80\u53d6\uff0c\u53ea\u662f\u9019\u9846\u611f\u6e2c\u5668\u5176\u5be6\u7528\u9014\u4e0d\u5927\uff0c\u505a\u7c21\u6613\u5be6\u9a57\u53ef\uff0c\u4f46\u662f\u8981\u505a\u7cbe\u78ba\u7684\u7814\u7a76\uff0c\u5efa\u8b70\u63db\u5546\u7528\u7684\u611f\u6e2c\u5668\uff0cmq\u9019\u7cfb\u5217\u7684\uff0c\u5751\u592a\u5927\u4e86\u3002<\/p><\/blockquote><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-ht-block-toc is-style-rounded htoc htoc--position-wide toc-list-style-plain\" data-htoc-state=\"expanded\"><span class=\"htoc__title\"><span class=\"ht_toc_title\">Table of Contents<\/span><span class=\"htoc__toggle\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"16\" height=\"16\"><g fill=\"#444\"><path d=\"M15 7H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><path d=\"M15 1H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1zM15 13H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><\/g><\/svg><\/span><\/span><div class=\"htoc__itemswrap\"><ul class=\"ht_toc_list\"><li class=\"\"><a href=\"#htoc-\">\u524d\u8a00<\/a><\/li><li class=\"\"><a href=\"#htoc-1\">\u4e00\u3001\u5be6\u9a57\u76ee\u7684<\/a><\/li><li class=\"\"><a href=\"#htoc-11111\">\u4e8c\u3001\u6750\u6599\u6e96\u5099<\/a><\/li><li class=\"\"><a href=\"#htoc-esp321\">\u4e09\u3001ESP32\u7dda\u8def\u4f48\u7f6e<\/a><\/li><li class=\"\"><a href=\"#htoc-11111111\">\u56db\u3001\u7a0b\u5f0f\u64b0\u5beb<\/a><\/li><\/ul><\/div><\/div>\n\n\n\n<p>\u6211\u7684ESP32\u5be6\u505a\u66f8\u7c4d\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.nmking.io\/index.php\/2022\/11\/10\/esp32_ch1-2\/\" target=\"_blank\">\u6211\u51fa\u66f8\u4e86 ESP32 \u7269\u806f\u7db2\u5c08\u984c<\/a><br>\u535a\u5ba2\u4f86\u7db2\u5740\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.books.com.tw\/products\/0010901195\" target=\"_blank\">https:\/\/www.books.com.tw\/products\/0010901195<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-\">\u524d\u8a00<\/h2>\n\n\n\n<p>\u672c\u7bc7\u662f\u524d\u7bc7(\u7b2c\u516d\u7bc7 ESP32\u985e\u6bd4\u8b80\u53d6(analogRead)\uff1a\u5c0f\u591c\u71c8)\u7684\u53e6\u4e00\u7a2e\u61c9\u7528\uff0c\u4e3b\u8981\u8ac7\u7684\u662fmq\u7cfb\u5217\u7684\u6c23\u9ad4\u611f\u6e2c\u5668\uff0c\u76f8\u540c\u7684\u662f\u4f7f\u7528\u985e\u6bd4\u8b80\u53d6\uff0c\u53ea\u662f\u9019\u9846\u611f\u6e2c\u5668\u5176\u5be6\u7528\u9014\u4e0d\u5927\uff0c\u505a\u7c21\u6613\u5be6\u9a57\u53ef\uff0c\u4f46\u662f\u8981\u505a\u7cbe\u78ba\u7684\u7814\u7a76\uff0c\u5efa\u8b70\u63db\u5546\u7528\u7684\u611f\u6e2c\u5668\uff0cmq\u9019\u7cfb\u5217\u7684\uff0c\u5751\u592a\u5927\u4e86\u3002<\/p>\n\n\n\n<p>mq\u7cfb\u5217\u6709\u4e00\u500b\u9f90\u5927\u7684\u5bb6\u65cf\uff0c\u5728\u53f0\u7063\u5e02\u9762\u4e0a\u5e38\u898b\u7684\u5927\u6982\u662fmq2, mq9, mq135\u9019\u5e7e\u500b\uff0c\u6839\u64da\u539f\u5ee0\u63d0\u4f9b\u7684\u898f\u683c\u8868\uff08\u4e0b\u5716\uff09\uff0c\u6bcf\u4e00\u9846\u90fd\u6709\u5176\u4e3b\u8981\u611f\u6e2c\u7684\u6c23\u9ad4\uff0c\u5982\u679c\u4f60\u6709\u7279\u5b9a\u9700\u8981\u611f\u6e2c\u7684\u76ee\u6a19\uff0c\u5247\u4f9d\u7167\u4e0b\u8868\u53bb\u8cfc\u8cb7\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582912312-3297832224_n.png?resize=840%2C444&#038;ssl=1\" alt=\"\" width=\"840\" height=\"444\"\/><figcaption class=\"wp-element-caption\">\u539f\u5ee0mq\u7cfb\u5217\u898f\u683c\u8868<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582913383-1662780268.png?resize=531%2C434&#038;ssl=1\" alt=\"\" width=\"531\" height=\"434\"\/><figcaption class=\"wp-element-caption\">mq\u7cfb\u5217\u5546\u54c1\u5716<\/figcaption><\/figure>\n\n\n\n<p>\u4e00\u822c\u70ba\u4e86\u6388\u8ab2\u65b9\u4fbf\uff0c\u6211\u6703\u62ff\u5bb9\u6613\u53d6\u5f97\u7684\u6d88\u6bd2\u7528\u9152\u7cbe\u9032\u884c\u6e2c\u8a66\uff0c\u7562\u7adf\u4e0a\u8ab2\u6642\u9593\u4f60\u4e0d\u53ef\u80fd\u642c\u4e00\u500b\u74e6\u65af\u7b52\u4f86\u6e2c\u8a66\uff0c\u6240\u4ee5\u6211\u6703\u9078\u64c7mq2, mq135, mq3\u9019\u5e7e\u500b\uff0c\u800cmq2\u662f\u6700\u5e38\u898b\u7684\u3002\u8b80\u8005\u82e5\u9700\u8981mq\u7cfb\u5217\u66f4\u8a73\u7d30\u7684\u7d30\u7bc0\uff0c\u53ef\u53c3\u8003\u539f\u5ee0\u7db2\u7ad9\uff1a <a href=\"https:\/\/playground.arduino.cc\/Main\/MQGasSensors\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/playground.arduino.cc\/Main\/MQGasSensors\/<\/a>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-1\">\u4e00\u3001\u5be6\u9a57\u76ee\u7684<\/h2>\n\n\n\n<p>\u672c\u6b21\u5be6\u9a57\u8981\u5b78\u7fd2\u5229\u7528\u6c23\u9ad4\u611f\u6e2c\u5668\u611f\u6e2c\u662f\u5426\u6709\u6709\u5bb3\u6c23\u9ad4\u6d29\u6f0f\uff0c\u672c\u8655\u4ee5\u5bb9\u6613\u53d6\u5f97\u7684\u9152\u7cbe\u53d6\u4ee3\u74e6\u65af\uff0c\u4e26\u4ee5\u71c8\u865f\u986f\u793a\u74b0\u5883\u7684\u56b4\u91cd\u7a0b\u5ea6\uff0c\u7576\u7136\u5f8c\u7e8c\u8b1b\u5230\u7db2\u8def\u53ca\u85cd\u82bd\u6642\uff0c\u5c31\u53ef\u4ee5\u900f\u904e\u7db2\u8def\u767c\u5e03LINE\u8a0a\u606f\u7d66\u7ba1\u7406\u54e1\u9032\u884c\u7dca\u6025\u8655\u7f6e\uff0c\u8acb\u8b80\u8005\u6301\u7e8c\u95dc\u6ce8\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u611f\u6e2c\u6709\u5bb3\u6c23\u9ad4\u6d29\u6f0f\u56b4\u91cd\uff1a\u7d05\u71c8<\/li>\n\n\n\n<li>\u611f\u6e2c\u6709\u5bb3\u6c23\u9ad4\u6d29\u6f0f\u5fb5\u5146\uff1a\u9ec3\u71c8<\/li>\n\n\n\n<li>\u611f\u6e2c\u74b0\u5883\u6c23\u9ad4\u72c0\u6cc1\u6b63\u5e38\uff1a\u7da0\u71c8<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-11111\">\u4e8c\u3001\u6750\u6599\u6e96\u5099<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>ESP32\u4e3b\u677f+\u9eb5\u5305\u677f<\/li>\n\n\n\n<li>\u7d05\u3001\u9ec3\u3001\u7da0LED\u71c8\u54041<\/li>\n\n\n\n<li>\u675c\u90a6\u7dda\u82e5\u5e72<\/li>\n\n\n\n<li>\u9152\u7cbe\u68c9\u7247\u82e5\u5e72\uff1a\u7528\u4f86\u6a21\u64ec\u74e6\u65af\u5916\u6d29<\/li>\n\n\n\n<li>mq2\u6c23\u9ad4\u611f\u61c9\u5668\uff1amq2\u5916\u578b\u5982\u4e0b\u5716\uff0c\u5916\u578b\u6709\u9ede\u50cf\u9ea5\u514b\u98a8\uff0c\u56db\u8ddf\u8173\u4f4d\u8207\u4e0a\u4e00\u7bc7\u7684\u5149\u654f\u96fb\u963b\u5b8c\u5168\u4e00\u6a23\uff0cAO=\u985e\u6bd4\u8f38\u51fa\u3001DO\uff1d\u6578\u4f4d\u8f38\u51fa\uff0c\u800c\u5728\u5916\u7f69\u5167\u90e8\u662f\u4e8c\u6c27\u5316\u932b\u7dda\uff0c\u5176\u5de5\u4f5c\u539f\u7406\u662f\u7576\u7a7a\u6c23\u4e2d\u6709\u53ef\u71c3\u6c23\u9ad4\u6642\uff0c\u5247\u6703\u6539\u8b8a\u7dda\u7684\u5c0e\u96fb\u7387\uff0c\u85c9\u7531\u8b8a\u5316\u4f86\u63d0\u4f9b\u6fc3\u5ea6\u300c\u6578\u503c\u300d\u7684\u53c3\u8003\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582914373-624637825.png?resize=841%2C720&#038;ssl=1\" alt=\"\" width=\"841\" height=\"720\"\/><figcaption class=\"wp-element-caption\">mq2\u7684\u5916\u89c0<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582913616-1075797867.png?resize=532%2C520&#038;ssl=1\" alt=\"\" width=\"532\" height=\"520\"\/><figcaption class=\"wp-element-caption\">mq\u611f\u6e2c\u5668\u5167\u90e8\u7684\u4e8c\u6c27\u5316\u932b\u7dda<\/figcaption><\/figure>\n\n\n\n<p>\u9019\u88e1\u5fc5\u9808\u8981\u8aaa\u660e\u4e00\u4e0bmq\u7cfb\u5217\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u6839\u64da\u539f\u5ee0\u7684\u8aaa\u660e\uff0c\u7531\u65bc\u51fa\u5ee0\u6642\u6703\u6709\u4e9b\u96dc\u8cea\u9644\u8457\u5728\u4e8c\u6c27\u5316\u932b\u7dda\u4e0a\uff0c\u56e0\u6b64\u958b\u6a5f\u5f8c2hr\u5167\u7684\u6578\u503c\u6703\u504f\u9ad8\uff0c\u4e5f\u6703\u805e\u5230\u4e00\u80a1\u6de1\u6de1\u7684\u71d2\u7126\u5473(\u6709\u4eba\u6703\u4ee5\u70ba\u6676\u7247\u71d2\u6389\u800c\u66ab\u505c\u5be6\u9a57)\uff0c\u7136\u5f8c\u6162\u6162\u8d70\u5411\u7a69\u5b9a\uff0c\u800c\u500b\u4eba\u5efa\u8b70\u81f3\u5c11\u7b4924hr\u6703\u6bd4\u8f03\u7a69\u5b9a\u3002\u53e6\u5916\u6709\u4eba\u6703\u554f\u5982\u679c\u5f9emq\u62ff\u5230\u7684\u6578\u503c\u4ee3\u8868\u4ec0\u9ebc\u542b\u610f\uff0c\u662fppm\u9084\u662fml\uff1f\u500b\u4eba\u7684\u610f\u898b\u662f\u9019\u500b\u6578\u503c\u53ea\u662f\u63d0\u4f9b\u60a8\u300c\u76f8\u5c0d\u300d\u6bd4\u8f03\u7528\u7684\uff0c\u4e26\u4e0d\u80fd\u6e96\u78ba\u8f49\u63db\u6210ppm\u6216\u8005\u5176\u4ed6\u300c\u7d55\u5c0d\u300d\u6578\u503c\u3002\u70ba\u4ec0\u9ebc\uff1f<\/p>\n\n\n\n<p>\u6839\u64da\u539f\u5ee0\u63d0\u4f9b\u7684\u898f\u683c\u8868\u6703\u767c\u73fe\uff0c\u80fd\u5f71\u97ffmq2\u6578\u503c\u7684\u7a2e\u985e\u76f8\u7576\u591a\uff0c\u800c\u6211\u5011\u7a7a\u6c23\u4e2d\u6216\u591a\u6216\u5c11\u90fd\u6703\u6b98\u7559\u9019\u4e9b\u6709\u6a5f\u6c23\u9ad4\uff0c\u5f71\u97ff\u5230\u611f\u6e2c\u7684\u6578\u503c\uff0c\u4f46\u5b83\u53ea\u6703\u53cd\u61c9\u4e00\u500b\u6578\u503c\uff0c\u6240\u4ee5\u5230\u5e95\u662f\u7d66\u4e88\u54ea\u4e00\u7a2e\u6c23\u9ad4\u7684\u6578\u503c\u5df2\u7d93\u7121\u6cd5\u77e5\u9053\uff1f\u96d6\u7136\u7db2\u8def\u53ef\u4ee5\u641c\u5c0b\u5230\u4e00\u4e9b\u8f49\u63dbppm\u7684\u516c\u5f0f(\u4f8b\u5982\uff1a <a href=\"http:\/\/sandboxelectronics.com\/?p=165\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/sandboxelectronics.com\/?p=165<\/a> )\uff0c\u4f46\u6211\u5be6\u969b\u5957\u7528\u5f8c\u767c\u73fe\u8aa4\u5dee\u76f8\u7576\u5927\uff0c\u500b\u4eba\u5efa\u8b70\u662f\u653e\u68c4\u8f49ppm\u7684\u65b9\u5f0f\uff0c\u6539\u4ee5\u76f8\u5c0d\u65b9\u5f0f\u6bd4\u8f03\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582914920-136662242.png?resize=840%2C738&#038;ssl=1\" alt=\"\" width=\"840\" height=\"738\"\/><figcaption class=\"wp-element-caption\">mq\u611f\u6e2c\u5668\u5c0d\u65bc\u4e0d\u540c\u6c23\u9ad4\u7684\u654f\u611f\u5ea6\u5206\u6790<\/figcaption><\/figure>\n\n\n\n<p>\u9019\u88e1\u5c0d\u65bc\u8981\u4f7f\u7528mq\u7cfb\u5217\u5925\u4f34\u7684\u5efa\u8b70\u662f\uff0c\u5148\u5728\u74b0\u5883\u4e2d\u975c\u81f3\u4e00\u6bb5\u6642\u9593\uff0c\u9577\u671f\u89c0\u5bdf\u6578\u503c\u7684\u7a69\u5b9a\u72c0\u614b\uff0c\u6839\u64da\u7b46\u8005\u7d93\u9a57\uff0c\u6bcf\u9846mq\u90fd\u6709\u81ea\u5df1\u7684\u500b\u6027\uff0c\u6709\u4e9b50-100\uff0c\u6709\u4e9b200-400\u4e4b\u9593\u8df3\u52d5\uff0c\u56e0\u6b64\u5f37\u52a0\u4e0a\u4e00\u500b\u56fa\u5b9a\u9580\u6abb\u503c\u662f\u4e0d\u884c\u7684\uff0c\u53ea\u80fd\u6539\u6210\u76f8\u5c0d\u7684\u65b9\u5f0f\uff0c\u5c31\u662f\u5c07\u9577\u671f\u7684\u89c0\u5bdf\u503c\u8a2d\u5b9a\u70ba\u6b63\u5e38\u72c0\u614b\u4f8b\u5982\u6b63\u5e38\uff1d100\uff0c\u63a5\u4e0b\u4f86\u5229\u7528\u9152\u7cbe\u9760\u8fd1\u6e2c\u8a66\uff0c\u4f8b\u5982\u8df3\u81f3\uff1d700\uff0c\u4e86\u89e3mq\u7684\u654f\u611f\u5ea6\u5f8c\uff0c\u5c31\u53ef\u6c7a\u5b9a\u4e00\u500b\u9580\u6abb\u6578\u503c\uff0c\u4f8b\u5982\u8d85\u904e300\u4ee3\u8868\u6fc3\u5ea6\u9ec3\u71c8\u8b66\u6212\uff0c\u8d85\u904e600\u5247\u662f\u4eae\u51fa\u7d05\u71c8\u8b66\u544a\u3002\u7531\u65bc\u6bcf\u4e00\u500b\u4eba\u7684\u74b0\u5883\u8207\u611f\u6e2c\u5668\u7684\u72c0\u6cc1\u4e0d\u540c\uff0c\u9019\u500b\u6578\u503c\u7531\u6bcf\u500b\u4eba\u6e2c\u8a66\u5f8c\u81ea\u884c\u6c7a\u5b9a\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u9019\u7a2e\u65b9\u5f0f\u4e5f\u53ef\u4ee5\u7528\u7a0b\u5f0f\u81ea\u52d5\u4f5c\u9577\u671f\u53d6\u6a23\uff0c\u7b49\u5f8c\u7e8c\u8f03\u6df1\u5165\u7684\u8ab2\u7a0b\u518d\u505a\u8aaa\u660e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-esp321\">\u4e09\u3001ESP32\u7dda\u8def\u4f48\u7f6e<\/h2>\n\n\n\n<p>\u7dda\u8def\u4f48\u7f6e\u65b9\u5f0f\u8207\u4e0a\u4e00\u7bc7\u5b8c\u5168\u76f8\u540c\u3002\u53ea\u9808\u5c07\u5149\u654f\u96fb\u963b\u79fb\u9664\uff0c\u63db\u6210mq2\u5373\u53ef\uff0c\u76f8\u540c\u7684\u6211\u5011\u4e00\u6a23\u4f7f\u7528AO\u4f5c\u70ba\u985e\u6bd4\u8f38\u51fa\uff0c\u63a5\u5728ESP32\u9eb5\u5305\u677f\u5de6\u5074\u5e8f\u865f5\uff0c\u5be6\u969bGPIO13\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582975729-3337654855.png?resize=840%2C644&#038;ssl=1\" alt=\"\" width=\"840\" height=\"644\"\/><figcaption class=\"wp-element-caption\">ESP32\u8207mq2\u8def\u7dda\u914d\u7f6e\u5716<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582394120-1611057319_n.png?resize=838%2C422&#038;ssl=1\" alt=\"\" width=\"838\" height=\"422\"\/><figcaption class=\"wp-element-caption\">ESP32\u8173\u4f4d\u7de8\u865f<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-11111111\">\u56db\u3001\u7a0b\u5f0f\u64b0\u5beb<\/h2>\n\n\n\n<p>\u76f8\u540c\u7684\u6211\u5011\u5148\u6e2c\u8a66mq2\u662f\u5426\u6b63\u5e38\uff0c\u6211\u5011\u5c07analogRead\u74e6\u65af\u6578\u503c\u653e\u7f6e\u5728\u8b8a\u6578GasValue\u4e2d\uff0c\u4e26\u986f\u793a\u5728\u8996\u7a97\u4e2d\u67e5\u770b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\n  Serial.begin(115200);\n  pinMode(13, INPUT);\/\/\u9078\u544aGPIO 13\u4f5c\u70ba\u8f38\u5165\uff08Mq2\u6c23\u9ad4\u611f\u6e2c\uff09\n}\n\nvoid loop() {\n  int GasValue;\/\/\u5ba3\u544a\u8b8a\u6578GasValue\n  GasValue = analogRead(13); \/\/\u8b80\u53d6\u7684GPIO 13\u8b80\u53d6\u7684\u6578\u503c\u653e\u5728GasValue\n  Serial.println(GasValue); \/\/GasValue\u986f\u793a\u5728\u5e8f\u5217\u8996\u7a97\n  delay(100);\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"965\" height=\"863\" src=\"https:\/\/i0.wp.com\/www.nmking.io\/wp-content\/uploads\/2022\/11\/IMG_20200229_032233.jpg?resize=965%2C863&#038;ssl=1\" alt=\"\" class=\"wp-image-599\" srcset=\"https:\/\/i0.wp.com\/www.nmking.io\/wp-content\/uploads\/2022\/11\/IMG_20200229_032233.jpg?w=965&amp;ssl=1 965w, https:\/\/i0.wp.com\/www.nmking.io\/wp-content\/uploads\/2022\/11\/IMG_20200229_032233.jpg?resize=300%2C268&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.nmking.io\/wp-content\/uploads\/2022\/11\/IMG_20200229_032233.jpg?resize=768%2C687&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.nmking.io\/wp-content\/uploads\/2022\/11\/IMG_20200229_032233.jpg?resize=200%2C179&amp;ssl=1 200w\" sizes=\"auto, (max-width: 965px) 100vw, 965px\" \/><figcaption class=\"wp-element-caption\">\u9152\u7cbe\u68c9\u7247\u6e2c\u8a66\u88dd\u7f6e<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1582917919-2928104970.png?resize=386%2C668&#038;ssl=1\" alt=\"\" width=\"386\" height=\"668\"\/><figcaption class=\"wp-element-caption\">\u985e\u6bd4\u8a0a\u865f\u8b80\u53d6\u7d50\u679c<\/figcaption><\/figure>\n\n\n\n<p>\u7d93\u904e\u4e0d\u65b7\u6aa2\u9a57\u8207\u6bd4\u8f03\u5f8c\uff0c\u6211\u5011\u6e2c\u8a66\u7684\u9580\u6abb\u503c\u5206\u5225\u70ba<\/p>\n\n\n\n<p>1.\u7da0\u71c8\u6b63\u5e38\uff1a0~200<br>2.\u9ec3\u71c8\u63d0\u793a\uff1a200~400<br>3.\u7d05\u71c8\u8b66\u5831\uff1a400\u4ee5\u4e0a<\/p>\n\n\n\n<p>\u63a5\u4e0b\u4f86\u6211\u5011\u53ef\u4ee5\u5beb\u7a0b\u5f0f\u4f86\u5b8c\u6210\u4e0a\u8ff0\u7684\u8a2d\u5b9a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\n  Serial.begin(115200);\n  pinMode(15, OUTPUT);\/\/\u9078\u544aGPIO15\u4f5c\u70ba\u8f38\u51fa\uff08\u7da0\u8272LED\uff09\n  pinMode(2, OUTPUT);\/\/\u9078\u544aGPIO 2\u4f5c\u70ba\u8f38\u51fa\uff08\u9ec3\u8272LED\uff09\n  pinMode(4, OUTPUT);\/\/\u9078\u544aGPIO 4\u4f5c\u70ba\u8f38\u51fa\uff08\u7d05\u8272LED\uff09\n  pinMode(13, INPUT);\/\/\u9078\u544aGPIO 13\u4f5c\u70ba\u8f38\u5165\uff08Mq2\u6c23\u9ad4\u611f\u6e2c\uff09\n}\n\nvoid loop() {\n  int GasValue;\/\/\u5ba3\u544a\u8b8a\u6578GasValue\n  GasValue = analogRead(13); \/\/\u8b80\u53d6\u7684GPIO 13\u8b80\u53d6\u7684\u6578\u503c\u653e\u5728GasValue\n  Serial.println(GasValue); \/\/GasValue\u986f\u793a\u5728\u5e8f\u5217\u8996\u7a97\n  if (GasValue &lt; 200) {\n    \/\/\u5c0f\u65bc200\uff0c\u4ee3\u8868\u4e00\u5207\u6b63\u5e38\uff0c\u4eae\u7da0\u71c8\n    digitalWrite(15, HIGH);\n    digitalWrite(2, LOW);\n    digitalWrite(4, LOW);\n  }\n\n  if (GasValue &gt;= 200 &amp;&amp; GasValue &lt; 400) {\n    \/\/200-400\u4e4b\u9593\uff0c\u9ec3\u71c8\u986f\u793a\u5916\u6d29\u8b66\u6212\n    digitalWrite(15, LOW);\n    digitalWrite(2, HIGH);\n    digitalWrite(4, LOW);\n  }\n  if (GasValue &gt;= 400) {\n    \/\/\u8d85\u904e600\uff0c\u767c\u51fa\u5916\u6d29\u8b66\u5831\n    digitalWrite(15, LOW);\n    digitalWrite(2, LOW);\n    digitalWrite(4, HIGH);\n  }\n  delay(100);\n}<\/code><\/pre>\n\n\n\n<p>\u53e6\u5916\u4e00\u500b\u597d\u73a9\u7684\u5247\u662f\u53ef\u4ee5\u7576\u4f5c\u53e3\u81ed\u611f\u6e2c\u5668\u6216\u5c41\u611f\u6e2c\u5668\uff0c\u7562\u7adf\u4eba\u9ad4\u662f\u4e00\u500b\u5927\u578b\u6709\u6a5f\u7269\uff0c\u547c\u51fa\u7684\u7a7a\u6c23\u5167\u6709\u5927\u91cf\u7684\u6709\u6a5f\u6c23\u9ad4\uff0c\u56e0\u6b64\u4e5f\u53ef\u4ee5\u5617\u8a66\u5c0d\u611f\u6e2c\u5668\u547c\u4e00\u53e3\u6c23\uff0c\u6703\u6709\u610f\u60f3\u4e0d\u5230\u7684\u6548\u679c\u5594\u3002<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"htoc-111111111\" style=\"font-size:clamp(16.293px, 1.018rem + ((1vw - 3.2px) * 0.68), 25px);\">\u5ef6\u4f38\u95b1\u8b80<\/h4>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#f2f2f2\">????   <a href=\"https:\/\/www.nmking.io\/index.php\/2022\/11\/21\/esp32_ch1-14\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u7b2c\u516b\u7bc7 \u8d85\u97f3\u6ce2\u6e2c\u8ddd\u53ca\u8702\u9cf4\u5668\u88fd\u4f5c\u5012\u8eca\u96f7\u9054<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u8981\u8ac7\u7684\u662fmq\u7cfb\u5217\u7684\u6c23\u9ad4\u611f\u6e2c\u5668\uff0c\u76f8\u540c\u7684\u662f\u4f7f\u7528\u985e\u6bd4\u8b80\u53d6\uff0c\u53ea\u662f\u9019\u9846\u611f\u6e2c\u5668\u5176\u5be6\u7528\u9014\u4e0d\u5927\uff0c\u505a\u7c21\u6613\u5be6\u9a57\u53ef\uff0c\u4f46\u662f\u8981\u505a\u7cbe\u78ba\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1,29],"tags":[],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-esp32","category-esp32-started"],"blocksy_meta":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/comments?post=598"}],"version-history":[{"count":4,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":925,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/598\/revisions\/925"}],"wp:attachment":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}