{"id":223,"date":"2017-05-10T06:55:00","date_gmt":"2017-05-10T13:55:00","guid":{"rendered":"http:\/\/www.kenwalger.com\/blog\/?p=223"},"modified":"2017-05-27T17:04:05","modified_gmt":"2017-05-28T00:04:05","slug":"micropython-webrepl-esp8266","status":"publish","type":"post","link":"https:\/\/www.kenwalger.com\/blog\/iot\/micropython-webrepl-esp8266\/","title":{"rendered":"MicroPython&#8217;s WebREPL on the ESP8266"},"content":{"rendered":"<p>The NodeMCU ESP8266 device has built in WiFi. This allows us to, among other things, connect to the device through it&#8217;s own network to run commands. I walked through how connecting to a MicroPython enabled <a href=\"https:\/\/www.amazon.com\/gp\/product\/B01N0B48NI\/ref=as_li_tl?ie=UTF8&amp;tag=kenwalgersite-20&amp;camp=1789&amp;creative=9325&amp;linkCode=as2&amp;creativeASIN=B01N0B48NI&amp;linkId=dc1e9f82e2beb42bca36616a22b8820d\">NodeMCU<\/a> device is accomplished through the serial port in <a href=\"http:\/\/www.kenwalger.com\/blog\/iot\/micropython-and-nodemcu-esp8266\/\">this post<\/a>. I&#8217;d\u00a0like to take a look now how to utilize another access feature that pairing MicroPython with an ESP8266 device allows, the WebREPL.<\/p>\n<p>The WebREPL is a web based interface for the Read-Evaluate-Print-Loop (REPL) which allows for running commands on the ESP8266 in the same fashion as the terminal REPL does. However, since it is done through a wireless network connection it opens up some additional freedom for access. Of course having a device up and running on a network also poses some potential security issues, but we&#8217;ll look at those in another post.<\/p>\n<h3>Enable WebREPL<\/h3>\n<p>First thing first though, let&#8217;s assume that MicroPython is running on an ESP8266 device and you have a serial connection to the device. Again, have a look at my post <a href=\"http:\/\/www.kenwalger.com\/blog\/iot\/micropython-and-nodemcu-esp8266\/\">here<\/a> for that walk through. Assuming that you have flashed the ESP8266 with the latest version of MicroPython, version 1.8.7 as of this writing, the WebREPL must be enabled through the serial interface. It is a one line command to do from a command prompt:<\/p>\n<pre>import webrepl_setup\n<\/pre>\n<p>Entering in this command will produce a series of setup prompts, asking if you want WebREPL to be enabled at boot time, to set a password for the WebREPL, and to confirm rebooting the device to activate the changes.<\/p>\n<h3>Connect to Network<\/h3>\n<p>Once the system reboots you\u00a0can connect to the device via WiFi. This is one of the neat features of these devices. If the board doesn&#8217;t connect to a wireless access point, it creates one for us. One\u00a0can then connect to it via our computer or other wireless device. Look for an advertised WiFi network with a name of\u00a0<strong>MicroPython-<em><\/strong>. The\u00a0<strong><\/em><\/strong> will be a set of letters and numbers unique to each device.<\/p>\n<h3>Set Password<\/h3>\n<p>Upon selecting the device&#8217;s network you will need a password. The network password for the access point is\u00a0<strong>micropythoN<\/strong> (note the capitalization of the last letter there). You should then be connected to the device&#8217;s network, congratulations!<\/p>\n<p>Now in many situations one could simply browse to the device&#8217;s IP address in a browser and get some form of web page, such as our WebREPL interface. Remember that we are dealing with a device with limited memory here and, therefore, doesn&#8217;t have the actual webpage. Instead it provides a convenient websocket interface which can be used with the WebREPL Client. You can download it below:<\/p>\n<p><a href=\"https:\/\/github.com\/micropython\/webrepl\/archive\/master.zip\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"242\" data-permalink=\"https:\/\/www.kenwalger.com\/blog\/iot\/micropython-webrepl-esp8266\/attachment\/webrepl-btn\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-btn-e1493758180436.png?fit=183%2C75&amp;ssl=1\" data-orig-size=\"183,75\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"webrepl-btn\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-btn-e1493758180436.png?fit=300%2C123&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-btn-e1493758180436.png?fit=183%2C75&amp;ssl=1\" class=\"aligncenter wp-image-242 size-full\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-btn-e1493758180436.png?resize=183%2C75\" alt=\"Download MicroPython WebREPL Client\" width=\"183\" height=\"75\" \/><\/a><\/p>\n<p>Once downloaded and unzipped you&#8217;ll want to open <code>webrepl.html<\/code> in either Chrome or Firefox (the browsers currently supported by WebREPL) You should see a screen similar to:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"243\" data-permalink=\"https:\/\/www.kenwalger.com\/blog\/iot\/micropython-webrepl-esp8266\/attachment\/webrepl-screenshot\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?fit=1770%2C966&amp;ssl=1\" data-orig-size=\"1770,966\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"webrepl-screenshot\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?fit=300%2C164&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?fit=840%2C459&amp;ssl=1\" class=\"alignnone wp-image-243\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot-300x164.png?resize=600%2C328\" alt=\"\" width=\"600\" height=\"328\" srcset=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?resize=300%2C164&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?resize=768%2C419&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?resize=1024%2C559&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?resize=1200%2C655&amp;ssl=1 1200w, https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?w=1770&amp;ssl=1 1770w, https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/05\/webrepl-screenshot.png?w=1680&amp;ssl=1 1680w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>With your computer is connected to the device on the MicroPython network and using the default IP address and port of\u00a0<strong>ws:\/\/192.168.4.1:8266<\/strong> you can select the\u00a0<em>Connect<\/em> button to start a WebREPL session.<\/p>\n<p>You should see a prompt to enter your password, which is the one you set after enabling the WebREPL service on the device earlier. Once logged into the device you have access to the REPL just like you would from a serial connection.<\/p>\n<p>Congratulations! You have just connected a NodeMCU ESP8266 to a wireless network with MicroPython. Not too horrible of a task, right?<\/p>\n<hr \/>\n<p>Follow me on Twitter <a href=\"https:\/\/www.twitter.com\/kenwalger\">@kenwalger<\/a> to get the latest updates on my postings on MicroPython and IoT.<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F223&#038;t=MicroPython%E2%80%99s%20WebREPL%20on%20the%20ESP8266&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F223&#038;p&#091;images&#093;&#091;0&#093;=https%3A%2F%2Fi0.wp.com%2Fwww.kenwalger.com%2Fblog%2Fwp-content%2Fuploads%2F2017%2F04%2Fmicro-python-e1493094682987.png%3Ffit%3D125%252C125%26ssl%3D1&#038;p&#091;title&#093;=MicroPython%E2%80%99s%20WebREPL%20on%20the%20ESP8266\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/facebook.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F223&#038;text=Hey%20check%20this%20out\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/twitter.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-reddit nolightbox\" data-provider=\"reddit\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Reddit\" href=\"https:\/\/www.reddit.com\/submit?url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F223&#038;title=MicroPython%E2%80%99s%20WebREPL%20on%20the%20ESP8266\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"reddit\" title=\"Share on Reddit\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/reddit.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F223&#038;title=MicroPython%E2%80%99s%20WebREPL%20on%20the%20ESP8266\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/linkedin.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=MicroPython%E2%80%99s%20WebREPL%20on%20the%20ESP8266&#038;body=Hey%20check%20this%20out:%20https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F223\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/mail.png?resize=48%2C48&#038;ssl=1\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>The NodeMCU ESP8266 device has built in WiFi. This allows us to, among other things, connect to the device through it&#8217;s own network to run commands. I walked through how connecting to a MicroPython enabled NodeMCU device is accomplished through the serial port in this post. I&#8217;d\u00a0like to take a look now how to utilize &hellip; <a href=\"https:\/\/www.kenwalger.com\/blog\/iot\/micropython-webrepl-esp8266\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MicroPython&#8217;s WebREPL on the ESP8266&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":197,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pmpro_default_level":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[27,28],"tags":[36,35,41],"yst_prominent_words":[246,278,255,273,284,249,274,281,276,257,275,239,256,279,283,244,280,247,282,277],"class_list":["post-223","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-iot","category-micropython","tag-esp8266","tag-nodemcu","tag-webrepl","pmpro-has-access"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.kenwalger.com\/blog\/wp-content\/uploads\/2017\/04\/micro-python-e1493094682987.png?fit=125%2C125&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8lx70-3B","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":15,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":341,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions\/341"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/media\/197"}],"wp:attachment":[{"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/tags?post=223"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.kenwalger.com\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}