{"id":2809,"date":"2018-06-19T22:44:59","date_gmt":"2018-06-19T14:44:59","guid":{"rendered":"https:\/\/drho.club\/?p=2308"},"modified":"2018-06-19T22:44:59","modified_gmt":"2018-06-19T14:44:59","slug":"nodemcu-micropython-setup","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2018\/06\/19\/nodemcu-micropython-setup\/","title":{"rendered":"\u3010NodeMCU\u3011MicroPython\u958b\u767c\u65b9\u5f0f\u8a2d\u7f6e"},"content":{"rendered":"<p>\u5728\u524d\u9762\u7684\u4ecb\u7d39\u6587\u7ae0\u4e2d\u6709\u63d0\u5230\u904e\uff0cNodeMCU\u53ef\u4ee5\u4f7f\u7528\u6a19\u6e96\u7684Arduino IDE\u4f86\u958b\u767c\u5176\u61c9\u7528\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u539f\u672c\u5b83\u9810\u8a2d\u7684Lau\u958b\u767c\uff0c\u800c\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\uff0c\u53d7\u6b61\u8fce\u7684Python\u4e5f\u53ef\u4ee5\u7528\u4f86\u7de8\u5bebNodeMCU\u7684\u7a0b\u5f0f\uff0c\u66f4\u68d2\u7684\u662f\uff0c\u9084\u53ef\u4ee5\u4f7f\u7528\u4ea4\u8ac7\u5f0f\u7684\u65b9\u5f0f\u4f86\u7de8\u5beb\u7a0b\u5f0f\uff0c\u4e00\u6b21\u57f7\u884c\u4e00\u500b\u6307\u4ee4\uff0c\u800c\u4e14\u99ac\u4e0a\u770b\u51fa\u7d50\u679c\u3002\u4e0d\u904e\uff0c\u70ba\u4e86\u8981\u80fd\u5920\u9054\u5230\u9019\u6a23\u7684\u74b0\u5883\uff0c\u9084\u6709\u4e00\u4e9b\u5b89\u88dd\u7684\u6b65\u9a5f\u5fc5\u8981\u8981\u5b8c\u6210\uff0c\u9019\u7bc7\u6587\u7ae0\u5c31\u4f86\u6559\u540c\u5b78\u5011\u5982\u4f55\u8a2d\u7f6eNodeMCU\u7684MicroPython\u958b\u767c\u74b0\u5883\u3002<\/p>\n<p>\u9996\u5148\uff0c\u9084\u662f\u8981\u5148\u5b89\u88ddNodeMCU\u7684USB\u9a45\u52d5\u7a0b\u5f0f\uff0c\u9019\u500b\u5728\u7b2c\u4e00\u7bc7\u6587\u7ae0\u4e2d\u5c31\u6709\u6559\u5b78\uff0c\u57fa\u672c\u4e0a\u5c31\u662f\u524d\u5f80\u8a72\u9a45\u52d5\u7a0b\u5f0f\u7684\u7db2\u7ad9\uff0c\u4f9d\u7167\u4f7f\u7528\u7684\u4f5c\u696d\u7cfb\u7d71\u5b89\u88dd\u5408\u9069\u7684\u7a0b\u5f0f\u5c31\u53ef\u4ee5\u4e86\u3002\u5982\u679c\u540c\u5b78\u5011\u4f7f\u7528\u7684\u662fWindows\u4f5c\u696d\u7cfb\u7d71\uff0c\u6703\u5728\u88dd\u7f6e\u7ba1\u7406\u54e1\u4e2d\u770b\u5230\u5b89\u88dd\u597d\u7684\u88dd\u7f6e\uff08\u4e0d\u540c\u7684COM\u57e0\uff09\uff0c\u5982\u679c\u662fMacOS\uff0c\u5247\u53ef\u4ee5\u5728\/dev\u76ee\u9304\u4e0b\u770b\u5230tty.SLAB_USBtoUART\u9019\u500b\u88dd\u7f6e\u3002<\/p>\n<p>\u9a45\u52d5\u7a0b\u5f0f\u5b89\u88dd\u5b8c\u6210\u4e4b\u5f8c\uff0c\u63a5\u4e0b\u4f86\u8981\u628aMicroPython\u6240\u9700\u8981\u7684Firmware\u71d2\u9304\u5230\u677f\u5b50\u4e0a\uff0cFirmware\u53ef\u4ee5\u9019\u500b\u3010<a href=\"http:\/\/micropython.org\/download\/#esp8266\">\u7db2\u5740<\/a>\u3011\u4e2d\u627e\u5230\u3002\u4e0b\u8f09\u7684\u756b\u9762\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.19.32.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2310\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.19.32.png\" alt=\"\" width=\"772\" height=\"262\" \/><\/a><\/p>\n<p>\u8acb\u76f4\u63a5\u9078\u64c7\u6700\u65b0\u7248\u7684\u4e0b\u8f09\u5c31\u53ef\u4ee5\u4e86\u3002\u6709\u4e86\u9019\u500b\u97cc\u9ad4\u6a94\u6848\u4e4b\u5f8c\uff0c\u9084\u8981\u6709\u80fd\u5920\u71d2\u9304\u4e0a\u53bb\u7684\u5de5\u5177\u7a0b\u5f0f\uff0c\u65e2\u7136\u6211\u5011\u6253\u7b97\u4f7f\u7528MicroPython\u958b\u767c\uff0c\u6240\u4ee5\u7576\u7136\u5c31\u662f\u8981\u4f7f\u7528Python\u7684\u71d2\u9304\u5de5\u5177esptool\uff0c\u6b64\u5de5\u5177\u53ea\u8981\u5728Python\u7684\u53ef\u7528\u74b0\u5883\u4e0b\u900f\u904epip install esptool\u5373\u53ef\u9806\u5229\u5b8c\u6210\u5b89\u88dd\u3002<\/p>\n<p>\u7136\u5f8c\uff0c\u900f\u904e\u4ee5\u4e0besptool.py\u547d\u4ee4\u628aNodeMCU\u539f\u6709\u7684\u5167\u5bb9\u62b9\u9664\uff0c\u62b9\u9664\u7684\u904e\u7a0b\u53ca\u8a0a\u606f\u5982\u4e0b\uff08\u4ee5MacOS\u70ba\u4f8b\uff09\uff1a<\/p>\n<p>[code]<br \/>\n$ esptool.py &#8211;port \/dev\/tty.SLAB_USBtoUART erase_flash<br \/>\nesptool.py v2.4.0<br \/>\nConnecting&#8230;&#8230;.._<br \/>\nDetecting chip type&#8230; ESP8266<br \/>\nChip is ESP8266EX<br \/>\nFeatures: WiFi<br \/>\nMAC: 2c:3a:e8:10:dc:bc<br \/>\nUploading stub&#8230;<br \/>\nRunning stub&#8230;<br \/>\nStub running&#8230;<br \/>\nErasing flash (this may take a while)&#8230;<br \/>\nChip erase completed successfully in 12.6s<br \/>\nHard resetting via RTS pin&#8230;<\/p>\n<p>[\/code]<\/p>\n<p>\u4e0b\u9762\u5247\u662fWindows 10\u7684\u4f8b\u5b50\uff1a<\/p>\n<p>[code]<br \/>\n(base) C:\\nodemcu&gt;esptool &#8211;port COM7 erase_flash<br \/>\nesptool.py v2.4.1<br \/>\nSerial port COM7<br \/>\nConnecting&#8230;.<br \/>\nDetecting chip type&#8230; ESP8266<br \/>\nChip is ESP8266EX<br \/>\nFeatures: WiFi<br \/>\nMAC: 60:01:94:43:3a:c9<br \/>\nUploading stub&#8230;<br \/>\nRunning stub&#8230;<br \/>\nStub running&#8230;<br \/>\nErasing flash (this may take a while)&#8230;<br \/>\nChip erase completed successfully in 6.0s<br \/>\nHard resetting via RTS pin&#8230;<br \/>\n[\/code]<\/p>\n<p>\u63a5\u8457\uff0c\u4e5f\u662f\u4f7f\u7528esptool.py\u628a\u525b\u525b\u4e0b\u8f09\u7684\u97cc\u9ad4\u6a94\u6848\u71d2\u9304\u5230NodeMCU\u4e2d\uff0c\u6307\u4ee4\u4ee5\u53ca\u57f7\u884c\u7684\u904e\u7a0b\u5982\u4e0b\u6240\u793a\uff08MacOS\u7248\u672c\uff09\uff1a<\/p>\n<p>[code]<br \/>\n$ esptool.py &#8211;port \/dev\/tty.SLAB_USBtoUART &#8211;baud 460800 write_flash &#8211;flash_size=detect -fm dio 0 esp8266-20180511-v1.9.4.bin<br \/>\nesptool.py v2.4.0<br \/>\nConnecting&#8230;&#8230;.._<br \/>\nDetecting chip type&#8230; ESP8266<br \/>\nChip is ESP8266EX<br \/>\nFeatures: WiFi<br \/>\nMAC: 2c:3a:e8:10:dc:bc<br \/>\nUploading stub&#8230;<br \/>\nRunning stub&#8230;<br \/>\nStub running&#8230;<br \/>\nChanging baud rate to 460800<br \/>\nChanged.<br \/>\nConfiguring flash size&#8230;<br \/>\nAuto-detected Flash size: 4MB<br \/>\nFlash params set to 0x0240<br \/>\nCompressed 604872 bytes to 394893&#8230;<br \/>\nWrote 604872 bytes (394893 compressed) at 0x00000000 in 9.9 seconds (effective 486.7 kbit\/s)&#8230;<br \/>\nHash of data verified.<\/p>\n<p>Leaving&#8230;<br \/>\nHard resetting via RTS pin&#8230;<br \/>\n[\/code]<\/p>\n<p>\u4ee5\u4e0b\u662fWindows 10\u7248\u672c\u7684\u71d2\u9304\u904e\u7a0b\uff1a<\/p>\n<p>[code]<br \/>\n(base) C:\\nodemcu&gt;esptool &#8211;port COM7 &#8211;baud 460800 write_flash &#8211;flash_size=detect -fm dio 0 esp8266-20180511-v1.9.4.bin<br \/>\nesptool.py v2.4.1<br \/>\nSerial port COM7<br \/>\nConnecting&#8230;.<br \/>\nDetecting chip type&#8230; ESP8266<br \/>\nChip is ESP8266EX<br \/>\nFeatures: WiFi<br \/>\nMAC: 60:01:94:43:3a:c9<br \/>\nUploading stub&#8230;<br \/>\nRunning stub&#8230;<br \/>\nStub running&#8230;<br \/>\nChanging baud rate to 460800<br \/>\nChanged.<br \/>\nConfiguring flash size&#8230;<br \/>\nAuto-detected Flash size: 4MB<br \/>\nFlash params set to 0x0240<br \/>\nCompressed 604872 bytes to 394893&#8230;<br \/>\nWrote 604872 bytes (394893 compressed) at 0x00000000 in 9.8 seconds (effective 492.3 kbit\/s)&#8230;<br \/>\nHash of data verified.<\/p>\n<p>Leaving&#8230;<br \/>\nHard resetting via RTS pin&#8230;<br \/>\n[\/code]<\/p>\n<p>\u7136\u5f8c\u5c31\u5b8c\u6210\u4e86\u3002\u4e4b\u5f8c\uff0c\u6bcf\u4e00\u6b21\u8981\u767b\u5165NodeMCU\u7de8\u5bebMicroPython\u7a0b\u5f0f\uff0c\u5728Windows\u4f5c\u696d\u7cfb\u7d71\u4e4b\u4e0b\u53ef\u4ee5\u4f7f\u7528PuTTY\uff0c\u5728MacOS\u4f5c\u696d\u7cfb\u7d71\u4e2d\u5247\u662f\u5230\u7d42\u7aef\u6a5f\u4e2d\u57f7\u884cscreen\u547d\u4ee4\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>[code]<br \/>\n$ screen \/dev\/tty.SLAB_USBtoUART 115200<br \/>\n[\/code]<\/p>\n<p style=\"text-align: left;\">\u7576\u5de6\u4e0a\u89d2\u51fa\u73fe\u4e00\u500b\u65b9\u584a\u6e38\u6a19\u6642\uff0c\u5230NodeMCU\u4e0a\u6309\u4e00\u4e0bRST\u6309\u9215\uff0c\u5f88\u5feb\u5730\u5c31\u6703\u51fa\u73feMicroPython\u7684Shell\u4ecb\u9762\u4e86\uff0c\u5982\u4e0b\u5716\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.38.31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2311\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.38.31.png\" alt=\"\" width=\"730\" height=\"428\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.38.31.png 730w, https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.38.31-300x176.png 300w, https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.38.31-600x352.png 600w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">\u5982\u6b64\u5c31\u51fa\u73fePython\u7684\u6a19\u6e96Shell\u4ecb\u9762\u4e86\u3002\u6709\u4e86\u9019\u500b\u4ecb\u9762\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u5728\u4e0a\u9762\u7de8\u5bebMicroPython\u7a0b\u5f0f\u4e86\u3002\u5982\u4e0b\u5716\u6240\u793a\uff0c\u6211\u5011\u4f7f\u7528MicroPython\u8a9e\u6cd5\u5728Python Shell\u4e2d\u7de8\u5beb\u4e86\u4e00\u500b\u7c21\u55ae\u7684LED\u9583\u720d\u7a0b\u5f0f\uff1a<\/p>\n<p>\u00a0<a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.42.55.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2312 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/screenshot-2018-06-19-\u4e0b\u534810.42.55.png\" alt=\"\" width=\"737\" height=\"468\" \/><\/a><\/p>\n<p>\u5728\u6309\u4e0bEnter\u4e4b\u5f8c\uff0c\u5c31\u53ef\u4ee5\u770b\u5230LED\u5728\u9583\u720d\u4e86\u5594\u3002\u4e0b\u5716\u5247\u662f\u5728Windows 10\u4f5c\u696d\u7cfb\u7d71\u4e4b\u4e0b\u6aa2\u67e5\u76ee\u524d\u9023\u7dda\u7684NodeMCU\u6240\u5728\u4e4bCOM\u4f4d\u7f6e\uff08\u5728\u6b64\u4f8b\u70baCOM7\uff09\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-06-20_09-43-12.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2317 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-06-20_09-43-12.png\" alt=\"\" width=\"679\" height=\"497\" \/><\/a><\/p>\n<p>\u540c\u6a23\u5728Windows 10\u4e4b\u4e0b\uff0c\u4f7f\u7528PuTTY\u9023\u7dda\u7a0b\u5f0f\uff0c\u9700\u9078\u7528Serial\u4ecb\u9762\uff0c\u4e26\u6307\u5b9aCOM7\uff0c\u4ee5\u53ca115200\u50b3\u8f38\u901f\u7387\uff0c\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-06-20_09-45-46.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2318 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-06-20_09-45-46.png\" alt=\"\" width=\"452\" height=\"442\" \/><\/a><\/p>\n<p>\u5982\u4e0a\u5716\uff0c\u6309\u4e0b\u3010Open\u3011\u6309\u9215\u5c31\u53ef\u4ee5\u9806\u5229\u9032\u884c\u9023\u7dda\u9032\u5165MicroPython Shell\u4e86\uff0c\u4ee5\u4e0b\u662f\u5728Windows 10\u4e4b\u4e0b\u900f\u904ePuTTY\u767b\u5165NodeMCU\u7684\u756b\u9762\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-06-20_09-57-34.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2320 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-06-20_09-57-34.png\" alt=\"\" width=\"661\" height=\"418\" \/><\/a><\/p>\n<p>\u6b64\u6642\u5982\u679c\u7121\u6cd5\u8f38\u5165\u4efb\u4f55\u6587\u5b57\u7684\u8a71\uff0c\u8acb\u518d\u5230PuTTY\u7684Serial\u8a2d\u5b9a\u8655\u628a\u6d41\u91cf\u63a7\u5236\u7684\u8a2d\u5b9a\u95dc\u9589\u5c31\u53ef\u4ee5\u4e86\uff0c\u5982\u4e0b\u5716\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-09-03_07-00-39.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2324 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/06\/2018-09-03_07-00-39.png\" alt=\"\" width=\"404\" height=\"360\" \/><\/a><\/p>\n<p>\u56e0\u70baPython\u662f\u76f4\u8b6f\u5f0f\u7684\u8a9e\u8a00\uff0c\u6240\u4ee5\u5b83\u662f\u9010\u884c\u57f7\u884c\u7684\uff0c\u5728Shell\u74b0\u5883\u4e0b\u4e5f\u662f\u8f38\u5165\u4e00\u884c\u5373\u57f7\u884c\u4e00\u884c\uff0c\u5728\u6e2c\u8a66\u4e0a\u975e\u5e38\u65b9\u4fbf\uff0c\u53ef\u4ee5\u76f4\u63a5\u900f\u904e\u6307\u4ee4\u6e2c\u8a66\u786c\u9ad4\u7684\u9023\u7dda\u662f\u5426\u6b63\u78ba\uff0c\u4e0d\u9700\u8981\u50cf\u662fArduino IDE\u4e00\u6a23\uff0c\u8981\u5168\u90e8\u7de8\u8b6f\u5b8c\u6210\u4e0a\u50b3\u4e4b\u5f8c\uff0c\u958b\u59cb\u57f7\u884c\u4e4b\u5f8c\u624d\u80fd\u5920\u77e5\u9053\u7d50\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u524d\u9762\u7684\u4ecb\u7d39\u6587\u7ae0\u4e2d\u6709\u63d0\u5230\u904e\uff0cNodeMCU\u53ef\u4ee5\u4f7f\u7528\u6a19\u6e96\u7684Arduino IDE\u4f86\u958b\u767c\u5176\u61c9\u7528\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u539f\u672c\u5b83\u9810\u8a2d\u7684Lau\u958b\u767c\uff0c\u800c\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\uff0c\u53d7\u6b61\u8fce\u7684Python\u4e5f\u53ef\u4ee5\u7528\u4f86\u7de8\u5bebNodeMCU\u7684\u7a0b\u5f0f\uff0c\u66f4\u68d2\u7684\u662f\uff0c\u9084\u53ef\u4ee5\u4f7f\u7528\u4ea4\u8ac7\u5f0f\u7684\u65b9\u5f0f\u4f86\u7de8\u5beb\u7a0b\u5f0f\uff0c\u4e00\u6b21\u57f7\u884c\u4e00\u500b\u6307\u4ee4\uff0c\u800c\u4e14\u99ac\u4e0a\u770b\u51fa\u7d50\u679c\u3002\u4e0d\u904e\uff0c\u70ba\u4e86\u8981\u80fd\u5920\u9054\u5230\u9019\u6a23\u7684\u74b0\u5883\uff0c\u9084\u6709\u4e00\u4e9b\u5b89\u88dd\u7684\u6b65\u9a5f\u5fc5\u8981\u8981\u5b8c\u6210\uff0c\u9019\u7bc7\u6587\u7ae0\u5c31\u4f86\u6559\u540c\u5b78\u5011\u5982\u4f55\u8a2d\u7f6eNodeMCU\u7684MicroPython\u958b\u767c\u74b0\u5883\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13],"tags":[44],"class_list":["post-2809","post","type-post","status-publish","format-standard","hentry","category-nodemcu","tag-micropython"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=2809"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2809\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}