{"id":80235,"date":"2022-03-07T09:55:00","date_gmt":"2022-03-07T09:55:00","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=80235"},"modified":"2023-09-07T09:17:54","modified_gmt":"2023-09-07T09:17:54","slug":"getting-started-thonny-micropython-python-ide-esp32-esp8266","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/getting-started-thonny-micropython-python-ide-esp32-esp8266\/","title":{"rendered":"Getting Started with Thonny MicroPython (Python) IDE for ESP32 and ESP8266"},"content":{"rendered":"\n<p>If you want to program your ESP32 and ESP8266 with MicroPython firmware, it\u2019s very handy to use an IDE. In this guide, we\u2019ll introduce you to Thonny IDE.&nbsp;After completing this guide, you\u2019ll have your first LED blinking using MicroPython and Thonny IDE.<\/p>\n\n\n\n<!--more-->\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-micropython-esp32-esp8266.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80319\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-micropython-esp32-esp8266.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-micropython-esp32-esp8266.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-micropython-esp32-esp8266.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-micropython-esp32-esp8266.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>We&#8217;ve experimented with several IDEs to program the ESP32 and ESP8266 boards using MicroPython, and Thonny seemed a good choice. Although there are some bugs, it is constantly being updated and improved.<\/p>\n\n\n\n<p>It allows you to program your ESP32 and ESP8266 boards with MicroPython, and it is compatible with Windows, Mac OS X, and Linux. It even comes installed by default on the Raspberry Pi OS. Additionally, it&#8217;s easy to install, so you shouldn\u2019t have problems with the installation process.<\/p>\n\n\n\n<p>Alternatively, you may want to check the following compilation of MicroPython-compatible IDEs:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-ides-esp32-esp8266\/\">MicroPython IDEs for ESP32 and ESP8266<\/a><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"Micropython-Intro\">What is MicroPython?<\/h1>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"250\" height=\"254\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/Micropython-logo.svg-Copy.png?resize=250%2C254&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"MicroPython Logo\" class=\"wp-image-75088\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/Micropython-logo.svg-Copy.png?w=250&amp;quality=100&amp;strip=all&amp;ssl=1 250w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/Micropython-logo.svg-Copy.png?resize=80%2C80&amp;quality=100&amp;strip=all&amp;ssl=1 80w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/figure><\/div>\n\n\n<p>MicroPython is a Python 3 programming language re-implementation targeted for microcontrollers and embedded systems. MicroPython is very similar to regular Python. Apart from a few exceptions, the language features of Python are also available in MicroPython. The most significant difference between Python and MicroPython is that MicroPython was designed to work under constrained conditions.<\/p>\n\n\n\n<p>Because of that, MicroPython does not come with the entire pack of standard libraries. It only includes a small subset of the Python standard libraries, but it includes modules to easily control and interact with the GPIOs, use Wi-Fi, and other communication protocols.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Thonny IDE<\/h2>\n\n\n\n<p>In this guide, we provide instructions to install Thonny IDE in different operating systems, read the section that fits your needs:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A) <a href=\"#install-thonny-ide-windows\">Installing Thonny IDE &#8211; Windows PC<\/a><\/li>\n\n\n\n<li>B) <a href=\"#install-thonny-ide-mac\">Installing Thonny IDE &#8211; Mac OS X<\/a><\/li>\n\n\n\n<li>C) <a href=\"#install-thonny-ide-linux\">Installing Thonny IDE &#8211; Linux<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Tip: <\/strong>Thonny IDE comes installed by default on Raspbian OS that is used with the Raspberry Pi board.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-thonny-ide-windows\">A) Installing Thonny IDE &#8211; Windows PC<\/h3>\n\n\n\n<p>To install Thonny on your Windows PC, follow the next instructions:<\/p>\n\n\n\n<p><strong>1.<\/strong> Go to <a href=\"https:\/\/thonny.org\/\">https:\/\/thonny.org<\/a><\/p>\n\n\n\n<p><strong>2.<\/strong> Download the version for Windows and wait a few seconds while it downloads.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"629\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-download-f.png?resize=750%2C629&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"thony-ide-micropython-windows\" class=\"wp-image-80254\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-download-f.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-download-f.png?resize=300%2C252&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p><strong>3.&nbsp;<\/strong>Run the <em>.exe<\/em> file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"344\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/0-Install-Thonny-Windows.png?resize=466%2C344&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80257\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/0-Install-Thonny-Windows.png?w=466&amp;quality=100&amp;strip=all&amp;ssl=1 466w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/0-Install-Thonny-Windows.png?resize=300%2C221&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 466px) 100vw, 466px\" \/><\/figure><\/div>\n\n\n<p><strong>4. <\/strong>Follow the installation wizard to complete the installation process. You just need to click &#8220;Next&#8221;.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"499\" height=\"387\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/6-Install-Thonny-Windows.png?resize=499%2C387&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80258\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/6-Install-Thonny-Windows.png?w=499&amp;quality=100&amp;strip=all&amp;ssl=1 499w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/6-Install-Thonny-Windows.png?resize=300%2C233&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/figure><\/div>\n\n\n<p><strong>5.<\/strong> After completing the installation, open Thonny IDE. A window as shown in the following figure should open.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"702\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/8-Install-Thonny-Windows.png?resize=802%2C702&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"thony-ide-micropython-windows\" class=\"wp-image-80259\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/8-Install-Thonny-Windows.png?w=802&amp;quality=100&amp;strip=all&amp;ssl=1 802w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/8-Install-Thonny-Windows.png?resize=300%2C263&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/8-Install-Thonny-Windows.png?resize=768%2C672&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"install-thonny-ide-mac\">B) Installing Thonny IDE &#8211; Mac OS X<\/h3>\n\n\n\n<p>Since Thonny IDE is open source and downloaded from the Internet, it&#8217;s not a verified app in the App Store. For security reasons, Mac OS X blocks unknown apps to run on your computer. Follow these next instructions to enable any downloaded software to run in your Mac.<\/p>\n\n\n\n<p><strong>1.<\/strong> Open the &#8220;<strong>System Preferences..<\/strong>.&#8221; menu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"262\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/1-Allow-Apps-to-run-Mac-OS-X-uPyCraft-IDE.png?resize=235%2C262&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-74822\"\/><\/figure><\/div>\n\n\n<p><strong>2.<\/strong> Open the &#8220;<strong>Security &amp; Privacy<\/strong>&#8221; menu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"598\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/2-Allow-Apps-to-run-Security-Privacy-Mac-OS-X-uPyCraft-IDE.png.png?resize=670%2C598&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-74823\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/2-Allow-Apps-to-run-Security-Privacy-Mac-OS-X-uPyCraft-IDE.png.png?w=670&amp;quality=100&amp;strip=all&amp;ssl=1 670w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/2-Allow-Apps-to-run-Security-Privacy-Mac-OS-X-uPyCraft-IDE.png.png?resize=300%2C268&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/figure><\/div>\n\n\n<p><strong>3.<\/strong>&nbsp;At the bottom left corner, click the lock icon to modify your&nbsp;&#8220;Security &amp; Privacy&#8221; settings:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"544\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/3-Allow-Apps-to-run-unlock-computer-Mac-OS-X-uPyCraft-IDE.png.png?resize=670%2C544&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-74824\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/3-Allow-Apps-to-run-unlock-computer-Mac-OS-X-uPyCraft-IDE.png.png?w=670&amp;quality=100&amp;strip=all&amp;ssl=1 670w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/3-Allow-Apps-to-run-unlock-computer-Mac-OS-X-uPyCraft-IDE.png.png?resize=300%2C244&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/figure><\/div>\n\n\n<p><strong>4.<\/strong> Type your username\/password and click the &#8220;<strong>Unlock<\/strong>&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"445\" height=\"232\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/4-Allow-Apps-to-run-unlock-computer-Mac-OS-X-uPyCraft-IDE.png.png?resize=445%2C232&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-74825\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/4-Allow-Apps-to-run-unlock-computer-Mac-OS-X-uPyCraft-IDE.png.png?w=445&amp;quality=100&amp;strip=all&amp;ssl=1 445w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/4-Allow-Apps-to-run-unlock-computer-Mac-OS-X-uPyCraft-IDE.png.png?resize=300%2C156&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/figure><\/div>\n\n\n<p><strong>5.<\/strong> Finally, select the option &#8220;Allow apps downloaded from: <strong>Anywhere<\/strong>&#8220;.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"669\" height=\"542\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/5-Allow-Apps-to-run-from-anywhere-computer-Mac-OS-X-uPyCraft-IDE.png.png?resize=669%2C542&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-74826\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/5-Allow-Apps-to-run-from-anywhere-computer-Mac-OS-X-uPyCraft-IDE.png.png?w=669&amp;quality=100&amp;strip=all&amp;ssl=1 669w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/5-Allow-Apps-to-run-from-anywhere-computer-Mac-OS-X-uPyCraft-IDE.png.png?resize=300%2C243&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 669px) 100vw, 669px\" \/><\/figure><\/div>\n\n\n<p>That&#8217;s it, you can close that window.<\/p>\n\n\n\n<p>To install Thonny on Mac OS X, follow the next instructions:<\/p>\n\n\n\n<p><strong>1.<\/strong> Go to <a href=\"https:\/\/thonny.org\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/thonny.org<\/a><\/p>\n\n\n\n<p><strong>2.<\/strong> Download the version for Mac OS X and wait a few seconds while it downloads.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"629\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-download-mac.png?resize=750%2C629&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80329\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-download-mac.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-download-mac.png?resize=300%2C252&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p><strong>3.<\/strong>&nbsp;Open the <em>.dmg<\/em> file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"172\" height=\"248\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/0-downloading-thonny-ide-mac-os-x.png?resize=172%2C248&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80323\"\/><\/figure><\/div>\n\n\n<p><strong>4.<\/strong> Drag the &#8220;Thonny&#8221; application to your Desktop:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"303\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/1-installing-thonny-ide-mac-os-x.png?resize=500%2C303&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80324\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/1-installing-thonny-ide-mac-os-x.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/1-installing-thonny-ide-mac-os-x.png?resize=300%2C182&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n<p><strong>5.<\/strong> Thonny IDE is now installed and you can double-click to open it:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"226\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/2-installing-thonny-ide-mac-os-x.png?resize=279%2C226&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80325\"\/><\/figure><\/div>\n\n\n<p><strong>6.<\/strong> After the installation is completed, open Thonny IDE. A window as shown in the following figure should open.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"651\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/3-open-thonny-ide-mac-os-x-1.png?resize=727%2C651&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80578\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/3-open-thonny-ide-mac-os-x-1.png?w=727&amp;quality=100&amp;strip=all&amp;ssl=1 727w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/3-open-thonny-ide-mac-os-x-1.png?resize=300%2C269&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"install-thonny-ide-linux\">C) Installing Thonny IDE &#8211; Linux<\/h3>\n\n\n\n<p>To install Thonny on your Linux computer, it depends on your Linux distribution and version, follow the next instructions for your system. First, we recommend installing these dependencies: python3, python3-pip, and python3-tk<\/p>\n\n\n\n<p>If you\u2019re in Ubuntu, you can install the Python dependencies like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install python3 python3-pip python3-tk<\/pre>\n\n\n\n<p>After having Python3, pip3, and Python3 Tkinter, you can install Thonny IDE.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ubuntu (after running that command, you&#8217;ll need to press Enter again to install the software):<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">bash &lt;(wget -O - https:\/\/thonny.org\/installer-for-linux)<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Or you can install Thonny IDE with pip3:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo pip3 install thonny<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Fedora since 27:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo dnf install thonny<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Raspbian since Stretch (installed by default):<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install python3-thonny<\/pre>\n\n\n\n<p>After installing Thonny IDE and depending on your installation method, to open Thonny IDE:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You either need go to the search bar and type &#8220;Thonny&#8221; to find it<\/li>\n\n\n\n<li>Or if you installed Thonny IDE using pip3, you can type in your terminal window:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">thonny<\/pre>\n\n\n\n<p>Then, it should open Thonny IDE:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"646\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/linux-thonny.png?resize=720%2C646&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80402\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/linux-thonny.png?w=720&amp;quality=100&amp;strip=all&amp;ssl=1 720w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/linux-thonny.png?resize=300%2C269&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Flashing MicroPython Software<\/h2>\n\n\n\n<p>MicroPython isn\u2019t flashed onto the ESP32 or ESP8266 boards by default. The first thing you need to do to start programming your boards with MicroPython is flash\/upload\/burn the firmware.<\/p>\n\n\n\n<p>There are different ways in which you can do that. Thonny IDE comes with a tool that allows you to quickly install MicroPython firmware on your board. Another method is using esptool\u2014check <a href=\"https:\/\/randomnerdtutorials.com\/flashing-micropython-firmware-esptool-py-esp32-esp8266\/\">this tutorial to burn MicroPython firmware with esptool.py<\/a> if you have trouble flashing the firmware with Thonny IDE.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Downloading MicroPython Firmware<\/h3>\n\n\n\n<p>Go to the MicroPython Downloads page: <a href=\"https:\/\/micropython.org\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/micropython.org\/download\/<\/a>.<\/p>\n\n\n\n<p>Select the type of board you\u2019re using. Here are the quick links for \u201cregular\u201d ESP32 and ESP8266 boards:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/micropython.org\/download\/esp32\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 MicroPython firmware<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/micropython.org\/download\/esp8266\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266 MicroPython firmware<\/a><\/li>\n<\/ul>\n\n\n\n<p>You should see a similar web page (see figure below) with links to download <span class=\"rnthl rntliteral\">.bin<\/span> files. Download the latest release.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"461\" height=\"538\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/Download-Micropython-firmware.png?resize=461%2C538&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Download MicroPython Firmware\" class=\"wp-image-108999\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/Download-Micropython-firmware.png?w=461&amp;quality=100&amp;strip=all&amp;ssl=1 461w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/Download-Micropython-firmware.png?resize=257%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 257w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><\/figure><\/div>\n\n\n<p>At the time of writing this article, the latest release is <strong><em>v1.17 (2021-09-02).bin<\/em><\/strong> for the ESP32 and ESP8266 boards. Don\u2019t download the Nightly builds; those versions are not stable and are only recommended for advanced programmers.<\/p>\n\n\n\n<p>The downloaded file will probably go to the <em>Downloads<\/em> folder. Continue reading to learn how to flash the firmware on your boards.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Flashing MicroPython Firmware using Thonny IDE<\/h3>\n\n\n\n<p>In this section, you\u2019ll learn how to flash MicroPython firmware on your boards using Thonny IDE. Follow the next steps: <\/p>\n\n\n\n<p><strong>1)<\/strong> Connect your ESP32 or ESP8266 board to your computer. <\/p>\n\n\n\n<p><strong>2)<\/strong> Open Thonny IDE. Go to <strong>Tools <\/strong>&gt; <strong>Options <\/strong>&gt; <strong>Interpreter<\/strong>.<\/p>\n\n\n\n<p><strong>3)<\/strong> Select the interpreter you want to use accordingly to the board you&#8217;re using and select the COM port your board is connected to. Finally, click on the link <strong>Install or update firmware<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"505\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/flash-micropython-firmware-thonny-ide-1.png?resize=651%2C505&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Flash MicroPython Firmware Thonny IDE\" class=\"wp-image-109718\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/flash-micropython-firmware-thonny-ide-1.png?w=651&amp;quality=100&amp;strip=all&amp;ssl=1 651w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/flash-micropython-firmware-thonny-ide-1.png?resize=300%2C233&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/figure><\/div>\n\n\n<p><strong>4)<\/strong> Select the port once again, and then click on the <strong>Browse <\/strong>button to open the <span class=\"rnthl rntliteral\">.bin<\/span> file with the firmware you&#8217;ve downloaded on the previous step. Select the options as shown in the picture below and finally click on <strong>Install<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"429\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/ESP-firmware-installer-thonny-ide.png?resize=541%2C429&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP Firmware Flasher Thonny IDE\" class=\"wp-image-109719\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/ESP-firmware-installer-thonny-ide.png?w=541&amp;quality=100&amp;strip=all&amp;ssl=1 541w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/ESP-firmware-installer-thonny-ide.png?resize=300%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><\/figure><\/div>\n\n\n<p>After a few seconds, the installation should be completed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Installation<\/h2>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Important: <\/strong>before testing the installation, your ESP32\/ESP8266 board needs to be flashed with MicroPython firmware (see the previous step).<\/p>\n\n\n\n<p>Connect the board to your computer using a USB cable. To test the installation, you need to tell Thonny that you want to run MicroPython Interpreter and select the board you are using.<\/p>\n\n\n\n<p><strong>1.<\/strong> Go to <strong>Tools<\/strong> &gt; <strong>Options<\/strong> and select the <strong>Interpreter<\/strong> tab. Make sure you&#8217;ve selected the right interpreter for your board as well as the COM port.<\/p>\n\n\n\n<p>You can also select the &#8220;<strong>Try to detect automatically<\/strong>&#8221; option, but <em>only<\/em> if you just have one board connected to your computer at a time. Otherwise, select the specific port for the board you\u2019re using.<\/p>\n\n\n\n<p><strong>2.<\/strong> Thonny IDE should now be connected to your board and you should see the prompt on the Shell.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"690\" height=\"554\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/3-thonny-ide-window-generic-micropython.png?resize=690%2C554&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80380\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/3-thonny-ide-window-generic-micropython.png?w=690&amp;quality=100&amp;strip=all&amp;ssl=1 690w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/3-thonny-ide-window-generic-micropython.png?resize=300%2C241&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/figure><\/div>\n\n\n<p><strong>3.<\/strong> Type the command&nbsp;<strong>help()<\/strong>&nbsp;in the Shell and see if it responds back.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"544\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-help.png?resize=621%2C544&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80268\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-help.png?w=621&amp;quality=100&amp;strip=all&amp;ssl=1 621w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-help.png?resize=300%2C263&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/figure><\/div>\n\n\n<p>If it responded back, everything is working fine. Now, you can send a few more commands to test.<\/p>\n\n\n\n<p>Send the following commands to light up the on-board LED<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; from machine import Pin\n&gt;&gt;&gt; Pin(2, Pin.OUT).value(1)<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"544\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-light-up-led.png?resize=621%2C544&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80270\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-light-up-led.png?w=621&amp;quality=100&amp;strip=all&amp;ssl=1 621w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-light-up-led.png?resize=300%2C263&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/figure><\/div>\n\n\n<p>If you\u2019re using an ESP8266, the logic to turn on the LED works the other way around, so you should send the following command instead:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; Pin(2, Pin.OUT).value(0)<\/pre>\n\n\n\n<p>The on-board LED should light up.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 board Built in LED turned on HIGH\" class=\"wp-image-96167\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<p>Then, turn off the led like this for the ESP32:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; Pin(2, Pin.OUT).value(0)<\/pre>\n\n\n\n<p>And like this for the ESP8266:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">>>> Pin(2, Pin.OUT).value(1)<\/pre>\n\n\n\n<p>Congratulations! Your installation was successful!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Thonny IDE Overview<\/h2>\n\n\n\n<p>At this point, you should have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Thonny IDE installed on your computer<\/li>\n\n\n\n<li>ESP32\/ESP8266 flashed with MicroPython firmware<\/li>\n<\/ul>\n\n\n\n<p>Open Thonny IDE. There are two different sections: the <strong>Editor<\/strong> and the <strong>MicroPython Shell\/Terminal<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"609\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-Copy.png?resize=768%2C609&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80287\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-Copy.png?w=768&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-Copy.png?resize=300%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>Editor<\/strong> section is where you write your code and edit your <em>.py<\/em> files. You can open more than one file, and the Editor will open a new tab for each file.<\/li>\n\n\n\n<li>On the <strong>MicroPython Shel<\/strong>l you can type commands to be executed immediately by your ESP board without the need to upload new files. The terminal also provides information about the state of an executing program, shows errors related with upload, syntax errors, prints messages, etc\u2026<\/li>\n<\/ul>\n\n\n\n<p>You can also customize Thonny IDE to show other useful tabs. Go to <strong>View<\/strong> and you can select several tabs that provide more information.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"544\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-view.png?resize=621%2C544&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80288\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-view.png?w=621&amp;quality=100&amp;strip=all&amp;ssl=1 621w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-view.png?resize=300%2C263&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/figure><\/div>\n\n\n<p>Something that could be very useful is the <strong>Variables<\/strong> tab. It lists all available variables in your program and their corresponding values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Running Your First Script<\/h2>\n\n\n\n<p>To get you familiar with the process of writing a file and executing code on your ESP32\/ESP8266 boards, we\u2019ll upload a new script that simply blinks the on-board LED of your ESP32 or ESP8266.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating the main.py file on your board<\/h3>\n\n\n\n<p><strong>1.<\/strong> When you open Thonny IDE for the first time, the Editor shows an untitled file. Save that file as <em>main.py<\/em> by clicking on the <strong>save<\/strong> icon. Select the &#8220;<strong>This computer<\/strong>&#8221; option. We recommend saving the file inside a folder with a name that identifies the project, for example <em>Blink<\/em>. The file must be called <span class=\"rnthl rntliteral\">main.py<\/span>. Otherwise, it will not work.<\/p>\n\n\n\n<p><strong>2.<\/strong> The Editor should now have a tab called <span class=\"rnthl rntliteral\">main.py<\/span>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"465\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-main-py.png?resize=621%2C465&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80291\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-main-py.png?w=621&amp;quality=100&amp;strip=all&amp;ssl=1 621w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-main-py.png?resize=300%2C225&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/figure><\/div>\n\n\n<p><strong>3.<\/strong> Copy the following code to the <span class=\"rnthl rntliteral\">main.py<\/span> file:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from machine import Pin\nfrom time import sleep\nled = Pin(2, Pin.OUT)\nwhile True:\n  led.value(not led.value())\n  sleep(0.5)<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"503\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-main-py-2.png?resize=595%2C503&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80292\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-main-py-2.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-main-py-2.png?resize=300%2C254&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Uploading the Script<\/h2>\n\n\n\n<p><strong>1)<\/strong> Go to <strong>File<\/strong> &gt; <strong>Save as\u2026<\/strong> or click on the <strong>save <\/strong>icon. The following window will open.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/save-micropython-device-thonny-ide.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"220\" height=\"202\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/save-micropython-device-thonny-ide.png?resize=220%2C202&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE Save to MicroPython Device\" class=\"wp-image-109022\"\/><\/a><\/figure><\/div>\n\n\n<p><strong>2)<\/strong> Select <strong>MicroPython device<\/strong>.<\/p>\n\n\n\n<p><strong>3)<\/strong> Name the file <span class=\"rnthl rntliteral\">main.py<\/span>, otherwise, it won\u2019t work. Notice that the window that pops up shows the files currently saved on the board filesystem. There should be a file called <span class=\"rnthl rntliteral\">boot.py<\/span>. That file is created by default when you burn MicroPython firmware.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/save-main-py-thonny-device.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"553\" height=\"409\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/save-main-py-thonny-device.png?resize=553%2C409&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE Save main.py File\" class=\"wp-image-109023\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/save-main-py-thonny-device.png?w=553&amp;quality=100&amp;strip=all&amp;ssl=1 553w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/01\/save-main-py-thonny-device.png?resize=300%2C222&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong>4)<\/strong> Finally, click <strong>Ok <\/strong>to proceed.<\/p>\n\n\n\n<p><strong>5)<\/strong> Now, press the on-board RST\/EN button so that the board restarts and starts running the code.<\/p>\n\n\n\n<p><strong>6)<\/strong> Now, your board should be blinking the blue on-board LED every 500 milliseconds. <\/p>\n\n\n\n<p>The following figure shows the ESP32 on-board LED light up.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 board Built in LED turned on HIGH\" class=\"wp-image-96167\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>And the following figure shows the ESP8266.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-88063\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting Tips for Thonny IDE<\/h2>\n\n\n\n<p>We&#8217;ve discovered some common problems and error messages that occur with Thonny IDE. Usually restarting your ESP with the on-board EN\/RST button fixes your problem. Or press the Thonny IDE &#8220;<strong>Stop\/Restart backend<\/strong>&#8221; button and repeat your desired action. In case it doesn\u2019t work for you, read these next common errors and discover how to solve them.<\/p>\n\n\n\n<p><strong>Error #1:<\/strong> You get one of the following messages:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">========================= RESTART =========================\nUnable to connect to COM4\nError: could not open port 'COM4': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)\n\nCheck the configuration, select Run \u2192 Stop\/Restart or press Ctrl+F2 to try again. (On some occasions it helps to wait before trying again.)<\/pre>\n\n\n\n<p>Or:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">========================= RESTART =========================\nCould not connect to REPL.\nMake sure your device has suitable firmware and is not in bootloader mode!\nDisconnecting.<\/pre>\n\n\n\n<p>Or:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">========================= RESTART =========================\nLost connection to the device (EOF).<\/pre>\n\n\n\n<p>Unplug, and plug back your ESP board. Then, double-check that you&#8217;ve selected the right serial port in the <strong>Tools<\/strong> &gt; <strong>Options<\/strong> &gt; <strong>Interpreter<\/strong> &gt; <strong>Port<\/strong>. Then, click the &#8220;<strong>Stop\/Restart backend<\/strong>&#8221; button to establish a serial communication. You should now be able to upload a new script or re-run new code.<\/p>\n\n\n\n<p>These errors might also mean that you have your serial port being used in another program (like a serial terminal or in the Arduino IDE). Double-check that you&#8217;ve closed all the programs that might be establishing a serial communication with your ESP board. Then,&nbsp;unplug and plug back your ESP board. Finally, restart Thonny IDE.<\/p>\n\n\n\n<p><strong>Error #2:<\/strong>&nbsp;Thonny IDE fails to respond or gives an Internal Error:<\/p>\n\n\n\n<p>When this happens, you can usually close that window and it will continue to work. If it keeps crashing, we recommend restarting the Thonny IDE software.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"551\" height=\"296\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-internal-error.png?resize=551%2C296&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80554\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-internal-error.png?w=551&amp;quality=100&amp;strip=all&amp;ssl=1 551w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-internal-error.png?resize=300%2C161&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-internal-error.png?resize=280%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 280w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/figure><\/div>\n\n\n<p><strong>Error #3:<\/strong>&nbsp;Thonny IDE hangs when pressing &#8220;<strong>Stop\/Restart backend<\/strong>&#8221; button:<\/p>\n\n\n\n<p>When you press the &#8220;Stop\/Restart backend&#8221; button, you need to wait a few seconds. The ESP needs time to restart and establish the serial communication with Thonny IDE. If you press the &#8220;Stop&#8221; button multiple times or if you press the button very quickly, the ESP will not have enough time to restart properly and it&#8217;s very likely to crash Thonny IDE.<\/p>\n\n\n\n<p><strong>Error #4: <\/strong>Problem restarting your ESP board, running a new script, or opening the serial port:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Brownout detector was triggered<\/pre>\n\n\n\n<p>Or if the ESP keeps restarting and printing the ESP boot information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ets Jun 8 2016 00:22:57 \n\nrst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) \nconfigsip: 0, SPIWP:0xee \nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 \nmode:DIO, clock div:2 \nload:0x3fff0018,len:4 \nload:0x3fff001c,len:4732 \nload:0x40078000,len:7496 \nload:0x40080400,len:5512<\/pre>\n\n\n\n<p>The &#8220;Brownout detector was triggered&#8221; error message or constant reboots means that there&#8217;s some sort of hardware problem. It&#8217;s often related to one of the following issues:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Poor quality USB cable;<\/li>\n\n\n\n<li>USB cable is too long;<\/li>\n\n\n\n<li>Board with some defect (bad solder joints);<\/li>\n\n\n\n<li>Bad computer USB port;<\/li>\n\n\n\n<li>Or not enough power provided by the computer USB port.<\/li>\n<\/ul>\n\n\n\n<p><strong>Solution:<\/strong> try a different shorter USB cable (with data wires), try a different computer USB port or use a USB hub with an external power supply.<\/p>\n\n\n\n<p><span style=\"color: #ff0000;\"><strong>Important:<\/strong><\/span>&nbsp;if you keep having constant problems or weird error messages, we recommend re-flashing your ESP board with the latest version of MicroPython firmware.<\/p>\n\n\n\n<p><strong>Error #5:&nbsp;<\/strong>When I try to establish a serial communication with the ESP32\/ESP8266 in Thonny IDE, I can&#8217;t get it to connect.<\/p>\n\n\n\n<p>We think this is what\u2019s happening: when you\u2019re running a script in your board, sometimes it\u2019s busy running that script and performing the tasks.<\/p>\n\n\n\n<p>So, you need to try start the connection by pressing &#8220;<strong>Stop\/Restart backend<\/strong>&#8221; button multiple times or restart the ESP to catch available to establish the serial communication.<\/p>\n\n\n\n<p><strong><span style=\"color: #ff0000;\">Warning:&nbsp;<\/span><\/strong>don&#8217;t press the &#8220;<strong>Stop\/Restart backend<\/strong>&#8221; button multiple times very quickly. After pressing that button, you need to be patient and wait a few seconds for the command to run.<\/p>\n\n\n\n<p>If you\u2019re running a script that uses Wi-Fi, deep sleep, or it&#8217;s doing multiple tasks, I recommend trying 3 or 4 times to establish the communication. If you can\u2019t, I recommend re-flash the ESP with MicroPython firmware.<strong><br><\/strong><\/p>\n\n\n\n<p><strong>Error #6:<\/strong>&nbsp;debug tools are grayed out:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"264\" height=\"290\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-debug-tools.png?resize=264%2C290&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-80559\"\/><\/figure><\/div>\n\n\n<p><strong>Thonny IDE debug tools aren&#8217;t available for MicroPython.<\/strong> The debug tools are only available for the Python Interpreter, so being&nbsp;grayed out is the expected behavior.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>Thonny IDE is a great IDE to program the ESP32 and ESP8266 boards using MicroPython. It is compatible with Windows, Mac OS X, and Linux and it is easy to install.<\/p>\n\n\n\n<p>We have an article with a compilation of several MicroPython IDEs compatible with the ESP32 and ESP8266 boards that you can check below:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-ides-esp32-esp8266\/\">MicroPython IDEs for ESP32 and ESP8266<\/a><\/li>\n<\/ul>\n\n\n\n<p>More tutorials about MicroPython with ESP32 and ESP8266:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-basics-esp32-esp8266\/\">MicroPython Programming Basics with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-gpios-esp32-esp8266\/\">MicroPython with ESP32 and ESP8266: Interacting with GPIOs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">ESP32\/ESP8266 MicroPython Web Server<\/a><\/li>\n<\/ul>\n\n\n\n<p>Learn more about MicroPython with our eBook:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with ESP32 and ESP8266 eBook<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to program your ESP32 and ESP8266 with MicroPython firmware, it\u2019s very handy to use an IDE. In this guide, we\u2019ll introduce you to Thonny IDE.&nbsp;After completing this &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Getting Started with Thonny MicroPython (Python) IDE for ESP32 and ESP8266\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/getting-started-thonny-micropython-python-ide-esp32-esp8266\/#more-80235\" aria-label=\"Read more about Getting Started with Thonny MicroPython (Python) IDE for ESP32 and ESP8266\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":80319,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,265,310,309,264],"tags":[],"class_list":["post-80235","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp8266-project","category-micropython","category-0-esp32-micropython","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/01\/thonny-ide-micropython-esp32-esp8266.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/80235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=80235"}],"version-history":[{"count":4,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/80235\/revisions"}],"predecessor-version":[{"id":135296,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/80235\/revisions\/135296"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/80319"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=80235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=80235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=80235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}