{"id":20761,"date":"2023-11-13T16:51:37","date_gmt":"2023-11-13T08:51:37","guid":{"rendered":"https:\/\/www.circuspi.com\/?p=20761"},"modified":"2023-11-16T11:00:58","modified_gmt":"2023-11-16T03:00:58","slug":"esp32-uart-pms5003t","status":"publish","type":"post","link":"https:\/\/www.circuspi.com\/index.php\/2023\/11\/13\/esp32-uart-pms5003t\/","title":{"rendered":"ESP32\u6559\u5b78\u7cfb\u5217(\u4e03)\uff1a\u4ee5PMS5003T\u6e2c\u91cf\u7a7a\u6c23\u54c1\u8cea &#8211; \u8ac7UART\u7684\u4f7f\u7528"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"526\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/1000x526_1.jpg\" alt=\"\" class=\"wp-image-20801\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>\u63a5\u4e0b\u4f86\u7684\u5e7e\u7bc7\u6587\u7ae0\u6703\u9678\u7e8c\u4ecb\u7d39\u5fae\u63a7\u5236\u5668\u5e38\u7528\u7684\u4ecb\u9762\uff0c\u9019\u7bc7\u6211\u5011\u5c07\u4f7f\u7528\u6500\u85e4\u79d1\u6280\u63a8\u51fa\u7684\u7684<a href=\"https:\/\/www.icshop.com.tw\/products\/368030200769\" target=\"_blank\" rel=\"noreferrer noopener\">PMS5003T<\/a> PM2.5\u6eab\u6ebc\u5ea6\u4e8c\u5408\u4e00\u611f\u6e2c\u5668\u4f86\u4ecb\u7d39<a href=\"https:\/\/www.icshop.com.tw\/categories\/esp32\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32<\/a> UART\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">UART\u7c21\u4ecb<\/h2>\n\n\n\n<p>UART\u7684\u5168\u540d\u662f\u300c\u901a\u7528\u975e\u540c\u6b65\u63a5\u6536\u5668\/\u767c\u9001\u5668 (Universal Asynchronous Receiver\/Transmitter)\u300d\uff0c\u4e3b\u8981\u7528\u9014\u662f\u5be6\u73fe\u4e32\u5217\u8cc7\u6599\u7684\u50b3\u9001\u8207\u63a5\u6536\uff0c\u4e00\u822c\u5e38\u7528\u65bc\u5169\u500b\u4e0d\u540c\u8a2d\u5099\u6216\u88dd\u7f6e\u4e4b\u9593\u7684\u901a\u8a0a\uff0c\u5177\u9ad4\u7684\u5be6\u7269\u901a\u5e38\u6703\u4ee5\u5fae\u63a7\u5236\u5668\u5167\u90e8\u7684\u5468\u908a\u88dd\u7f6e(peripheral)\u6216\u662fIC\u7684\u5f62\u5f0f\u51fa\u73fe\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528UART\u50b3\u8f38\u8a0a\u606f\u6642\uff0c\u5169\u908a\u7684\u8a2d\u5099\u9700\u8981\u7528\u76f8\u540c\u7684\u8cc7\u6599\u683c\u5f0f\u4ee5\u53ca\u7d04\u5b9a\u597d\u7684\u50b3\u8f38\u901f\u5ea6\u624d\u80fd\u4e92\u76f8\u901a\u8a0a\uff0c\u9019\u500b\u8cc7\u6599\u50b3\u8f38\u901f\u5ea6\u5728UART\u4e2d\u7a31\u70ba\u9b91\u7387(baud rate)\uff0c\u55ae\u4f4d\u662fbps (bits per sec)\uff0c\u610f\u601d\u662f\u6bcf\u79d2\u9418\u50b3\u9001\u591a\u5c11\u500b\u4f4d\u5143\u6578\u3002\u5982\u679c\u683c\u5f0f\u6216\u9b91\u7387\u4e0d\u4e00\u81f4\uff0c\u5c31\u6703\u7121\u6cd5\u6b63\u78ba\u6e9d\u901a\u3002<\/p>\n\n\n\n<p>UART\u7684\u5176\u4e2d\u4e00\u9805\u512a\u9ede\u662f\u53ea\u9700\u8981\u5169\u689d\u8cc7\u6599\u7dda\uff0c\u4e00\u689d\u7528\u4f86\u767c\u9001\u8cc7\u6599(TX)\uff0c\u53e6\u4e00\u689d\u7528\u4f86\u63a5\u6536\u8cc7\u6599(RX)\uff0c\u8a2d\u5099\u4e4b\u9593\u7684TX\u8207RX\u6210\u5c0d\u9023\u63a5\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"4167\" height=\"2448\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/01_\u5de5\u4f5c\u5340\u57df-1.jpg\" alt=\"\" class=\"wp-image-20799\"\/><figcaption class=\"wp-element-caption\">UART\u9023\u63a5\u793a\u610f\u5716<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728ESP32\u4f7f\u7528UART<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Arduino\u540d\u7a31<\/th><th>UART\u4ee3\u865f<\/th><th>TX<\/th><th>RX<\/th><th>\u662f\u5426\u80fd\u76f4\u63a5\u4f7f\u7528<\/th><\/tr><\/thead><tbody><tr><td>Serial<\/td><td>UART0<\/td><td>GPIO 1<\/td><td>GPIO 3<\/td><td>\u2705<\/td><\/tr><tr><td>Serial1<\/td><td>UART1<\/td><td>GPIO 10<\/td><td>GPIO 9<\/td><td>\u274c\uff0c\u9700\u8981\u91cd\u65b0\u5b9a\u7fa9\u63a5\u8173<\/td><\/tr><tr><td>Serial2<\/td><td>UART2<\/td><td>GPIO 17<\/td><td>GPIO 16<\/td><td>\u2705<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>ESP32\u7e3d\u5171\u67093\u500bUART\uff083.3V TTL\u96fb\u58d3\u6e96\u4f4d\uff09\uff0cUART0\u8207UART2\u90fd\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u4f46\u662fUART1\u9810\u8a2d\u7684\u5169\u96bb\u63a5\u8173\u90fd\u9023\u63a5\u5230\u6a21\u7d44\u5167\u7684SPI Flash\uff0c\u6c92\u8fa6\u6cd5\u76f4\u63a5\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u4f46\u7531\u65bcESP32\u6709\u63a5\u8173\u591a\u5de5\uff08pin multiplexing\uff09\u7684\u529f\u80fd\uff0c\u6211\u5011\u53ea\u8981\u5c07UART1\u91cd\u65b0\u6620\u5c04\u5230\u5176\u4ed6GPIO\u5f8c\u5c31\u4f9d\u7136\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u3002\u6240\u6709\u63a5\u8173\u90fd\u53ef\u4ee5\u91cd\u65b0\u6620\u5c04\uff0c\u4e00\u822c\u6703\u5c07UART0\u7559\u505a\u8207\u958b\u767c\u677f\u901a\u8a0a\uff0c\u9700\u8981\u8207\u5176\u4ed6\u88dd\u7f6e\u901a\u8a0a\u6642\u518d\u4f7f\u7528UART1\u548cUART2\u3002<\/p>\n\n\n\n<p>\u5047\u5982\u4f7f\u7528\u9810\u8a2d\u63a5\u8173\uff0c\u53ea\u9700\u8981\u5728setup()\u51fd\u5f0f\u4e2d\u5ba3\u544a\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Serial2.begin(9600); \/\/ \u8a2d\u5b9aSerial2\u9b91\u7387\u70ba9600<\/code><\/pre>\n\n\n\n<p><p>\u5047\u5982\u8981\u91cd\u65b0\u6620\u5c04\u63a5\u8173\uff0c\u9996\u5148\u8981\u532f\u5165HardwareSerial\u51fd\u5f0f\u5eab\u3002\u9019\u500b\u51fd\u5f0f\u5eab\u5df2\u7d93\u5167\u5efa\u5728Arduino IDE\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u53e6\u5916\u5b89\u88dd\u3002<\/p><p>\u5177\u9ad4\u4f5c\u6cd5\u53ef\u4ee5\u53c3\u8003\u4e0b\u9762\u7684\u7a0b\u5f0f\u7bc4\u4f8b\uff1a<\/p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;HardwareSerial.h&gt;\n\nHardwareSerial NewSerial(1);  \/\/ \u4f7f\u7528UART1\n\nvoid setup() {\n  \/\/ \u521d\u59cb\u5316NewSerial\n  NewSerial.begin(9600, SERIAL_8N1, 12, 14) \/\/ \u914d\u7f6e\u7684\u53c3\u6578\u4f9d\u5e8f\u70ba\u9b91\u7387, UART\u914d\u7f6e, RX, TX\u3002\u5176\u9918\u53c3\u6578\u4f7f\u7528\u9810\u8a2d\u503c\u5373\u53ef\n}\n\nvoid loop() {\n\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5176\u4ed6\u8aaa\u660e\u4e8b\u9805<\/h3>\n\n\n\n<ul>\n<li>\u81ea\u5b9a\u7fa9\u7684NewSerial\u9664\u4e86\u4e00\u958b\u59cb\u8981\u7279\u5225\u5ba3\u544a\u4e4b\u5916\uff0c\u5176\u4ed6\u7684\u7528\u6cd5\u90fd\u8207\u4e00\u822c\u7684Serial\u76f8\u540c(read, write, println, available, \u2026)<\/li>\n\n\n\n<li>Serial\u7684\u7b2c\u4e8c\u9805\u53c3\u6578\u9810\u8a2d\u662fSERIAL_8N1\uff0c\u610f\u601d\u662f8\u500b\u8cc7\u6599\u4f4d\u5143\u3001\u7121\u6821\u9a57\u4f4d\u548c1\u500b\u505c\u6b62\u4f4d\u5143\u3002\u5982\u679c\u8981\u4f7f\u7528\u5176\u4ed6\u914d\u7f6e\u53ef\u4ee5\u53c3\u8003Arduino\u6587\u4ef6\u4e2d\u7684Parameters\u6b04\uff08<a href=\"https:\/\/www.arduino.cc\/reference\/en\/language\/functions\/communication\/serial\/begin\/#:~:text=begin(speed%2C%20config)-,Parameters,-Serial%3A%20serial%20port\">\u9023\u7d50<\/a>\uff09(<a href=\"https:\/\/github.com\/G6EJD\/ESP32-Using-Hardware-Serial-Ports\/blob\/master\/ESP32_Using_Serial2.ino\">github\u9023\u7d50<\/a>)<\/li>\n\n\n\n<li>GPIO34, 35, 36, 39\u63a5\u8173\u53ea\u80fd\u5141\u8a31\u8f38\u5165\uff0c\u5982\u679c\u5b9a\u7fa9\u5230TX\u63a5\u8173\u6703\u7121\u6cd5\u4f7f\u7528\u3002<\/li>\n\n\n\n<li>GPIO 6~ GPIO 11\u9023\u63a5\u5230\u6a21\u7d44\u7684SPI Flash\uff0c\u4f7f\u7528\u9019\u4e9b\u63a5\u8173\u53ef\u80fd\u6703\u4f7fESP32\u904b\u4f5c\u6642\u7522\u751f\u554f\u984c\uff0c\u5728\u5b9a\u7fa9UART\u63a5\u8173\u6642\u8acb\u8a18\u5f97\u907f\u958b\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6e2c\u91cf\u7a7a\u6c23\u54c1\u8cea\u7684\u597d\u5e6b\u624b &#8211; PMS5003T<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.icshop.com.tw\/products\/368030200769\" target=\"_blank\" rel=\"noreferrer noopener\">PMS5003T<\/a>\u662f\u6500\u85e4\u79d1\u6280\u63a8\u51fa\u7684\u4e00\u6b3ePM2.5\u6eab\u6ebc\u5ea6\u4e8c\u5408\u4e00\u611f\u6e2c\u5668\uff0c\u5b83\u53ef\u4ee5\u6e2c\u91cf\u5e38\u898b\u5927\u5c0f\u7684\u61f8\u6d6e\u5fae\u7c92\u4ee5\u53ca\u74b0\u5883\u6eab\u6fd5\u5ea6\u6578\u503c\u505a\u70ba\u76ee\u524d\u7a7a\u6c23\u54c1\u8cea\u7684\u53c3\u8003\u3002<\/p>\n\n\n\n<p>\u6e2c\u91cf\u61f8\u6d6e\u5fae\u7c92\u6709\u5f88\u591a\u7a2e\u65b9\u6cd5\uff0c\u5c08\u696d\u7684\u76e3\u6e2c\u5100\u5668\u5927\u591a\u4f7f\u7528\u03b2\u5c04\u7dda\u8870\u6e1b\u6cd5\u6216\u662f\u64fa\u52d5\u5f0f\u9310\u72c0\u5fae\u91cf\u5929\u5e73\u6cd5\uff0c\u96d6\u7136\u7d50\u679c\u6e96\u78ba\u3001\u7cbe\u5ea6\u9ad8\uff0c\u4f46\u50f9\u683c\u6602\u8cb4\uff0c\u9700\u8981\u5b9a\u671f\u6821\u6b63\u5100\u5668\u3001\u6aa2\u67e5\u7ba1\u8def\u6d41\u7387\u8207\u66f4\u63db\u6ffe\u7d19\uff0c\u901a\u5e38\u53ea\u6709\u653f\u5e9c\u55ae\u4f4d\u6216\u5c08\u696d\u7684\u5be6\u9a57\u5ba4\u624d\u6703\u4f7f\u7528\u9019\u985e\u5100\u5668\u3002<\/p>\n\n\n\n<p>\u53e6\u4e00\u7a2e\u5e38\u898b\u7684\u6e2c\u91cf\u65b9\u6cd5\u662f\u96f7\u5c04\u6563\u5c04\uff0c\u5b83\u7684\u539f\u7406\u662f\u5c07\u4e00\u675f\u96f7\u5c04\u5149\u6253\u5728\u7a7a\u6c23\u4e2d\uff0c\u7576\u7a7a\u6c23\u4e2d\u6709\u9846\u7c92\u7269\u6642\u5c31\u6703\u4f7f\u96f7\u5c04\u5149\u7522\u751f\u6563\u5c04\uff0c\u63a5\u8457\u5c31\u80fd\u7d93\u7531\u4e0d\u540c\u7684\u6563\u5c04\u89d2\u5ea6\u4ee5\u53ca\u5149\u7684\u5f37\u5ea6\u9032\u4e00\u6b65\u63a8\u7b97\u51fa\u7a7a\u6c23\u4e2d\u4e0d\u540c\u5c3a\u5bf8\u7684\u9846\u7c92\u7269\u6fc3\u5ea6\uff0c\u662f\u76ee\u524d\u624b\u6301\u5f0f\u61f8\u6d6e\u5fae\u7c92\u6e2c\u91cf\u8a2d\u5099\u6700\u5e38\u898b\u7684\u6e2c\u91cf\u65b9\u6cd5\uff0c\u6500\u85e4\u79d1\u6280\u63a8\u51fa\u7684PMS\u7cfb\u5217\u611f\u6e2c\u5668\uff0c\u5305\u542bPMS5003T\u5167\u90e8\u4e5f\u90fd\u662f\u4f7f\u7528\u9019\u7a2e\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>PMS5003T\u53ef\u4ee5\u9023\u7e8c\u63a1\u96c6\u7a7a\u6c23\u4e2d\u4e0d\u540c\u5927\u5c0f\u7684\u61f8\u6d6e\u5fae\u7c92\uff08\u5982PM1.0\u3001PM2.5\u3001PM10\uff09\u6578\u91cf\u4e26\u4e14\u8a08\u7b97\u51fa\u8cea\u91cf\u6fc3\u5ea6\uff0c\u6700\u5c0f\u53ef\u4ee5\u6e2c\u91cf\u52300.3um\u7684\u9846\u7c92\u3002\u9664\u4e86\u5075\u6e2c\u61f8\u6d6e\u5fae\u7c92\u4e4b\u5916\uff0c\u5728\u5b83\u7684\u611f\u6e2c\u5668\u5167\u90e8\u53e6\u5916\u6709\u4e00\u9846\u6e2c\u91cf\u6eab\u6fd5\u5ea6\u7684\u6676\u7247\uff0c\u9019\u4e9b\u8cc7\u6599\uff08\u61f8\u6d6e\u5fae\u7c92\u8207\u6eab\u6ebc\u5ea6\u7684\u6578\u503c\uff09\u6703\u4ee5UART\u8f38\u51fa\u3002<\/p>\n\n\n\n<p>\ud83d\udca1 <strong>Tips:<\/strong> \u74b0\u5883\u6fd5\u5ea6\u5c0d\u65bc\u96f7\u5c04\u6563\u5c04\u539f\u7406\u611f\u6e2c\u5668\u7684\u6e2c\u91cf\u7d50\u679c\u6703\u6709\u5f88\u5927\u7684\u5f71\u97ff\uff0c\u7576\u6fd5\u5ea6\u8d8a\u9ad8\uff0c\u6e2c\u91cf\u8aa4\u5dee\u5c31\u8d8a\u5927\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5916\u89c0<\/h3>\n\n\n\n<p>\u611f\u6e2c\u5668\u63a5\u53e3\u4f7f\u7528\u7684\u662f1.25mm\u7684\u9023\u63a5\u5668\uff0c\u8207\u4e00\u822c\u675c\u90a6\u7dda\u7684\u898f\u683c\u4e0d\u540c\uff0c\u8cfc\u8cb7\u6642\u53ef\u4ee5\u6ce8\u610f\u4e00\u4e0b\u5e97\u5bb6\u6709\u6c92\u6709\u9644\u4e0a\u8f49\u63a5\u7dda\u6216\u8f49\u63a5\u677f\uff0c\u9019\u6a23\u5728\u5be6\u9a57\u7684\u6642\u5019\u6703\u65b9\u4fbf\u4e00\u4e9b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/IMG_2208.jpeg\" alt=\"PMS5003T\u5916\u89c0\" class=\"wp-image-20764\" width=\"800\" height=\"601\" title=\"PMS5003T\"\/><figcaption class=\"wp-element-caption\">PMS5003T \u8a0a\u865f\u63a5\u53e3<\/figcaption><\/figure>\n\n\n\n<p>\u9023\u63a5\u5668\u7684\u53e6\u4e00\u7aef\u662f\u9032\u6c23\u5b54\u8207\u51fa\u6c23\u5b54<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/IMG_2205.jpeg\" alt=\"PMS5003T \u9032\u6c23\u98a8\u6247\" class=\"wp-image-20765\" width=\"800\" height=\"600\" title=\"PMS5003T \u9032\u6c23\u98a8\u6247\"\/><figcaption class=\"wp-element-caption\">PMS5003T \u9032\u6c23\u98a8\u6247<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8173\u4f4d\u5b9a\u7fa9<\/h3>\n\n\n\n<p>\u611f\u6e2c\u5668\u8a0a\u865f\u7d93\u75313.3V \u96fb\u58d3\u6e96\u4f4d\u7684UART\u8f38\u51fa\uff0c\u53ea\u9700\u89814\u689d\u7ddaVCC\u3001GND\u3001TX\u3001RX\uff0c\u5c31\u80fd\u5b8c\u6210\u57fa\u672c\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/IMG_2197.jpeg\" alt=\"PMS5003T \u5f15\u8173\u9806\u5e8f\" class=\"wp-image-20766\" width=\"800\" height=\"600\" title=\"PMS5003T \u5f15\u8173\u9806\u5e8f\"\/><figcaption class=\"wp-element-caption\">PMS5003T \u5f15\u8173\u9806\u5e8f<\/figcaption><\/figure>\n\n\n\n<p>\u4e0b\u8868\u8aaa\u660e\u4e86\u611f\u6e2c\u5668\u7684\u63a5\u8173\u8207\u529f\u80fd\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u63a5\u8173<\/th><th>\u540d\u7a31<\/th><th>\u529f\u80fd<\/th><\/tr><\/thead><tbody><tr><td>Pin1<\/td><td>VCC<\/td><td>\u96fb\u6e90\u6b63\u7aef<strong> 4.5 ~ 5.5V<\/strong><\/td><\/tr><tr><td>Pin2<\/td><td>GND<\/td><td>\u96fb\u6e90\u8ca0\u7aef<\/td><\/tr><tr><td>Pin3<\/td><td>SET<\/td><td>\u8a2d\u5b9a\u8173\u3002\u9ad8\u96fb\u4f4d\u6216\u7a7a\u63a5\u662f\u6b63\u5e38\u5de5\u4f5c\u72c0\u614b\uff1b\u4f4e\u96fb\u4f4d\u70ba\u4f11\u7720\u72c0\u614b\u3002<strong>TTL \u908f\u8f2f\u6e96\u4f4d3.3V<\/strong><\/td><\/tr><tr><td>Pin4<\/td><td>RXD<\/td><td>\u5e8f\u5217\u57e0\u63a5\u6536\u8173\u3002<strong>TTL \u908f\u8f2f\u6e96\u4f4d3.3V<\/strong><\/td><\/tr><tr><td>Pin5<\/td><td>TXD<\/td><td>\u5e8f\u5217\u57e0\u50b3\u9001\u8173\u3002<strong>TTL \u908f\u8f2f\u6e96\u4f4d3.3V<\/strong><\/td><\/tr><tr><td>Pin6<\/td><td>RESET<\/td><td>\u91cd\u7f6e\u63a5\u8173\uff0c\u4f4e\u96fb\u4f4d\u91cd\u7f6e\u3002<strong>TTL \u908f\u8f2f\u6e96\u4f4d3.3V<\/strong><\/td><\/tr><tr><td>Pin7<\/td><td>NC<\/td><td>\u7a7a\u63a5<\/td><\/tr><tr><td>Pin8<\/td><td>NC<\/td><td>\u7a7a\u63a5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\ud83d\udca1 <strong>Tips:<\/strong> \u6ce8\u610fPin1\u9700\u8981\u63a55V\uff0c\u5176\u4ed6\u901a\u8a0a\u8207\u63a7\u5236\u63a5\u8173(Pin3~Pin6)\u7684\u908f\u8f2f\u6e96\u4f4d\u90fd\u662f3.3V\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u50b3\u8f38\u5354\u8b70<\/h3>\n\n\n\n<p>\u5728\u9810\u8a2d\u7684\u4e3b\u52d5\u50b3\u8f38\u6a21\u5f0f\u4e0b\uff0cPMS5003T\u7684\u9b91\u7387\u70ba9600bps\uff0c8\u500b\u8cc7\u6599\u4f4d\u5143\uff0c\u7121\u6821\u9a57\u4f4d\u5143\uff0c1\u500b\u505c\u6b62\u4f4d\u5143\uff0c\u8cc7\u6599\u7e3d\u9577\u5ea632 bytes\u3002<\/p>\n\n\n\n<p>\u6839\u64da\u5b98\u65b9\u7684\u8cc7\u6599\u624b\u518a\uff08<a href=\"http:\/\/www.aqmd.gov\/docs\/default-source\/aq-spec\/resources-page\/plantower-pms5003-manual_v2-3.pdf?sfvrsn=2\">\u9023\u7d50<\/a>\uff09\uff0c\u4e3b\u52d5\u5f0f\u50b3\u8f38\u5354\u8b70\u7684\u8cc7\u6599\u5167\u5bb9\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/Untitled.png\" alt=\"PMS5003T\u4e3b\u52d5\u5f0f\u50b3\u8f38\u5354\u8b70\u7684\u5167\u5bb9\" class=\"wp-image-20767\" width=\"750\" height=\"636\" title=\"PMS5003T\u4e3b\u52d5\u5f0f\u50b3\u8f38\u5354\u8b70\u7684\u5167\u5bb9\"\/><figcaption class=\"wp-element-caption\">PMS5003T\u4e3b\u52d5\u5f0f\u50b3\u8f38\u5354\u8b70\u7684\u5167\u5bb9<\/figcaption><\/figure>\n\n\n\n<p>\u5be6\u969b\u5c07\u611f\u6e2c\u5668\u8cc7\u6599\u4ee516\u9032\u4f4d\u65b9\u5f0f\u8b80\u53d6\u51fa\u4f86\u5f8c\uff0c\u642d\u914d\u624b\u518a\u7684\u5167\u5bb9\uff0c\u6211\u5011\u5c31\u53ef\u4ee5\u77e5\u9053\u6bcf\u500b\u6b04\u4f4d\u8cc7\u6599\u6240\u4ee3\u8868\u7684\u610f\u7fa9\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/PMS5003T\u8cc7\u6599\u683c\u5f0fMade-by-Jessie.png\" alt=\"\u8a0a\u6846\u683c\u5f0f\u8207\u5be6\u969b\u8cc7\u6599\" class=\"wp-image-20768\" width=\"950\" height=\"329\"\/><figcaption class=\"wp-element-caption\">\u8a0a\u6846\u683c\u5f0f\u8207\u5be6\u969b\u8cc7\u6599<\/figcaption><\/figure>\n\n\n\n<p>\u4e0a\u9762\u9019\u6bb5\u8cc7\u6599\u6240\u50b3\u905e\u7684\u8a0a\u606f\u662f\uff1a<\/p>\n\n\n\n<ul>\n<li>PM1.0\u6fc3\u5ea6: 8 ug\/m^3<\/li>\n\n\n\n<li>PM2.5\u6fc3\u5ea6: 12 ug\/m^3<\/li>\n\n\n\n<li>PM10\u6fc3\u5ea6: 12 ug\/m^3<\/li>\n\n\n\n<li>\u6eab\u5ea6: 23 \u00b0C<\/li>\n\n\n\n<li>\u6fd5\u5ea6: 44 %<\/li>\n<\/ul>\n\n\n\n<p>\u73fe\u5728\u6211\u5011\u5df2\u7d93\u77e5\u9053\u611f\u6e2c\u5668\u6703\u50b3\u51fa\u4ec0\u9ebc\u5167\u5bb9\u4e86\uff0c\u63a5\u4e0b\u4f86\u5c31\u4f86\u770b\u770b\u600e\u9ebc\u7528ESP32\u8b80\u53d6\u9019\u4e9b\u8cc7\u6599\u5427\uff01<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b1: \u8b80\u53d6\u7a7a\u6c23\u4e2d\u7684\u61f8\u6d6e\u5fae\u7c92\u6fc3\u5ea6<\/h2>\n\n\n\n<p>PMS5003T\u9019\u9846PM2.5\u611f\u6e2c\u5668\u4f7f\u7528UART\u50b3\u8f38\u8cc7\u6599\uff0c\u6211\u5011\u5c07\u6703\u4f7f\u7528ESP32\u8b80\u53d6\u611f\u6e2c\u5668\u8cc7\u6599\uff0c\u5c07\u7d50\u679c\u986f\u793a\u5728Arduino IDE\u7684\u5e8f\u5217\u57e0\u76e3\u63a7\u8996\u7a97\u4e0a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6750\u6599\u6e05\u55ae<\/h3>\n\n\n\n<ul>\n<li><a href=\"https:\/\/www.icshop.com.tw\/products\/368030501867\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32\u958b\u767c\u677f<\/a> x1<\/li>\n\n\n\n<li><a href=\"https:\/\/www.icshop.com.tw\/products\/368070100145\" target=\"_blank\" rel=\"noreferrer noopener\">micro USB \u50b3\u8f38\u7dda<\/a> x1<\/li>\n\n\n\n<li><a href=\"https:\/\/www.icshop.com.tw\/products\/368090200053\" target=\"_blank\" rel=\"noreferrer noopener\">\u9eb5\u5305\u677f<\/a> x1<\/li>\n\n\n\n<li><a href=\"https:\/\/www.icshop.com.tw\/products\/368030200769\" target=\"_blank\" rel=\"noreferrer noopener\">PMS5003T \u611f\u6e2c\u5668<\/a> x1<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5143\u4ef6\u9023\u63a5\u793a\u610f\u5716<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/Untitled-1.png\" alt=\"\u7dda\u8def\u9023\u63a5\u5716\" class=\"wp-image-20769\" width=\"869\" height=\"600\" title=\"\u7dda\u8def\u9023\u63a5\u5716\"\/><figcaption class=\"wp-element-caption\">\u7dda\u8def\u9023\u63a5\u5716<\/figcaption><\/figure>\n\n\n\n<p>\ud83d\udca1 <strong>Tips:<\/strong> \u9023\u63a5\u6642\u8981\u6ce8\u610f\u611f\u6e2c\u5668\u8207\u958b\u767c\u677f\u7684TX\u3001RX\u8173\u4f4d\u9023\u63a5\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88dd\u51fd\u5f0f\u5eab<\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u5011\u5148\u5b89\u88dd<a href=\"https:\/\/github.com\/fu-hsi\/PMS\" target=\"_blank\" rel=\"noreferrer noopener\">PMS Library<\/a>\u9019\u500b\u51fd\u5f0f\u5eab\uff0c\u5b83\u652f\u63f4\u6500\u85e4\u79d1\u6280\u5176\u4ed6\u578b\u865f\u7684PM2.5\u611f\u6e2c\u5668\uff0c\u800c\u4e14\u5df2\u7d93\u5e6b\u6211\u5011\u5beb\u597d\u4e86\u63a5\u6536\u611f\u6e2c\u5668\u8cc7\u6599\u7684\u7a0b\u5f0f\uff0c\u4f7f\u7528\u8d77\u4f86\u76f8\u7576\u65b9\u4fbf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\" id=\"\u5b89\u88dd-PMS-Library\"><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"402\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/Untitled-2.png\" alt=\"\u5b89\u88dd PMS Library\" class=\"wp-image-20770\"\/><figcaption class=\"wp-element-caption\">\u5b89\u88dd PMS Library<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a0b\u5f0f\u78bc<\/h3>\n\n\n\n<script src=\"https:\/\/gist.github.com\/FelixLinSY\/c497d86c9bc1d3e2581b615c344617c4.js\"><\/script>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8aaa\u660e<\/h3>\n\n\n\n<p>\u5728\u9019\u500b\u7a0b\u5f0f\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u4e86Serial (UART0) \u8207 Serial2 (UART2)\u3002Serial\u7528\u4f86\u8207\u96fb\u8166\u901a\u8a0a\uff0cSerial2\u7528\u4f86\u9023\u63a5\u611f\u6e2c\u5668\u3002\u7576\u611f\u6e2c\u5668\u50b3\u4f86\u8cc7\u6599\u6642\uff0c<a href=\"https:\/\/www.circuspi.com\/index.php\/2023\/08\/24\/esp32-arduino-ide-2-x\/\" target=\"_blank\" rel=\"noreferrer noopener\">Arduino IDE<\/a>\u7684\u5e8f\u5217\u57e0\u76e3\u63a7\u8996\u7a97\u5c31\u6703\u8f38\u51faPM1.0\u3001PM2.5\u8207PM10.0\u7684\u6578\u503c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u57f7\u884c\u7d50\u679c<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/Untitled-3.png\" alt=\"\u8f38\u51fa\u7d50\u679c\" class=\"wp-image-20771\" width=\"540\" height=\"291\" title=\"\u8f38\u51fa\u7d50\u679c\"\/><figcaption class=\"wp-element-caption\">\u8f38\u51fa\u7d50\u679c<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b2: \u8b80\u53d6\u6eab\u6ebc\u5ea6\u8207PM2.5\u6578\u503c<\/h2>\n\n\n\n<p>PMS Library\u6700\u5927\u7684\u7f3a\u9ede\u662f\u53ea\u80fd\u8b80\u53d6\u61f8\u6d6e\u5fae\u7c92\uff0c\u4f46\u6709\u71b1\u5fc3\u7684\u7db2\u53cb\u5e6b\u5fd9\u64f4\u5145\u4e86\u6eab\u6ebc\u5ea6\u8b80\u53d6\u7684\u529f\u80fd\uff0c\u6211\u5011\u53ea\u9700\u8981\u627e\u51fa\u51fd\u5f0f\u5eab\u5167\u5bb9\u4e26\u4e14\u4fee\u6539\u4e00\u4e0b\u5c31\u53ef\u4ee5\u8b80\u53d6\u76ee\u524d\u7684\u6eab\u6ebc\u5ea6\u6578\u503c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5143\u4ef6\u9023\u63a5\u793a\u610f\u5716<\/h3>\n\n\n\n<p>\u786c\u9ad4\u63a5\u7dda\u8207\u7bc4\u4f8b1\u76f8\u540c\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u91cd\u65b0\u9023\u63a5\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4fee\u6539\u51fd\u5f0f\u5eab<\/h3>\n\n\n\n<p>\u63a5\u4e0b\u4f86\u6211\u5011\u8981\u627e\u51faPMS Library\u6240\u5728\u7684\u4f4d\u7f6e\uff0c\u6bcf\u53f0\u96fb\u8166\u7684\u5b89\u88dd\u8def\u5f91\u53ef\u80fd\u6703\u7565\u6709\u4e0d\u540c\uff0c\u9810\u8a2d\u5b89\u88dd\u7684\u4f4d\u7f6e\u6703\u5728 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span data-token-index=\"0\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">C:\\Users\\USER\\Documents\\Arduino\\libraries\\PMS_Library\\src<\/span><\/code><\/pre>\n\n\n\n<p>\u9032\u5165\u5230src\u8cc7\u6599\u593e\u5f8c\uff0c\u61c9\u8a72\u6703\u770b\u5230PMS.cpp\u8207PMS.h\u9019\u5169\u500b\u6a94\u6848<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/Untitled-4.png\" alt=\"PMS Library \u6a94\u6848\" class=\"wp-image-20773\" width=\"449\" height=\"223\" title=\"PMS Library \u6a94\u6848\"\/><figcaption class=\"wp-element-caption\">PMS Library \u6a94\u6848<\/figcaption><\/figure>\n\n\n\n<p>\u7167\u8457<a href=\"https:\/\/www.airgradient.com\/blog\/patching-pms-library-for-plantower-pms5003t\/\">\u9019\u500b<\/a>\u7db2\u7ad9\u63d0\u4f9b\u7684\u7a0b\u5f0f\u4fee\u6539\u51fd\u5f0f\u5eab\u7684\u6a94\u6848\u5167\u5bb9\u5f8c\uff0c\u63a5\u4e0b\u4f86\u6211\u5011\u5c31\u53ef\u4ee5\u8b80\u53d6PM2.5\u4ee5\u53ca\u6eab\u6ebc\u5ea6\u8cc7\u6599\u4e86\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a0b\u5f0f\u78bc<\/h3>\n\n\n\n<script src=\"https:\/\/gist.github.com\/FelixLinSY\/5ebd6fb62c328a7bf7655b8fd0f23a30.js\"><\/script>\n\n\n\n<h3 class=\"wp-block-heading\">\u8aaa\u660e<\/h3>\n\n\n\n<p>\u7531\u65bcPMS\u7cfb\u5217\u7684\u611f\u6e2c\u5668\u4e0d\u662f\u6bcf\u4e00\u6b3e\u90fd\u6709\u6eab\u6ebc\u5ea6\u7684\u529f\u80fd\uff0c\u539f\u59cb\u7684\u51fd\u5f0f\u5eab\u88e1\u9762\u53ea\u8b80\u53d6\u4e86\u7a7a\u6c23\u5fae\u7c92\u7684\u8cc7\u6599\uff0c\u800c\u4fee\u6539\u5f8c\u7684\u51fd\u5f0f\u5eab\u5247\u662f\u5e6b\u6211\u5011\u628a\u8a0a\u606f\u4e32\u5f8c\u9762\u7684\u6eab\u6ebc\u5ea6\u6578\u503c\u4e5f\u4e00\u8d77\u8b80\u51fa\u4f86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u57f7\u884c\u7d50\u679c<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/11\/Untitled-5.png\" alt=\"\u61f8\u6d6e\u5fae\u7c92\u8207\u6eab\u6fd5\u5ea6\u7684\u611f\u6e2c\u8f38\u51fa\" class=\"wp-image-20774\" width=\"419\" height=\"272\" title=\"\u61f8\u6d6e\u5fae\u7c92\u8207\u6eab\u6fd5\u5ea6\u7684\u611f\u6e2c\u8f38\u51fa\"\/><figcaption class=\"wp-element-caption\">\u61f8\u6d6e\u5fae\u7c92\u8207\u6eab\u6fd5\u5ea6\u7684\u611f\u6e2c\u8f38\u51fa<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c0f\u7d50<\/h3>\n\n\n\n<p>\u7531\u65bcESP32\u7684GPIO\u6709\u63a5\u8173\u591a\u5de5\uff08pin multiplexing\uff09\u7684\u529f\u80fd\uff0c\u5728\u4f7f\u7528UART\u7684\u6642\u5019\u9664\u4e86\u53ef\u4ee5\u7528\u9810\u8a2d\u7684TX\u8207RX\u63a5\u8173\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528HardwareSerial\u51fd\u5f0f\u5eab\u91cd\u65b0\u6620\u5c04\u5230\u5176\u4ed6\u63a5\u8173\uff0c\u6700\u591a\u53ef\u4ee5\u7528\u52303\u7d44UART\u3002\u552f\u4e00\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e26\u4e0d\u662f\u6240\u6709\u7684GPIO\u63a5\u8173\u90fd\u80fd\u4f7f\u7528\uff08\u5177\u9ad4\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u63a5\u8173\u8acb\u53c3\u8003 <strong><a href=\"https:\/\/www.circuspi.com\/index.php\/2023\/08\/30\/esp32-gpio-1\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32\u6559\u5b78\u7cfb\u5217(\u4e09)\uff1a\u6578\u4f4d\u8f38\u5165\u8207\u8f38\u51fa(\u4e0a)<\/a><\/strong>\uff09\uff0c\u5728\u6620\u5c04\u6642\u9700\u8981\u591a\u52a0\u7559\u610f\u3002\u6211\u5011\u4e5f\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\u5be6\u969b\u89e3\u6790<a href=\"https:\/\/www.icshop.com.tw\/products\/368030200769\" target=\"_blank\" rel=\"noreferrer noopener\">PMS5003T<\/a>\u9019\u9846PM2.5\u611f\u6e2c\u5668\u7684\u7528\u6cd5\u8207\u8f38\u51fa\u7684\u8cc7\u6599\u5167\u5bb9\uff0c\u4e26\u4e14\u4ee5ESP32\u7684UART\u8b80\u53d6\u611f\u6e2c\u5668\u8cc7\u6599\uff0c\u5c07\u8cc7\u6599\u986f\u793a\u5728\u5e8f\u5217\u57e0\u76e3\u63a7\u8996\u7a97\u3002\u4e0b\u4e00\u7bc7\u6587\u7ae0\u5c07\u6703\u8ac7\u4e00\u8ac7SPI\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u63a5\u4e0b\u4f86\u7684\u5e7e\u7bc7\u6587\u7ae0\u6703\u9678\u7e8c\u4ecb\u7d39\u5fae\u63a7\u5236\u5668\u5e38\u7528\u7684\u4ecb\u9762\uff0c\u9019\u7bc7\u6211\u5011\u5c07\u4f7f\u7528\u6500\u85e4\u79d1\u6280\u63a8\u51fa\u7684\u7684PMS5003T PM2.5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":20801,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[235,238],"tags":[],"table_tags":[],"_links":{"self":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/20761"}],"collection":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/comments?post=20761"}],"version-history":[{"count":6,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/20761\/revisions"}],"predecessor-version":[{"id":20805,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/20761\/revisions\/20805"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/media\/20801"}],"wp:attachment":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/media?parent=20761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/categories?post=20761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/tags?post=20761"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/table_tags?post=20761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}