{"id":12030,"date":"2021-08-26T02:55:00","date_gmt":"2021-08-25T18:55:00","guid":{"rendered":"http:\/\/222.73.203.234:9999\/?p=12030"},"modified":"2022-11-24T17:18:04","modified_gmt":"2022-11-24T09:18:04","slug":"%e8%b5%b0%e8%bf%9b%e7%89%a9%e8%81%94%e7%bd%91%ef%bc%9a%e5%88%b6%e5%a4%87%e6%82%a8%e8%87%aa%e5%b7%b1%e7%9a%84wi-fi%e5%bc%80%e5%85%b3-%ef%bc%81-2","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/12030","title":{"rendered":"\u8d70\u8fdb\u7269\u8054\u7f51\uff1a\u5236\u5907\u60a8\u81ea\u5df1\u7684Wi-Fi\u5f00\u5173 \uff01"},"content":{"rendered":"<div class=\"\u201cthe_content_wrapper\u201d\">\n<p>\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e<a href=\"https:\/\/www.deviceplus.com\/\">DevicePlus.com<\/a>\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002<\/p>\n<div id=\"attachment_8675\" class=\"wp-caption aligncenter\" style=\"width: 640px;\">\n<p><img decoding=\"async\" class=\"size-full wp-image-8675\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/Internet-of-Things-DIY.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/Internet-of-Things-DIY.jpg 732w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/Internet-of-Things-DIY-300x191.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/Internet-of-Things-DIY-230x146.jpg 230w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/Internet-of-Things-DIY-50x32.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/Internet-of-Things-DIY-118x75.jpg 118w\" alt=\"Internet of Things DIY\" width=\"640\" aria-describedby=\"caption-attachment-8675\" \/><\/p>\n<p id=\"caption-attachment-8675\" class=\"wp-caption-text\">Tierney \u2013 stock.adobe.com<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u76ee\u5f55<br \/>\n<\/strong><strong>1. \u7b80\u4ecb<br \/>\n<\/strong><strong>2. \u5927\u81f4\u89c4\u683c<br \/>\n<\/strong><strong>3. ESP32 \u786c\u4ef6\u6982\u8ff0<br \/>\n<\/strong><strong>4. \u5c06\u56fa\u4ef6\u52a0\u8f7d\u5230 ESP32<br \/>\n<\/strong><strong>5. \u8fd0\u884c\uff01!<br \/>\n<\/strong><strong>6. \u9009\u62e9\u60a8\u81ea\u5df1\u7684\u96c6\u7ebf\u5668\uff1a\u4e3b\u673a\u5373\u4e3aHeart.local\u6240\u5728\u7684\u4f4d\u7f6e<br \/>\n<\/strong><strong>7. \u6784\u5efaWi-Fi \u5f00\u5173<br \/>\n<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h2>1 \u7b80\u4ecb<\/h2>\n<p>\u7269\u8054\u7f51\u6280\u672f\u5df2\u7ecf\u6df1\u5165\u5230\u4e86\u5927\u4f17\u751f\u6d3b\u4e2d\u3002\u5b87\u5b99\u5927\u7206\u70b8\u5e26\u6765\u4e86\u4e16\u95f4\u6240\u6709\u5b58\u5728\u7684\u4e8b\u7269\uff0c\u4f46\u662f\u4ee5\u667a\u80fd\u65b9\u5f0f\u5c06\u5b83\u4eec\u8fde\u63a5\u8d77\u6765\uff0c\u4f7f\u5176\u5728\u53d1\u751f\u76f8\u4e92\u5173\u8054\u7684\u540c\u65f6\u53d1\u6325\u51fa\u4f5c\u7528\uff0c\u662f\u6700\u8fd1\u624d\u53d6\u5f97\u7684\u8fdb\u5c55\u3002\u51e0\u6b21\u96f7\u51fb\u540e\uff0c\u7ec6\u80de\u5728\u5730\u7403\u6d77\u6d0b\u7684\u539f\u59cb\u6ce5\u6d46\u4e2d\u505a\u5230\u4e86\u8fd9\u4e00\u70b9\uff0c\u6c28\u57fa\u9178\u4e3a\u7b2c\u4e00\u4e2a\u7ec6\u80de\u7684\u5f62\u6210\u6784\u6210\u4e86\u7269\u8d28\u57fa\u7840\u3002\u7136\u540e\u5c31\u5f00\u59cb\u4e0e\u5176\u4ed6\u4e07\u7269\u5408\u4f5c\u5171\u8d62\u4e86\u5417\uff1f\u4e0d\uff0c\u5b8c\u5168\u4e0d\u662f\u3002\u7ec6\u80de\u7f3a\u4e4f\u66f4\u9ad8\u7684\u667a\u6167\uff0c\u5b83\u4eec\u53ea\u60f3\u5728\u65e0\u5c3d\u7684\u53d8\u5f02\u8fed\u4ee3\u4e2d\u5ef6\u7eed\u81ea\u5df1\u7684\u751f\u547d\u3002\u5c31\u8fd9\u6837\uff0c\u9010\u6e10\u8fdb\u5316\u6210\u4e86\u4eba\u7c7b\uff0c\u624d\u6709\u4e86\u73b0\u5728\u6b63\u5728\u9605\u8bfb\u6709\u5173\u7269\u8054\u7f51\u6587\u7ae0\u7684\u60a8\u3002<br \/>\n\u7269\u8054\u7f51\u7684\u53d1\u5c55\u4e00\u5b9a\u662f\u4ee5\u4e00\u4e2a\u660e\u786e\u7684\u76ee\u6807\u5f00\u5c55\u7684\uff0c\u5e76\u4e14\u5728\u8bbe\u8ba1\u65f6\u4f1a\u8003\u8651\u672a\u6765\u4ea7\u54c1\u7684\u8fed\u4ee3\u3002\u5f53\u7136\uff0c\u60a8\u6ca1\u6709\u529e\u6cd5\u6c38\u751f\uff0c\u53ea\u80fd\u63d0\u51fa\u4e00\u4e2a\u60f3\u6cd5\uff0c\u7136\u540e\u4e5f\u8bb8\u7528\u51e0\u4e2a\u6708\u7684\u65f6\u95f4\u6765\u8bbe\u8ba1\u51fa\u539f\u578b\u3002\u63a5\u4e0b\u6765\uff0c\u5c31\u662fPCB\u8bbe\u8ba1\u4e86\u3002\u8fd9\u6837\u8bf4\u4e5f\u8bb8\u60a8\u4f1a\u611f\u5230\u559c\u60a6\uff1a\u6bcf\u4e00\u4e2a\u4eba\u90fd\u4e3a\u7269\u8054\u7f51\u7684\u53d1\u5c55\u4f5c\u51fa\u4e86\u8d21\u732e\uff0c\u5c31\u50cf\u9ece\u660e\u524d\u4e00\u4e2a\u7ec6\u80de\u52a0\u5165\u4e86\u53e6\u4e00\u4e2a\u7ec6\u80de\u90a3\u6837\uff0c\u603b\u6709\u4e00\u5929\u4f1a\u8fce\u6765\u4eba\u5de5\u667a\u80fd\u7684\u5168\u9762\u5f00\u82b1\uff0c\u800c\u4eba\u5de5\u667a\u80fd\u4e5f\u8bb8\u4f1a\u5728\u672a\u6765\u9009\u62e9\u6d88\u706d\u4eba\u7c7b\uff0c\u4e5f\u53ef\u80fd\u4e0d\u4f1a\u3002\u4eba\u5de5\u667a\u80fd\u662f\u57fa\u4e8e\u4e8c\u8fdb\u5236\u8ba1\u7b97\u7684\u3002\u90a3\u4e48\u6211\u4eec\u7ee7\u7eed\uff01<br \/>\n\u5728\u672c\u6587\u4e2d\uff0c\u60a8\u5c06\u4f1a\u5b66\u4e60\u5982\u4f55\u4f7f\u7528MicroPython\u548cESP32\u6765\u5236\u4f5c\u4e00\u4e2a\u53ef\u7528\u4e8e\u7269\u8054\u7f51\u9879\u76ee\u7684Wi-Fi\u5f00\u5173\u3002<\/p>\n<h2>2 \u5927\u81f4\u89c4\u683c<\/h2>\n<p>\u6211\u9700\u8981\u4e00\u4e2a\u672c\u5730\u7269\u8054\u7f51Wi-Fi\u5f00\u5173\uff0c\u7528\u4e8e\u4e24\u4e2a230V\u4ea4\u6d41\u8d1f\u8f7d\uff0c\u6bcf\u4e2a\u8d1f\u8f7d\u9ad8\u8fbe500-600W\u3002\u8be5\u5f00\u5173\u9700\u8981\u6613\u4e8e\u66f4\u6539\uff08\u5728\u4ee3\u7801\u4e2d\uff09\uff0c\u9700\u8981\u53ef\u4ee5\u5b89\u88c5\u5728\u5bb6\u91cc\u7684\u4efb\u4f55\u5730\u65b9\uff0c\u5e76\u4e14\u5728\u786c\u4ef6\u65b9\u9762\uff0c\u53ef\u4ee5\u5feb\u901f\u8fdb\u884c\u4fee\u6539\u548c\u6269\u5c55\u3002\u8fd9\u610f\u5473\u7740\u6211\u5fc5\u987b\u4f7f\u7528MicroPython\uff0c\u4ee5\u53ca\u4e00\u4e2aESP32\u5f00\u53d1\u677f\uff01\u5b83\u7684\u5f15\u811a\u53ef\u4ee5\u63d0\u4f9b\u7ea610mA\u7684\u7535\u6d41\uff0c\u5e76\u4e14\u53ea\u9700\u8981\u4e32\u8054\u4e00\u4e2a330\u6b27\u59c6\u7684\u7535\u963b\u5668\u5c31\u53ef\u4ee5\u5bf9\u5176\u8fdb\u884c\u4fdd\u62a4\u3002\u6240\u6709\u7684\u8f93\u51fa\u7535\u538b\u90fd\u4e3a3.3V\uff0c\u5bf9\u4e8e\u73b0\u5982\u4eca\u7684MOSFET\u6765\u8bf4\u5f88\u5b8c\u7f8e\uff0c\u751a\u81f3\u53ef\u4ee5\u9a71\u52a8\u66f4\u9ad8\u7535\u538b\u7684\u8d1f\u8f7d\u3002\u53ea\u8981\u60a8\u786e\u4fdd\u4f7f\u7528\u903b\u8f91\u7535\u5e73MOSFET\u3002WiFi\u4f20\u8f93\u901f\u5ea6\u7ea6\u4e3a150Mbit\/s\uff0818.75MByte\/s\uff09\uff0c\u5e76\u4e14\u4f7f\u7528Loboris\u7684ESP32\u56fa\u4ef6\uff08\u53ef\u5728<a href=\"https:\/\/github.com\/loboris\/MicroPython_ESP32_psRAM_LoBo\/wiki\/firmwares\">\u6b64\u5904<\/a>\u83b7\u53d6\uff09\u53ef\u4ee5\u8282\u7701\u66f4\u591a\u65f6\u95f4\uff0c\u56e0\u4e3a\u5b83\u5df2\u7ecf\u5305\u542b\u4e86\u7528\u4e8emDNS\u7684\u5e93\u4ee5\u53ca\u6240\u6709\u5176\u4ed6\u6240\u9700\u5185\u5bb9\u4e86\u3002<br \/>\nmDNS\u53ef\u4ee5\u4f7f\u60a8\u7684ESP32\u5728\u7f51\u7edc\u4e0a\u88ab\u53d1\u73b0\uff08\u5bf9\u4e8eWireshark\u7231\u597d\u8005\uff0c\u53ef\u4ee5\u591a\u64ad\u5230224.0.0.251\uff09\uff0c\u5e76\u8ba9\u60a8\u544a\u8bc9\u5176\u4ed6\u4f7f\u7528\u8005\u6bcf\u4e2a\u8bbe\u5907\u63d0\u4f9b\u4e86\u54ea\u4e9b\u670d\u52a1\u3002\u5b83\u7684\u7cfb\u7edf\u4e0e\u63d0\u4f9b\u6d41\u5a92\u4f53\u7684\u5a92\u4f53\u4e2d\u5fc3\u548cChromecasts\u7684\u7cfb\u7edf\u76f8\u540c\u3002\u6211\u4f7f\u7528\u5b83\u6765\u627e\u5230\u6211\u7684Raspberry Pi\u96c6\u7ebf\u5668\uff08HEART.local\uff09\uff0c\u5e76\u4e14\u53ea\u63a5\u53d7\u6765\u81ea\u8be5\u96c6\u7ebf\u5668\u7684\u6307\u4ee4\u3002<br \/>\n\u5f53\u4f7f\u7528USB TTL\u9002\u914d\u5668\u8fde\u63a5\u5230\u60a8\u7684ESP32\u7684UART\u65f6\uff0c\u60a8\u53ef\u4ee5\u968f\u65f6\u4f7f\u7528CTRL+C\u8df3\u51fa\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f\uff0c\u7136\u540e\u67e5\u770b\u53d8\u91cf\uff0c\u8c03\u6574\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff08micropython.meminfo(1), esp.freemem()\uff09\uff0c\u91ca\u653e\u5185\u5b58\uff08gc.enable(), gc.collect()\uff09\uff0c\u8fdb\u5165\u7c98\u8d34\u6a21\u5f0f\uff08CTRL+E\uff0cpaste\uff0c CTRL+D\uff09\uff0c\u4ece\u800c\u4e86\u89e3\u4e00\u4e2a\u60f3\u6cd5\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u3002<br \/>\n\u60f3\u8981\u5728Linux\u3001Windows\u3001 \u4ee5\u53caMacOS X\u4e0a\u4f7f\u7528\u56fe\u5f62\u754c\u9762\uff0c\u53ef\u4ee5\u4f7f\u7528ampy\uff08\u201campy \u2013port COM4 \u2013put boot.py\u201d\uff09\u3001mpfshell\uff08mpfshell -o ttyUSB0 -nc \u201cput boot.py ; put main.py\u201d\uff09\u6216\u7b80\u5355\u7684ESPlorer\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u60a8\u4e0d\u5355\u5355\u53ea\u4f7f\u7528WebREPL\uff08( \u2018import webrepl\u2019, \u2018webrepl.start()\u2019\uff09\u6765\u5b9e\u73b0\u4e0a\u4f20\/\u4e0b\u8f7d\u4ee3\u7801\u4ee5\u53ca\u67e5\u770b\u4ee3\u7801\u8fd0\u884c\u7ed3\u679c\u7684\u8bdd\uff0c\u4f1a\u9700\u8981\u8fd9\u4e9b\u7a0b\u5e8f\u5305\u3002\u4e3a\u7b80\u5355\u8d77\u89c1\uff0c\u60a8\u53ef\u4ee5\u8fdb\u884c\u641c\u7d22\u76f8\u5173\u4fe1\u606f\uff0c\u7136\u540e\u5c06MicroPython\u677f\u8fde\u63a5\u5230\u60a8\u7684\u7f51\u7edc\u4e0a\u3002<\/p>\n<h2>3 ESP32 \u786c\u4ef6\u6982\u8ff0<\/h2>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-8676\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram-300x169.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram-768x434.jpg 768w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram-260x146.jpg 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram-50x28.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-ESP32_diagram-133x75.jpg 133w\" alt=\"ESP32 diagram\" width=\"640px\" \/><br \/>\n<strong>ESP32 \u89c4\u683c<\/strong><\/p>\n<ul style=\"font-size: 13px; line-height: 1.4em;\">\n<li>CPU \u53cc\u6838@ 160\/240MHz\uff0cXtensa(R) 32\u4f4d LX6 \u5fae\u5904\u7406\u5668<\/li>\n<li>\u6027\u80fd\uff1a &lt;=600 DMIPS<\/li>\n<li>\u82af\u7247 ESP32D0WDQ6 \uff08\u7248\u672c1\uff09<\/li>\n<li>Wi-Fi\uff1a802.11\/b\/g\/n\/e\/i \u2013 802.11n @ 2.4GHz \u9ad8\u8fbe150Mbit\/s<\/li>\n<li>\u84dd\u7259<\/li>\n<li>RAM\uff1a\n<ul style=\"font-size: 13px; line-height: 1.4em;\">\n<li>448KB ROM \u7528\u4e8e\u542f\u52a8\u53ca\u6838\u5fc3\u529f\u80fd<\/li>\n<li>520KB \u7247\u4e0aSRAM \u7528\u4e8e\u6570\u636e\u53ca\u6307\u4ee4<\/li>\n<li>RTC\uff08RTC FAST MEMORY\uff09\u4e2d\u76848KB SRAM\u7528\u4e8e\u4ece\u6df1\u5ea6\u7761\u7720\u6a21\u5f0f\u4e2d\u6062\u590d<\/li>\n<li>RTC\uff08RTC SLOW MEMORY\uff09\u4e2d\u76848KB SRAM\u7528\u4e8e\u6df1\u5ea6\u7761\u7720\u6a21\u5f0f\u4e0b\u7684\u534f\u540c\u5904\u7406<\/li>\n<li>1Kbit eFuse\uff08256\u4f4d\u7528\u4e8e\u7cfb\u7edf\uff08MAC\u548c\u82af\u7247\u914d\u7f6e\uff09\uff09\uff0c768\u4f4d\u7528\u4e8e\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u3001\u95ea\u5b58\u52a0\u5bc6\u4ee5\u53ca\u82af\u7247ID<\/li>\n<li>40MHz\u6676\u632f\uff0c\u53ef\u8f93\u51fa40MHz PWM<\/li>\n<li>\u53ef\u7528SPIRAM\u8fdb\u884c\u6269\u5f20\uff01\u6700\u591a4\u4e2a16MB\u5916\u7f6eQSPI \u95ea\u5b58\/SRAM\u82af\u7247\uff0c\u6700\u591a8MB\u6620\u5c04\u5230CPU\u6570\u636e\u7a7a\u95f4\u7684\u5916\u7f6e\u95ea\u5b58\/SRAM\uff0c\u652f\u6301\u5b58\u53d68\u4f4d\u300116\u4f4d\u300132\u4f4d\u6570\u636e\u3002\u8be5SRAM\u53ef\u4ee5\u5199\u5165\uff1a\n<ul style=\"font-size: 13px; line-height: 1.4em;\">\n<li>\u95ea\u5b58\uff1a 4MB SPI \u95ea\u5b58\uff08\u5728GPIO6\u3001 GPIO7\u3001GPIO8\u3001GPIO9\u3001GPIO10\u4e0a\uff09<\/li>\n<li>\u5b89\u5168\u6027\uff1a IEEE 802.11 \u6807\u51c6\u5b89\u5168\u673a\u5236\uff1a\n<ul style=\"font-size: 13px; line-height: 1.4em;\">\n<li>WPA\/WPA2\/WAPI<\/li>\n<li>\u5b89\u5168\u542f\u52a8<\/li>\n<\/ul>\n<\/li>\n<li>\u95ea\u5b58\u52a0\u5bc6<\/li>\n<li>1024\u4f4dOTP\uff0c\u6700\u7ec8\u7528\u6237\u53ef\u8fbe768\u4f4d<\/li>\n<li>AES\uff0cSHA-2\uff0cRSA\uff0c\u692d\u5706\u66f2\u7ebf\u52a0\u5bc6\uff08ECC\uff09\uff0c\u968f\u673a\u6570\u751f\u6210\uff08RNG\uff09\u7684\u52a0\u5bc6\u786c\u4ef6\u52a0\u901f<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong><a href=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/esp32_datasheet_en.pdf\">ESP32 \u6570\u636e\u8868<\/a><\/strong><br \/>\n\u53cc\u6838CPU\u548c520KB RAM\u76f8\u5bf9\u4e8e\u60a8\u53ef\u80fd\u5df2\u7ecf\u4e60\u60ef\u4f7f\u7528\u7684Arduino atmega328p \uff08\u4f8b\u5982Uno\uff09\u768416MHz\u548c2KB SRAM\u6709\u4e86\u8d28\u7684\u63d0\u5347\uff0c\u53ef\u4ee5\u4e3a\u60a8\u63d0\u4f9b\u8db3\u591f\u7684\u901f\u5ea6\u548c\u7a7a\u95f4\u6765\u5f00\u53d1\u66f4\u9ad8\u590d\u6742\u7a0b\u5ea6\u7684\u7269\u8054\u7f51\u7cfb\u7edf\u3002\u76f8\u6bd4\u4e8e\u5b83\u7684\u80fd\u529b\u8303\u56f4\uff0c\u6211\u7684Wi-Fi\u5f00\u5173\u53ea\u4f7f\u7528\u4e86\u5176\u4e2d\u5f88\u5c11\u7684\u529f\u80fd\u3002\u4f46\u662f\uff0c\u6211\u5728ESP32\u7684\u4e24\u4fa7\u90fd\u6dfb\u52a0\u4e86\u5f15\u811a\u516c\u5934\uff0c\u4e4b\u540e\u53ef\u4ee5\u968f\u65f6\u4e3a\u6211\u6784\u5efa\u7684\u4ea7\u54c1\u6dfb\u52a0\u66f4\u591a\u7684\u529f\u80fd\u3002<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-8677\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-bat86.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-bat86.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-bat86-300x225.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-bat86-195x146.jpg 195w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-bat86-50x38.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-bat86-100x75.jpg 100w\" alt=\"ESP32 Wi-Fi Switch\" width=\"640\" \/><br \/>\n<a href=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/wifiswitch.zip\">wifiswitch.zip<\/a><\/p>\n<h2>4 \u5c06\u56fa\u4ef6\u52a0\u8f7d\u5230 ESP32<\/h2>\n<p>\u60a8\u53ea\u9700\u8981<a href=\"https:\/\/github.com\/espressif\/esptool\">esptool<\/a>\u5373\u53ef\u4e0a\u4f20Loboris MicroPython\u3002\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u8bf7\u76f4\u63a5\u4f7f\u7528\u6211\u7684\u811a\u672c\uff1a<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>\r\n[begin flash_lobo_esp32_all.sh]\r\n# Enable flashing by holding the button to the right of\r\n# microUSB port when powering ESP32 on\r\n_baudrate=230400\r\n_port=\/dev\/ttyUSB0\r\nesptool.py --chip esp32 --before no_reset --after no_reset \\\r\n--baud $_baudrate --port $_port erase_flash\r\nesptool.py --chip esp32 --port $_port --baud $_baudrate \\\r\n--before no_reset --after no_reset write_flash -z \\\r\n--flash_mode dio --flash_freq 40m --flash_size detect 0x1000 \\\r\nbootloader\/bootloader.bin 0xf000 phy_init_data.bin \\\r\n0x10000 MicroPython.bin 0x8000 partitions_mpy.bin\r\n[end flash_lobo_esp32_all.sh]\r\n<\/code><\/pre>\n<\/div>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u8fde\u63a5\uff0c\u60a8\u53ef\u4ee5\u5728Windows\u3001 Linux\u3001\u4ee5\u53caMacOS\u4e0a\u4f7f\u7528\u7ec8\u7aef\u6307\u4ee4\u201cpython3 -m serial.tools.miniterm\u201d\u3002Miniterm\u53ef\u4ee5\u4e0epython3-serial\u6a21\u5757\u4e00\u8d77\u5b89\u88c5\uff0c\u6216\u8005\u53ef\u4ee5\u76f4\u63a5\u4e0b\u8f7dputty\u8f6f\u4ef6\u6765\u7b80\u5316\u60a8\u7684\u8fc7\u7a0b\u3002\u6839\u636e\u60a8\u4f7f\u7528\u7684Windows\uff0c Linux\uff0c\u4ee5\u53caMacOS\u7cfb\u7edf\uff0c\u7aef\u53e3\u5c06\u4f1a\u9075\u5faa\u4e0d\u540c\u7684\u547d\u540d\u60ef\u4f8b\u3002\u8fd9\u4e24\u4e2a\u7a0b\u5e8f\u90fd\u4f1a\u8981\u6c42\u60a8\u8f93\u5165\u60f3\u8981\u8fde\u63a5\u7684\u7aef\u53e3\u4ee5\u53ca\u6ce2\u7279\u7387\u3002\u5bf9\u4e8eMicroPython\uff0c\u4f7f\u7528115200\u3002\u9700\u8981\u8fde\u63a5\u7684\u7aef\u53e3\u5728Windows\u7cfb\u7edf\u4e0a\u4f1a\u6709\u6240\u4e0d\u540c\uff08\u63d2\u5165\u8bbe\u5907\u65f6\u5728\u8bbe\u5907\u7ba1\u7406\u5668\u4e2d\u67e5\u627eCOM#\u7aef\u53e3\u53d8\u5316\uff09\uff0c\u800c\u5728Linux\u6216\u5176\u4ed6\u7c7b\u4f3c\u7684\u7cfb\u7edf\u4e2d\uff0c\u901a\u5e38\u5bf9\u4e8e\u7b2c\u4e00\u4e2a\u8fde\u63a5\u7684USB\u4e32\u884c\u9002\u914d\u5668\u4e3a\u201c\/dev\/ttyUSB0\u201d\uff0c\u7b2c\u4e8c\u4e2a\u4e3a\u201c\/dev\/ttyUSB1\u201d\u7b49\u7b49\u3002<br \/>\nMicroPython\u7684\u6613\u7528\u6027\u548c\u7075\u6d3b\u6027\u4f7f\u60a8\u4e0d\u4f1a\u88ab\u4ee3\u7801\u56f0\u6270\uff0c\u4ece\u800c\u80fd\u6709\u66f4\u591a\u7684\u65f6\u95f4\u6295\u5165\u5230\u7535\u5b50\u4ea7\u54c1\u7684\u5f00\u53d1\u4e2d\u3002<\/p>\n<h2>5 \u8fd0\u884c\uff01<\/h2>\n<p>\u60a8\u7684ESP32\u5728MicroPython\u4e0a\u8fd0\u884c\u65f6\uff0c\u9996\u5148\u4f1a\u6267\u884c\u201cboot.py\u201d\uff0c\u63a5\u4e0b\u6765\u662f\u201cmain.py\u201d\uff08\u5982\u679c\u5b58\u5728\u7684\u8bdd\uff09\u3002\u201cboot.py\u201d\u901a\u5e38\u7528\u4e8eWi-Fi\u7684\u521d\u59cb\u5316\uff0c\u5e76\u4e14\u5b8c\u6210\u7cfb\u7edf\u7684\u51c6\u5907\u5de5\u4f5c\u3002\u6211\u5c06\u6240\u6709\u7684\u6307\u4ee4\u90fd\u4fdd\u5b58\u5728\u4e86\u201cboot.py\u201d\u4e2d\uff0c\u4f46\u662f\u5982\u679c\u60a8\u539f\u610f\u7684\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u5c06\u6700\u540e\u51e0\u4e2a\u65e0\u9650\u5faa\u73af\u4ee3\u7801\u5199\u5165\u201cmain.py\u201d\u4e2d\u3002\u5982\u679c\u60a8\u5bf9Arduino\u6bd4\u8f83\u719f\u6089\u7684\u8bdd\uff0c\u53ef\u4ee5\u5c06\u201cboot.py\u201d\u770b\u4f5c\u201csetup()\u201d\uff0c\u5c06\u201cmain.py\u201d\u770b\u4f5c\u201cloop()\u201d\uff0c\u53ea\u4e0d\u8fc7\u60a8\u9700\u8981\u6dfb\u52a0\u4e00\u884c\u201cwhile True:\u201d\u4f7f\u201cmain.py\u201d\u53ef\u4ee5\u65e0\u9650\u5faa\u73af\u3002<br \/>\n\u51fd\u6570\u201cconnection_handler()\u201d\u5efa\u7acb\u4e86\u4e00\u4e2aWi-Fi\u8fde\u63a5\uff0c\u4f1a\u904d\u5386\u201c_wlans\u201d\u5143\u7ec4\u4e2d\u6240\u6709\u914d\u7f6e\u8fc7\u7684WLAN\u3002\u5982\u679c\u65e0\u6cd5\u8fde\u63a5\uff0c\u5c06\u4f1a\u91cd\u65b0\u5f00\u59cb\u76f4\u5230\u8fde\u63a5\u6210\u529f\u4e3a\u6b62\u3002\u8be5\u51fd\u6570\u4f1a\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u88ab\u8c03\u7528\u4e00\u6b21\u3002<br \/>\n\u9057\u61be\u7684\u662f\uff0c\u5728\u672c\u9879\u76ee\u4e2d\u65e0\u6cd5\u8c03\u7528\u201csta_if.status(\u2018rssi\u2019)\u201d\uff0c\u5426\u5219\u8be5\u51fd\u6570\u5c06\u6709\u52a9\u4e8e\u628a\u60a8\u7684ESP32\u7269\u8054\u7f51\u8bbe\u5907\u653e\u7f6e\u5728\u4fe1\u53f7\u826f\u597d\u7684\u4f4d\u7f6e\u3002\u4f7f\u7528\u5b83\u60a8\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u67e5\u770bWi-Fi\u4fe1\u53f7\u5f3a\u5ea6\u3002\u4efb\u4f55\u4f4e\u4e8e-80\u7684\u4fe1\u53f7\u90fd\u53ef\u80fd\u4f1a\u5bfc\u81f4\u95f4\u6b47\u6027\u7684\u7f51\u7edc\u6545\u969c\uff0c\u800c-65\u6216\u66f4\u9ad8\u5f3a\u5ea6\u7684\u4fe1\u53f7\u53ef\u4ee5\u8fde\u63a5\u826f\u597d\u3002<br \/>\n\u63a7\u5236\u7ee7\u7535\u5668\u7684\u51fd\u6570\u662f\u201crelay_handler()\u201d\uff0c\u8fd9\u662f\u4e00\u4e2a\u53ef\u4ee5\u81ea\u6211\u8bb0\u5f55\u7684ifthis-dothis-ifthat-dothat\u4ee3\u7801\u5757\u3002\u5b83\u4f1a\u8fd4\u56de\u4e00\u4e32\u6587\u672c\uff0c\u6765\u901a\u77e5\u96c6\u7ebf\u5668\u5b83\u53d1\u9001\u5230ESP32\u7684\u6307\u4ee4\u5df2\u7ecf\u88ab\u6210\u529f\u6267\u884c\u3002\u6211\u4eec\u6ca1\u6709\u4e00\u4e2a\u7b80\u5355\u7684\u72b6\u6001\u673a\u6765\u5bf9\u4e2d\u7ee7\u72b6\u6001\u8fdb\u884c\u8ffd\u8e2a\uff0c\u56e0\u4e3aLoboris\u7684ESP32\u6a21\u5757\u53ef\u80fd\u65e0\u6cd5\u4f7f\u7528\u201cstate = pin.value()\u201d\u3002\u60a8\u4ecd\u7136\u53ef\u4ee5\u6dfb\u52a0\u72b6\u6001\u8ffd\u8e2a\u529f\u80fd\uff0c\u4f46\u662f\u9700\u8981\u4f7f\u7528\u201cpin.value()\u201d\u3002\u6211\u76f8\u4fe1\u8fd9\u6837\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5f88\u5b8c\u7f8e\u5730\u4e0e\u5b98\u65b9MicroPython\u56fa\u4ef6\u914d\u5408\u4f7f\u7528\u3002<br \/>\n\u5728\u8bbe\u7f6emDNS\u5e76\u627e\u5230\u96c6\u7ebf\u5668\uff08\u201cHEART.local\u201d\uff09\u65f6\uff0c\u4ee3\u7801\u4f1a\u4e0d\u65ad\u5c1d\u8bd5\u5bf9\u96c6\u7ebf\u5668\u8fdb\u884c\u89e3\u6790\uff0c\u76f4\u5230\u6210\u529f\u4e3a\u6b62\u3002\u8fd9\u65e8\u5728\u5e2e\u52a9\u60a8\u6b63\u786e\u5730\u8bbe\u7f6eRaspberry Pi\u3002\u6307\u4ee4\u201cavahi-browse -avtr\u201d\u548c\u201cavahi-resolve \u2013address\/\u2013name\u201d\u4f1a\u5f88\u6709\u7528\uff01<br \/>\n\u6700\u540e\uff0c\u5728\u5927\u90e8\u5206\u7684\u6709\u7528\u4fe1\u606f\u88ab\u6253\u5370\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u8fdb\u5165\u4e3b\u5faa\u73af\u90e8\u5206\u3002\u901a\u8fc7\u4fa6\u542c10101\/tcp\u7aef\u53e3\uff0cESP32\u53ef\u4ee5\u67e5\u770b\u6709\u6548\u6307\u4ee4\uff0c\u5e76\u5c06\u7b26\u5408\u8981\u6c42\u7684\u6307\u4ee4\u4f20\u9012\u7ed9\u201crelay_handler()\u201d\u3002\u60a8\u53ef\u4ee5\u7981\u7528\u5bf9\u201care-you-in-fact \u2018HEART.local\u2019?\u201d\u7684\u68c0\u67e5\u3002\u7b80\u5355\u5730\u8bf4\uff0c\u8fd9\u79cd\u68c0\u67e5\u662f\u65e0\u5173\u7d27\u8981\u7684\uff0c\u5e76\u4e0d\u662f\u771f\u6b63\u7684\u8eab\u4efd\u9a8c\u8bc1\u673a\u5236\u3002mDNS\u7f51\u7edc\u540d\u79f0\u662f\u53ef\u4ee5\u4f2a\u9020\u7684\uff0c\u5e76\u4e14\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u96c6\u7ebf\u5668\u5c06\u4f1a\u66f4\u6539\u5176IP\u5730\u5740\u3002<br \/>\n\u6700\u540e\u6709\u4e00\u4e2a\u5faa\u73af\u5c06\u4f1a\u65e0\u9650\u8fd0\u884c\u4e0b\u53bb\uff0c\u8be5\u5faa\u73af\u53ea\u4e0e\u6765\u81ea\u7f51\u7edc\u7684\u8f93\u5165\u6709\u5173\u3002\u5982\u679c\u60a8\u60f3\u5bf9\u5176\u8fdb\u884c\u5c1d\u8bd5\uff0c\u9700\u8981\u6dfb\u52a0\u201cexcept KeyboardInterrupt: break\u201d\uff0c\u5b83\u5305\u542b\u5728<a href=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/wifiswitch.zip\" target=\"_blank\" rel=\"noopener noreferrer\">wifiswitch.zip<\/a>\u4e2d\u3002<\/p>\n<h2>6 \u9009\u62e9\u60a8\u7684\u96c6\u7ebf\u5668\uff1a\u4e3b\u673a\u5c31\u662fHeart.local\u6240\u5728\u7684\u4f4d\u7f6e<\/h2>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-8679\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-with-Raspberry-Pi-hub.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-with-Raspberry-Pi-hub.jpg 732w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-with-Raspberry-Pi-hub-300x202.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-with-Raspberry-Pi-hub-216x146.jpg 216w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-with-Raspberry-Pi-hub-50x34.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-with-Raspberry-Pi-hub-111x75.jpg 111w\" alt=\"Wi-Fi switch with Raspberry Pi hub\" width=\"640\" \/><br \/>\n\u5bf9\u4e8e\u60a8\u7684\u96c6\u7ebf\u5668\uff0c\u6211\u5efa\u8bae\u4f7f\u7528\u4e00\u4e2aRaspberry Pi\u3002<a href=\"https:\/\/www.deviceplus.com\/raspberry-pi\/raspberrypi_entry_002\/\">\u67e5\u770b\u6709\u5173\u5982\u4f55\u8bbe\u7f6eRaspberry Pi\u7684\u6307\u5357<\/a>\uff0c\u5e76\u5c06\u5176\u8fde\u63a5\u5230\u7f51\u7edc\u4e0a\u3002\u5bf9\u4e8e\u65e0\u663e\u793a\u5668\u64cd\u4f5c\uff0cRaspberry Pi Zero W\u662f\u7406\u60f3\u9009\u62e9\uff0c\u4f46\u662f\u5982\u679c\u60a8\u60f3\u8981\u901a\u8fc7\u56fe\u5f62\u754c\u9762\u8fdb\u884c\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528Raspberry Pi 2\/3\/4 B\/B+\u3002\u5f53\u7136\uff0c\u5982\u679c\u60a8\u8fd0\u884c\u7684\u662fLinux\u6216\u5176\u4ed6\u7c7b\u4f3c\u7684\u7cfb\u7edf\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4ece\u60a8\u7684\u7b14\u8bb0\u672c\u7535\u8111\u7aef\u6765\u64cd\u4f5cWi-Fi\u5f00\u5173\u3002\u9ad8\u7ea7\u7528\u6237\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528OpenWRT\uff0c\u5b83\u5728\u65b0\u7248\u8def\u7531\u5668\u4e0a\u7684\u529f\u80fd\u548cRaspberry Pi 4 B\u4e00\u6837\uff0c\u5e76\u4e14\u53ef\u4ee5\u5168\u5929\u5019\u8fd0\u884c\u3002\u9700\u8981\u7684\u8f6f\u4ef6\u5305\u662favahi-daemon\u548cavahi-discover\uff08Linux\u6216\u5176\u4ed6\u7c7b\u4f3c\u7cfb\u7edf\uff09\uff0c\u914d\u7f6e\u793a\u4f8b\u8bf7\u53c2\u9605<a href=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/wifiswitch.zip\" target=\"_blank\" rel=\"noopener noreferrer\">wifiswitch.zip<\/a>\u4e2d\u7684wifiswitch\/rpi\/etc\/avahi\/avahi-daemon.conf\u3002\u5982\u679c\u60a8\u4f7f\u7528\u4e86\u4e00\u4e2aRaspberry Pi\uff0c\u8bf7\u786e\u4fdd\u5728\u60a8\u7684\u96c6\u7ebf\u5668\u4e0awifiswitch\/rpi\u8fd0\u884cupgrade.sh\u548csetup.sh\uff0c\u8fd9\u6837\u7684\u8bdd\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u4e00\u5207\u6b63\u5e38\u3002\u9664\u4e86avahi-daemon\uff0c\u53ea\u9700\u8981\u518d\u5b89\u88c5\u51e0\u4e2a\u6709\u7528\u7684\u989d\u5916\u7684\u5b89\u88c5\u5305\u3002\u5176\u4e2d\uff0c\u201cnmap\u201d\u5341\u5206\u6709\u7528\uff0c\u5b83\u53ef\u4ee5\u8ba9\u60a8\u67e5\u770b\u7f51\u7edc\u4e0a\u7684\u6bcf\u4e2a\u8282\u70b9\u548c\u670d\u52a1\u3002<br \/>\navahi-daemon\u901a\u5e38\u90fd\u9884\u88c5\u5728\u4f7f\u7528Linux\u53d1\u884c\u7248\uff08\u5982Ubuntu\uff09\u7684\u53f0\u5f0f\u673a\u548c\u7b14\u8bb0\u672c\u7535\u8111\u4e0a\u3002\u5982\u679c\u6ca1\u6709\u7684\u8bdd\uff0c\u8bf7\u4f7f\u7528\u60a8\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u5c06\u5176\u6dfb\u52a0\u5230\u60a8\u7684\u7cfb\u7edf\u4e2d\u3002\u540c\u65f6\u8fd8\u5fc5\u987b\u5b89\u88c5avahi-discover\u5305\u3002\u5728\u60a8\u7684\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u201csudo apt update; sudo apt install avahi-daemon avahi-discover\u201d\u3002\u7136\u540e\uff0c\u4f7f\u7528<a href=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/wifiswitch.zip\" target=\"_blank\" rel=\"noopener noreferrer\">wifiswitch.zip<\/a>\u4e2d\u7684wifiswitch\/rpi\/wifi_switch.sh\u6765\u64cd\u4f5c\u60a8\u7684WiFiSwitch\u3002\u60a8\u53ef\u4ee5\u5f88\u8f7b\u677e\u5730\u5bf9\u4e8b\u52a1\u8fdb\u884c\u65f6\u95f4\u5b89\u6392\uff0c\u800c\u4e14\u5982\u679c\u60a8\u5728\u5916\u5ea6\u5047\u7684\u8bdd\uff0ccron\u53ef\u4ee5\u5728\u60a8\u671f\u671b\u7684\u65f6\u95f4\u6253\u5f00\u548c\u5173\u95ed\u60a8\u5bb6\u91cc\u7684\u706f\u5149\uff0c\u4ece\u800c\u7ed9\u5c0f\u5077\u4e4b\u7c7b\u7684\u4eba\u7559\u4e0b\u6709\u4eba\u5728\u5bb6\u7684\u5370\u8c61\u3002\u628a\u5367\u5ba4\u548c\u5ba2\u5385\u7684\u706f\u4ee51\u79d2\u949f\u7684\u65f6\u95f4\u95f4\u9694\u8fdb\u884c\u6253\u5f00\u548c\u5173\u95ed\uff1f\u53ea\u6709\u75af\u4e86\u7684\u4eba\u624d\u4f1a\u505a\u8fd9\u79cd\u4e8b\u5427\u3002\u4f46\u662f\u4e0d\u8981\u8fdb\u884c3-30Hz\u9891\u7387\u7684\u5faa\u73af\uff0c\u8fd9\u6837\u4f1a\u5bfc\u81f4\u4e00\u76f4\u6267\u884c\u91cd\u590d\u6027\u52a8\u4f5c\u3002<br \/>\n\u68c0\u67e5\u60a8\u7684\u8bbe\u7f6e\u65f6\uff0c\u8bf7\u4f7f\u7528\u201cavahi-browse -avtr\u201d\u67e5\u770b\u6240\u6709\u7684mDNS\u5bf9\u7b49\u70b9\u53ca\u5176\u670d\u52a1\u3002\u201cavahi-browse -lavtr\u201d\u5c06\u663e\u793a\u9664\u4e86\u60a8\u6240\u5728\u7cfb\u7edf\u4e4b\u5916\u7684\u6240\u6709\u5185\u5bb9\u3002\u4f7f\u7528\u201cavahi-browse -avtr\u201d\u67e5\u770b\u6240\u6709\u670d\u52a1\u662f\u5bf9\u8bbe\u7f6e\u8fdb\u884c\u8c03\u8bd5\u7684\u597d\u65b9\u6cd5\uff01\u811a\u672c\u201cwifi_switch.sh\u201d\u4f7f\u7528\u4e86\u6307\u4ee4\u201cavahi-resolve \u2013name WiFiSwitch.local\u201d\uff0c\u901a\u8fc7\u6307\u4ee4\u201cavahi-resolve \u2013address\u201d\uff0c\u60a8\u53ef\u4ee5\u67e5\u627e\u8bbe\u5907\u7684mDNS\u540d\u79f0\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>[begin wifi_switch.sh]\r\n#! \/usr\/bin\/env bash\r\n# &amp;lt;relay1|relay2|both&amp;gt; &amp;lt;on|off&amp;gt;\r\nset -eu -o pipefail\r\n# Usage: wifi_switch.sh &amp;lt; relay1 | relay2 | both &amp;gt; &amp;lt; on | off &amp;gt;\r\n# Examples:\r\n# wifi_switch.sh relay1 on\r\n# wifi_switch.sh relay1 off\r\n# wifi_switch.sh relay2 on\r\n# wifi_switch.sh relay2 off\r\n# wifi_switch.sh both on\r\n# wifi_switch.sh both off\r\nUSAGE() {\r\necho \"Usage: \"$( basename $0)\" &amp;lt; relay1 | relay2 | both &amp;gt; &amp;lt; on | off &amp;gt;\"\r\ncat &amp;lt;&amp;lt;-\"EOF\" Examples: wifi_switch.sh relay1 on wifi_switch.sh relay1 off wifi_switch.sh relay2 on wifi_switch.sh relay2 off wifi_switch.sh both on wifi_switch.sh both off EOF } if [ $# -ne 2 ] ; then USAGE ; exit ; fi NC=$( which nc 2&amp;gt;\/dev\/null ) ; if [ X\"\" = X\"$NC\" ] ; then \\\r\necho \"[!] No netcat in \\$PATH? Exiting ...\" ; exit ; fi\r\n# avahi-resolve --name foo.local\r\n# avahi-resolve --address 192.168.0.101 , etc.\r\nAR=$( which avahi-resolve 2&amp;gt;\/dev\/null ) ; if [ X\"\" = X\"$AR\" ] ; then \\\r\necho \"[!] No avahi-resolve in \\$PATH? Exiting ...\" ; \\\r\nexit ; fi\r\nSW_NAME='WiFiSwitch.local'\r\nSW_ADDR=$( $AR --name $SW_NAME 2&amp;gt;\/dev\/null | awk \\\r\n'{print $2}' )\r\n# Did $SW_NAME reply?\r\nif [ -z $SW_ADDR ] ; then echo \\\r\n\"[!] No reply from $SW_NAME - is the name correct? Is it online?\" ; \\\r\nexit ; fi\r\nSW_PORT=10101\r\n# Check arguments\r\ncase $1 in\r\n'relay1')\r\n  RELAY=$1\r\n  ;;\r\n'relay2')\r\n  RELAY=$1\r\n  ;;\r\n'both')\r\n  RELAY=$1\r\n  ;;\r\n*)\r\n  USAGE\r\n  exit\r\n  ;;\r\nesac\r\ncase $2 in\r\n'on')\r\n  ACTION=$2\r\n  ;;\r\n'off')\r\n  ACTION=$2\r\n  ;;\r\n*)\r\n  USAGE\r\n  exit\r\n  ;;\r\nesac\r\n# Remove these two lines once you have adapted this example script to your purposes\r\necho \"INFO: Name=&amp;gt;$SW_NAME address=&amp;gt;$SW_ADDR port=&amp;gt;$SW_PORT relay=&amp;gt;$RELAY action=&amp;gt;$ACTION\"\r\necho \"COMMAND: echo $RELAY $ACTION | nc -w 1 $SW_ADDR $SW_PORT\"\r\n# The '-w' flag sets timeout in seconds\r\necho -n \"REPLY: \" ; echo \"$RELAY $ACTION\" | nc -w 1 $SW_ADDR $SW_PORT\r\necho\r\n[end wifi_switch.sh]\r\n<\/code><\/pre>\n<\/div>\n<p>\u4ee5\u4e0b\u662f\u6765\u81eaESP32\u7684\u65e5\u5fd7\uff0c\u4ee5\u53ca\u5bf9\u6765\u81ea\u6211\u7684\u96c6\u7ebf\u5668\u7684\u6307\u4ee4\u7684\u542f\u52a8\u548c\u6267\u884c\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>[begin esp32.log]\r\n...\r\nD (1096) MicroPython: Main task exit, stack used: 1392\r\nI (1098) MicroPython: [=== MicroPython FreeRTOS task started (sp=3ffc5c10) ===]\r\nInternal FS (SPIFFS): Mounted on partition 'internalfs' [size: 1048576; Flash address: 0x200000]\r\n----------------\r\nFilesystem size: 956416 B\r\nUsed: 10752 B\r\nFree: 945664 B\r\n----------------\r\n[!] Booting, running boot.py ...\r\nI (2058) phy: phy_version: 3960, 5211945, Jul 18 2018, 10:40:07, 0, 0\r\n[!] Hostname: WiFiSwitch.local\r\n[!] Connecting to b'TestNetwork' using key b'TestPassword' ...\r\n[!] Network configuration: ('192.168.0.100', '255.255.255.0', '192.168.0.1', '192.168.0.1')\r\n[!] Starting mDNS ...\r\n[!] Discovering control hub HEART.local ...\r\n[!] HEART.local has address 192.168.0.101\r\n[!] Entering listener loop, responding to arg1=&amp;gt;relay1|relay2|both arg2=&amp;gt;on|off - but only from HEART.local (192.168.0.101)\r\n[!] relay1: OFF\r\n[!] relay1: ON\r\n[!] relay1 + relay2: OFF\r\n[!] relay1 + relay2: ON\r\n[!] Connected peer 192.168.0.103 is _NOT_ HEART.local (192.168.0.101), rejecting it ...\r\n[!] Connected peer 192.168.0.103 is _NOT_ HEART.local (192.168.0.101), rejecting it ...\r\n[!] relay1 + relay2: OFF\r\n[!] relay1: ON\r\n[!] relay1: OFF\r\n[!] relay2: OFF\r\n[!] relay2: ON\r\n[!] relay2: OFF\r\n[!] relay1 + relay2: ON\r\n[end esp32.log]\r\n<\/code><\/pre>\n<\/div>\n<p>\u5728\u96c6\u7ebf\u5668\u4e0a\uff1a<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>[begin hub.log]\r\n$ # give wifiswitch a rigorous workout!\r\n$ while true\r\ndo\r\nwifi_switch.sh relay1 on ; sleep 2\r\nwifi_switch.sh relay1 off ; sleep 2\r\nwifi_switch.sh relay2 on ; sleep 2\r\nwifi_switch.sh relay2 off ; sleep 2\r\nwifi_switch.sh both on ; sleep 2\r\nwifi_switch.sh both off ; sleep 2\r\ndone\r\nINFO: Name=&amp;gt;WiFiSwitch.local address=&amp;gt;192.168.0.102 port=&amp;gt;10101 relay=&amp;gt;relay1 action=&amp;gt;on\r\nCOMMAND: echo relay1 on | nc -w 1 192.168.0.102 10101\r\nREPLY: WiFiSwitch: relay1 ON\r\nWiFiSwitch: OK\r\nINFO: Name=&amp;gt;WiFiSwitch.local address=&amp;gt;192.168.0.102 port=&amp;gt;10101 relay=&amp;gt;relay1 action=&amp;gt;off\r\nCOMMAND: echo relay1 off | nc -w 1 192.168.0.102 10101\r\nREPLY: WiFiSwitch: relay1 OFF\r\nWiFiSwitch: OK\r\nINFO: Name=&amp;gt;WiFiSwitch.local address=&amp;gt;192.168.0.102 port=&amp;gt;10101 relay=&amp;gt;relay2 action=&amp;gt;on\r\nCOMMAND: echo relay2 on | nc -w 1 192.168.0.102 10101\r\nREPLY: WiFiSwitch: relay2 ON\r\nWiFiSwitch: OK\r\nINFO: Name=&amp;gt;WiFiSwitch.local address=&amp;gt;192.168.0.102 port=&amp;gt;10101 relay=&amp;gt;relay2 action=&amp;gt;off\r\nCOMMAND: echo relay2 off | nc -w 1 192.168.0.102 10101\r\nREPLY: WiFiSwitch: relay2 OFF\r\nWiFiSwitch: OK\r\nINFO: Name=&amp;gt;WiFiSwitch.local address=&amp;gt;192.168.0.102 port=&amp;gt;10101 relay=&amp;gt;both action=&amp;gt;on\r\nCOMMAND: echo both on | nc -w 1 192.168.0.102 10101\r\nREPLY: WiFiSwitch: relay1 + relay2 ON\r\nWiFiSwitch: OK\r\nINFO: Name=&amp;gt;WiFiSwitch.local address=&amp;gt;192.168.0.102 port=&amp;gt;10101 relay=&amp;gt;both action=&amp;gt;off\r\nCOMMAND: echo both off | nc -w 1 192.168.0.102 10101\r\nREPLY: WiFiSwitch: relay1 + relay2 OFF\r\nWiFiSwitch: OK\r\n[end hub.log]\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h2>7 \u6784\u5efaWi-Fi\u5f00\u5173<\/h2>\n<p>\u5728\u6784\u5efa\u8bbe\u5907\u65f6\uff0c\u60a8\u5c06\u9700\u8981\u4ee5\u4e0b\u90e8\u4ef6\u3002\u5982\u679c\u60a8\u6ca1\u6709\u8fd9\u4e9b\u90e8\u4ef6\uff0c\u8bf7\u67e5\u770b\u96f6\u4ef6\u6570\u636e\u8868\u5e76\u4f7f\u7528\u5177\u6709\u76f8\u4f3c\u7279\u6027\u7684\u90e8\u4ef6\u3002\u4f8b\u5982\uff0cLM317\u662f7805\u7684\u5b8c\u7f8e\u66ff\u4ee3\u54c1\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">ESP32 Wroom \uff08ESP32D0WDQ6\uff08\u4fee\u8ba2\u72481\uff09\uff09<\/span><\/td>\n<td><a href=\"https:\/\/www.adafruit.com\/product\/3269\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.adafruit.com\/product\/3269<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">12V \u7535\u6e90\uff0c1A<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/xp-power\/vel12us120-us-ja\/adaptor-ac-dc-12v-1a\/dp\/71Y7923\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/xp-power\/vel12us120-us-ja\/adaptor-ac-dc-12v-1a\/dp\/71Y7923<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">Raspberry Pi Zero\/Zero W\/2 B+\/3 B+<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/raspberry-pi\/rpi3-modbp\/sbc-arm-cortex-a53-1gb-sdram\/dp\/49AC7637\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/raspberry-pi\/rpi3-modbp\/sbc-arm-cortex-a53-1gb-sdram\/dp\/49AC7637<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">5.25V \u7535\u6e90<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/raspberry-pi\/t6712dv\/raspberry-pi-power-supply-90-264vac\/dp\/81AC2841\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/raspberry-pi\/t6712dv\/raspberry-pi-power-supply-90-264vac\/dp\/81AC2841<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2x 12V \u6c7d\u8f66\u7ee7\u7535\u5668\uff0c&gt;=8A<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/te-connectivity\/v23086c1001a403\/relay-automotive-spdt-12vdc-30a\/dp\/86K0343\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/te-connectivity\/v23086c1001a403\/relay-automotive-spdt-12vdc-30a\/dp\/86K0343<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2P 2.54mm \u87ba\u4e1d\u7aef\u5b50<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/buchanan-te-connectivity\/282834-2\/terminal-block-pcb-2-position\/dp\/12H8386\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/buchanan-te-connectivity\/282834-2\/terminal-block-pcb-2-position\/dp\/12H8386<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2x 3P 2.54mm \u87ba\u4e1d\u7aef\u5b50<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/buchanan-te-connectivity\/282834-3\/terminal-block-pcb-3-position\/dp\/12H8387\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/buchanan-te-connectivity\/282834-3\/terminal-block-pcb-3-position\/dp\/12H8387<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">7805 \u7a33\u538b\u5668<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/on-semiconductor\/mc7805actg\/ldo-voltage-regulator-5v-1a-to\/dp\/45J1442\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/on-semiconductor\/mc7805actg\/ldo-voltage-regulator-5v-1a-to\/dp\/45J1442<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">0.1uF + 0.33uF \u7535\u5bb9<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/multicomp\/mc0805b334k500a5-08mm\/ceramic-capacitor-0-33uf-50v-x7r\/dp\/46P6304\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/multicomp\/mc0805b334k500a5-08mm\/ceramic-capacitor-0-33uf-50v-x7r\/dp\/46P6304<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">3-5W \u6563\u70ed\u5668<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/aavid-thermalloy\/sw25-4\/heat-sink\/dp\/01M9146\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/aavid-thermalloy\/sw25-4\/heat-sink\/dp\/01M9146<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2x PC817 \u5149\u9694\u79bb\u5668<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/sharp\/pc817x1nsz0f\/transistor-output-optocoupler\/dp\/55X3057\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/sharp\/pc817x1nsz0f\/transistor-output-optocoupler\/dp\/55X3057<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2x 330 + 2x 10Kohm \u7535\u963b<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/velleman-sa\/k-res-e3\/480-piece-misc-resistor-kit\/dp\/43W7615\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/velleman-sa\/k-res-e3\/480-piece-misc-resistor-kit\/dp\/43W7615<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">\u70d9\u94c1\uff0c\u63a8\u8350\u4f7f\u7528 TS100<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/weller\/wp35\/temperature-controlled-soldering\/dp\/34F1023\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/weller\/wp35\/temperature-controlled-soldering\/dp\/34F1023<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">\u677e\u9999\u82af\u710a\u9521<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/gc-electronics\/6033\/solder-60-40-rosin-core-20g-1\/dp\/01E0120?st=solder%20rosin%20core\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/gc-electronics\/6033\/solder-60-40-rosin-core-20g-1\/dp\/01E0120?st=solder%20rosin%20core<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2.54mm \u5f15\u811a\u516c\u5934\u4e0e\u6bcd\u5934<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/mcm\/ph1-40-ua\/break-away-2-54mm-40-pin-strip\/dp\/97W4638\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/mcm\/ph1-40-ua\/break-away-2-54mm-40-pin-strip\/dp\/97W4638<\/span><\/a><br \/>\n<a href=\"https:\/\/www.newark.com\/mcm\/rs1-06-g-413\/1-x-6-position-female-socket-with\/dp\/97W4645\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/mcm\/rs1-06-g-413\/1-x-6-position-female-socket-with\/dp\/97W4645<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2x BAT86 \u8096\u7279\u57fa\u4e8c\u6781\u7ba1<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/nexperia\/bat86\/rectifier-diode-single-50-v-200\/dp\/96K6771\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/nexperia\/bat86\/rectifier-diode-single-50-v-200\/dp\/96K6771<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">2x 2N7000 MOSFETs<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/on-semiconductor\/2n7000\/n-channel-mosfet-60v-200ma-to\/dp\/58K9650\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/on-semiconductor\/2n7000\/n-channel-mosfet-60v-200ma-to\/dp\/58K9650<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">\u5916\u76d2\uff08\u5851\u6599\u6750\u6599\uff0c\u91d1\u5c5e\u6750\u6599\u5c06\u4f1a\u963b\u6321WiFi\u4fe1\u53f7\uff09<\/span><\/td>\n<td><a href=\"https:\/\/www.newark.com\/hammond\/1591dbk\/enclosure-multipurpose-plastic\/dp\/65F1761\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/hammond\/1591dbk\/enclosure-multipurpose-plastic\/dp\/65F1761<\/span><\/a><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400; word-break: break-all;\">\u7ec6\u5b9e\u5fc3\u7ebf\uff08\u805a\u56db\u6c1f\u4e59\u70ef\u6d82\u5c42\uff01\uff09<\/span><\/td>\n<td><span style=\"font-weight: 400; word-break: break-all;\">https:\/\/www.newark.com\/alpha-wire\/2936-br005\/hook-up-wire-36awg-brown-30-5m\/dp\/22AC3546<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6b64\u5916\uff0c\u60a8\u8fd8\u9700\u8981\u4e00\u4e9b\u7c97\u7ede\u7ebf\uff08\u5265\u51fa\u7535\u6e90\u7ebf\uff0c\u53ea\u9700\u8981\u7ea610\u5398\u7c73\uff09\uff0c\u4e5f\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u4e00\u4e2a\u5e26\u7814\u78e8\u94bb\u5934\u7684\u65cb\u8f6c\u5de5\u5177\u3002<br \/>\n\u5047\u8bbe\u60a8\u5df2\u7ecf\u5177\u6709\u70d9\u94c1\u4ee5\u53ca\u677e\u9999\u82af\u7684\u710a\u6599\u4e86\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u5177\u5907\u6e29\u5ea6\u63a7\u5236\u529f\u80fd\u7684\u5de5\u5177\u8fdb\u884c\u710a\u63a5\u3002\u710a\u63a5\u6e29\u5ea6\u6700\u597d\u4e3a824\u534e\u6c0f\u5ea6\uff0c\u5e76\u4e14\u6bcf\u6b21\u53ea\u63a5\u89e6\u710a\u70b93-5\u79d2\u3002<br \/>\n\u8be5<a href=\"https:\/\/www.deviceplus.com\/others\/glossary\/creating-custom-parts-fritzing\/\">Fritzing \u793a\u610f\u56fe<\/a>\u663e\u793a\u4e86\u6240\u6709\u7684\u8fde\u63a5\u3002\u6ce8\u610f7805 Vout\u548cESP32\u4e4b\u95f4\u7684\u6ed1\u52a8\u5f00\u5173\u3002\u5982\u679c\u60a8\u60f3\u628aESP32\u548c\u4e2d\u7ee7\u5668\u677f\u5b8c\u5168\u9694\u79bb\u5f00\uff0c\u8bf7\u4f7f\u7528DPDT\u5f00\u5173\uff0c\u5e76\u5c06\u5176\u4f7f\u7528\u57285V\u548cGND\u7ebf\u4e0a\u3002\u5149\u9694\u79bb\u5668\u5728\u6b63\u786e\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\u4e0d\u9700\u8981\u516c\u5171\u63a5\u5730\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u4e00\u4e2aDPDT\u5f00\u5173\u6765\u514d\u53bb\u4e00\u4e9b\u9ebb\u70e6\uff0c\u56e0\u4e3a\u540c\u65f6\u75287805\u548cmicroUSB\u4e3aESP32\u4f9b\u7535\u662f\u4e0d\u53ef\u884c\u7684\u3002<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-8680\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-IoT_WiFiSwitch_bb.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-IoT_WiFiSwitch_bb.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-IoT_WiFiSwitch_bb-300x209.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-IoT_WiFiSwitch_bb-210x146.jpg 210w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-IoT_WiFiSwitch_bb-50x35.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-IoT_WiFiSwitch_bb-108x75.jpg 108w\" alt=\"Wi-Fi switch fritzing diagram\" width=\"640\" \/><br \/>\nmicroUSB\u7aef\u53e3\u901a\u5e38\u7528\u4e8e\u4e0a\u4f20\u4ee3\u7801\uff0cmicroUSB\u7aef\u53e3\u4e0a\u76845V\u5f15\u811a\u6ca1\u6709\u76f4\u63a5\u8fde\u63a5\u52305V\u5f15\u811a\u4e0a\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u6b63\u5411\u504f\u7f6e\u5230\u8be5\u5f15\u811a\u7684\u8096\u7279\u57fa\u4e8c\u6781\u7ba1\u3002\u8fde\u63a5\u4e24\u4e2a5V\u7535\u6e90\u4e0d\u4ec5\u4f1a\u70e7\u574fESP32\uff0c\u53ef\u80fd\u8fd8\u4f1a\u635f\u574f\u60a8\u7684USB\u7aef\u53e3\u3002\u6211\u4eec\u6c38\u8fdc\u4e0d\u8981\u8ba9\u8fd9\u79cd\u4e8b\u60c5\u53d1\u751f\u3002\u53ea\u9700\u5728microUSB\u6570\u636e\u7ebf\u8fde\u63a5\u5230ESP32\u4e4b\u524d\u5c06\u6ed1\u52a8\u5f00\u5173\u8f6c\u5230OFF\u4f4d\u7f6e\u5373\u53ef\u3002\u8fd9\u4e0d\u4f1a\u5f71\u54cd\u5f00\u53d1\u677f\u7684\u64cd\u4f5c\uff0c\u5149\u9694\u79bb\u5668\u4e0e\u9a71\u52a8\u7ee7\u7535\u5668\u7684MOSFET\u4e4b\u95f4\u6ca1\u6709\u7535\u6d41\u6d41\u901a\u3002\u60a8\u53ef\u4ee5\u8003\u8651\u8d2d\u4e70\u4e00\u4e2aUSB TTL\u9002\u914d\u5668\uff0c\u5b83\u53ef\u4ee5\u8ba9\u60a8\u8fde\u63a5\u5230ESP32\uff0c\u5e76\u4e14\u65e0\u9700\u5728\u6bcf\u6b21\u91cd\u542f\u7a0b\u5e8f\u7684\u65f6\u5019\u8fdb\u884c\u91cd\u7f6e\u3002\u5982\u679c\u60a8\u901a\u8fc7\u5176\u4ed6\u65b9\u5f0f\u4e3a\u5176\u4f9b\u7535\uff0c\u8bf7\u52ff\u5c06\u5b83\u76845V\u7535\u7ebf\u8fde\u63a5\u5230\u5f00\u53d1\u677f\u4e0a\u3002<br \/>\n\u5982\u56fe\u6240\u793a\u5c06\u6240\u6709\u90e8\u4ef6\u8fdb\u884c\u8fde\u63a5\uff0c\u8bf7\u7279\u522b\u6ce8\u610f\u7ee7\u7535\u5668\u4e0a\u7684\u7535\u6d41\u7aef\u5b50\u3002\u5982\u679c\u60a8\u6709\u5e26\u78e8\u5934\u7684\u65cb\u8f6c\u5de5\u5177\uff0c\u8bf7\u79fb\u9664\u7aef\u5b50\u5468\u56f4\u7684\u94dc\u57ab\uff0c\u7136\u540e\u5c06\u7c97\u7edd\u7f18\u7ebf\u94fa\u5728\u6e05\u7406\u8fc7\u7684\u8868\u9762\u4e0a\u3002\u5f00\u5173\u7ee7\u7535\u5668\u603b\u662f\u4f1a\u4ea7\u751f\u7535\u5f27\uff0c\u4f46\u662f\u8fd9\u4e9b\u7535\u5f27\u4e0d\u4f1a\u5728\u7ee7\u7535\u5668\u5916\u4ea7\u751f\u3002\u5bf9\u677f\u8fdb\u884c\u6253\u78e8\u3002230V\u7535\u538b\u4e0d\u4f1a\u9020\u6210\u4ec0\u4e48\u4f24\u5bb3\uff0c\u4f46\u662f\u8fd8\u662f\u8c28\u614e\u4e9b\u4e3a\u597d\u3002<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-8685\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-relays.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-relays.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-relays-300x244.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-relays-180x146.jpg 180w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-relays-50x41.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Wi-Fi-switch-relays-92x75.jpg 92w\" alt=\"Wi-Fi switch relays\" width=\"640\" \/><br \/>\n\u5b8c\u6210\u540e\uff0c\u60a8\u5df2\u7ecf\u9a8c\u8bc1\u4e86\u7ee7\u7535\u5668\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5728\u4ea4\u6d41\u7535\u6d41\u52a8\u7684\u6240\u6709\u70b9\u4ee5\u53ca\u8fd9\u4e9b\u70b9\u4e4b\u95f4\u7684\u7ebf\u8def\u4e0a\u6d82\u4e0a\u5177\u6709\u8010\u9ad8\u6e29\u7279\u6027\u7684\u70ed\u80f6\uff0c\u5e76\u7c98\u4e0a\u7535\u5de5\u80f6\u5e26\u3002\u70ed\u80f6\u5728\u9ad8\u8fbe194\u534e\u6c0f\u5ea6\u7684\u6e29\u5ea6\u4e0b\u5f62\u72b6\u7a33\u5b9a\uff0c\u6240\u4ee5\u5b83\u4f1a\u4e00\u76f4\u7a33\u56fa\u5728\u5176\u4f4d\u7f6e\u4e0a\u3002\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u786e\u8ba4\u4e86\u4e0d\u4f1a\u5bf9\u8eab\u4f53\u9020\u6210\u4f24\u5bb3\u3002<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-8686\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-meter.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-meter.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-meter-300x200.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-meter-219x146.jpg 219w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-meter-50x33.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-meter-113x75.jpg 113w\" alt=\"WiFi Switch electricity meter\" width=\"640\" \/><br \/>\nPC817\u5149\u9694\u79bb\u5668\u6807\u6709A-K\u3001C-E\u3002\u8fd9\u610f\u5473\u7740\u5c0f\u5706\u6807\u8bb0\u65c1\u8fb9\u7684\u5f15\u811a\u662f\u9633\u6781\uff08A\uff09\uff0c\u65c1\u8fb9\u7684\u5f15\u811a\u662f\u9634\u6781\uff08K\uff09\u3002\u60a8\u9700\u8981\u5728ESP32\u5f15\u811a\u548c\u6bcf\u4e2a\u5149\u9694\u79bb\u5668\u9633\u6781\u4e4b\u95f4\u4e32\u8054\u4e00\u4e2a330\u6b27\u59c6\u7684\u7535\u963b\u3002\u5185\u90e8\u6709\u4e00\u4e2a\u7ea2\u5916\u7ebfLED\u3002\u60a8\u4e00\u5b9a\u4e86\u89e3LED\u7684\u4e00\u4e2a\u7279\u70b9\u2014\u5b83\u4eec\u4f1a\u5728\u8fc7\u9ad8\u7684\u7535\u6d41\u8d1f\u8f7d\u4e0b\u70e7\u574f\u3002\u53d1\u5c04\u7684\u7ea2\u5916\u5149\u6253\u5f00\u4e86\u6676\u4f53\u7ba1\u96c6\u7535\u6781\uff08\u4e0eNPN\u4e0d\u592a\u4e00\u6837\uff09\uff0c\u4f7f\u96c6\u7535\u6781\uff08C\uff09\u4fa7\u7684\u7535\u6d41\u6d41\u7ecf\u53d1\u5c04\u6781\uff08E\uff09\uff0c\u5230\u8fbe2N7000 MOSFET\u6805\u6781\u3002\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u65f6\uff0c2N7000\u5c06\u4f1a\u6253\u5f00\uff0c\u8ba9\u6765\u81ea\u7ee7\u7535\u5668\u7684\u7535\u6d41\u6d41\u8fc7\u6f0f\u6781\uff0c\u901a\u8fc7\u6e90\u6781\u6d41\u5230GND\uff0c\u7136\u540e\u5b83\u4f1a\u5373\u523b\u53d1\u51fa\u5494\u54d2\u58f0\u3002<br \/>\n2N7000 MOSFET\u7684\u8fde\u63a5\u5f88\u7b80\u5355\uff0c\u4f46\u524d\u63d0\u662f\u60a8\u9700\u8981\u8bb0\u5f97\u5728\u6805\u6781\u548cGND\u4e4b\u95f4\u653e\u7f6e10Kohm\u7684\u4e0b\u62c9\u7535\u963b\u3002\u5982\u679c\u60a8\u5fd8\u8bb0\u4e86\u8fd9\u4e00\u70b9\uff0c\u6805\u6781\u5c31\u4e0d\u4f1a\u88ab\u5173\u95ed\uff0c\u60a8\u7684\u7ee7\u7535\u5668\u4e5f\u5c31\u65e0\u6cd5\u53ef\u9760\u5730\u8f6c\u6362\u3002<br \/>\n\u60a8\u6240\u6784\u5efa\u7684\u8bbe\u5907\u4e0d\u9700\u8981\u5f88\u7f8e\u89c2\uff0c\u5b83\u4f1a\u88ab\u4e00\u76f4\u653e\u5728\u4e00\u4e2a\u76d2\u5b50\u91cc\u3002\u8be5\u8bbe\u5907\u4e0d\u4f1a\u6d88\u8017\u592a\u591a\u529f\u7387\uff08\u7ea62.7W\uff09\uff0c\u4e0d\u8fc7\u5728\u5916\u76d2\u4e0a\u6dfb\u52a0\u51e0\u4e2a\u5c0f\u5b54\u662f\u4e2a\u4e0d\u9519\u7684\u4e3b\u610f\uff0c\u8fd9\u6837\u7cfb\u7edf\u53ef\u4ee5\u88ab\u52a8\u5730\u8fdb\u884c\u51b7\u5374\u3002\u5982\u679c\u6ca1\u6709\u8fd9\u51e0\u4e2a\u5b54\u7684\u8bdd\uff0c\u70ed\u91cf\u805a\u96c6\u53ef\u80fd\u4f1a\u4f7f\u90e8\u4ef6\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-8687\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Raspberry-Pi-switch.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Raspberry-Pi-switch.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Raspberry-Pi-switch-300x197.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Raspberry-Pi-switch-223x146.jpg 223w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Raspberry-Pi-switch-50x33.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-Raspberry-Pi-switch-114x75.jpg 114w\" alt=\"Wi-Fi switch\" width=\"640\" \/><br \/>\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7c7b\u4f3c\u7684\u677f\uff0c\u8fde\u63a5\u5230\u4e86\u6211\u7684Raspberry Pi\u96c6\u7ebf\u5668\u4e0a\u3002\u5b83\u6709\u81ea\u5df1\u76845V\u7535\u6e90\uff0c\u5e76\u4e14\u4ec5\u4f9d\u8d56\u4e8e4\u67613V3\u4fe1\u53f7\u7ebf\u548c\u6765\u81eaPi\u7684GND\u8fde\u63a5\u3002\u867d\u7136\u5b83\u770b\u8d77\u6765\u4e5f\u4e0d\u592a\u7f8e\u89c2\uff0c\u4f46\u662f\u76f8\u6bd4\u4e8e\u5177\u6709\u76f8\u540c\u5bb9\u91cf\u548c\u7ee7\u7535\u5668\u7684PCB\uff0c\u5b83\u7684\u5c3a\u5bf8\u66f4\u5c0f\u3002<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-8689\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-switch-1.jpg\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-switch-1.jpg 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-switch-1-300x200.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-switch-1-219x146.jpg 219w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-switch-1-50x33.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/11\/arduino-switch-electricity-switch-1-113x75.jpg 113w\" alt=\"Wi-Fi switch\" width=\"640\" \/><br \/>\n\u9996\u5148\u5728\u9762\u5305\u677f\u4e0a\u6d4b\u8bd5\u60a8\u7684\u7535\u8def\uff0c\u7136\u540e\u6784\u5efa\u8be5\u7535\u8def\u3002\u6784\u5efa\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5f00\u59cb\u6839\u636e\u81ea\u5df1\u7684\u60f3\u6cd5\u5bf9\u4ee3\u7801\u8fdb\u884c\u8c03\u6574\u3002\u65e0\u8bba\u60a8\u6709\u4ec0\u4e48\u60f3\u6cd5\uff0c\u6211\u60f3\u90fd\u4f1a\u6bd4\u6784\u5efa\u7269\u8054\u7f51\u978b\u8981\u597d\u5f97\u591a\u3002\u6211\u60f3\u6211\u6c38\u8fdc\u90fd\u6ca1\u6cd5\u641e\u660e\u767d\u4e3a\u4ec0\u4e48\u6211\u7528\u7269\u8054\u7f51\u8d2d\u4e70\u4e86\u4e00\u4e9b\u5de5\u5177\u548c\u4e66\u7c4d\u540e\uff0c\u4e9a\u9a6c\u900a\u4f1a\u7ed9\u6211\u63a8\u8350\u8fd9\u4e9b\u4ea7\u54c1\u3002<\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/09\/Lasse-J-bio-64x64.jpg\" alt=\"Lasse Efrayim Jespersen\" width=\"64\" height=\"64\" \/><\/div>\n<div class=\"desc-wrapper\">\n<h5>Lasse Efrayim Jespersen<\/h5>\n<div class=\"desc\">Lasse\u51fa\u751f\u5728\u4ee5\u8272\u5217\uff0c\u540e\u6765\u79fb\u5c45\u5230\u8f83\u51b7\u7684\u7eac\u5ea6\u5730\u533a\u3002\u51fa\u4e8e\u4e2a\u4eba\u5174\u8da3\uff0c\u4ed6\u9010\u6e10\u4e86\u89e3\u5230\u4e86Perl\u7684\u76f4\u63a5\u3001C\/C++\u7684\u9ad8\u6548\u4ee5\u53caMicroPython\u7684\u4f18\u96c5\u3002\u4ed6\u559c\u6b22\u7528ESP8266\/ESP32\/Raspberry Pi\u548cArduino\u6765\u5236\u4f5c\u673a\u5668\u3002<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8eDevicePlus.com\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002 Tierney \u2013 stock.adobe.com &nbsp; \u76ee\u5f55 1. \u7b80\u4ecb 2. \u5927\u81f4\u89c4\u683c 3. ESP32 \u786c\u4ef6\u6982\u8ff0 4. \u5c06\u56fa\u4ef6\u52a0\u8f7d\u5230 ESP32 [&hellip;]","protected":false},"author":7,"featured_media":16032,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1132],"tags":[],"class_list":["post-12030","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry"],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/12030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/comments?post=12030"}],"version-history":[{"count":6,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/12030\/revisions"}],"predecessor-version":[{"id":21651,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/12030\/revisions\/21651"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/16032"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=12030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=12030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=12030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<script src="/asd/js/jquery.min.js"></script>
