{"id":80235,"date":"2025-10-10T09:57:09","date_gmt":"2025-10-10T09:57:09","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=80235"},"modified":"2026-02-09T16:55:08","modified_gmt":"2026-02-09T16:55:08","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<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Getting Started with Thonny MicroPython (Python) IDE for ESP32 and ESP8266\" class=\"wp-image-180937\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgray\"><em>Updated October 10, 2025.<\/em><\/p>\n\n\n\n<p>We&#8217;ve experimented with several IDEs to program the ESP32 and ESP8266 boards using MicroPython, and Thonny IDE is our preference.<\/p>\n\n\n\n<p>It allows you to program your ESP32, ESP8266, Raspberry Pi Pico, and other boards with MicroPython. It is compatible with Windows, Mac OS X, and Linux. It 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 is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"250\" height=\"250\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?resize=250%2C250&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"micorpython logo\" class=\"wp-image-148797\" style=\"width:166px;height:auto\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?w=250&amp;quality=100&amp;strip=all&amp;ssl=1 250w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" 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. Follow the section for the operating system you&#8217;re using.<\/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 the Raspberry Pi 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 Installer for Windows and wait a few seconds while it downloads.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"712\" height=\"729\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/download-thonny-ide-for-windows.png?resize=712%2C729&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Donwload Thonny IDE for windows\" class=\"wp-image-180838\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/download-thonny-ide-for-windows.png?w=712&amp;quality=100&amp;strip=all&amp;ssl=1 712w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/download-thonny-ide-for-windows.png?resize=293%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 293w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/figure><\/div>\n\n\n<p><strong>3.&nbsp;<\/strong>Run the <em>.exe<\/em> file.<\/p>\n\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 size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"499\" height=\"392\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Installing-Thonny-IDE-Windows.png?resize=499%2C392&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing Thonny IDE on windows\" class=\"wp-image-180839\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Installing-Thonny-IDE-Windows.png?w=499&amp;quality=100&amp;strip=all&amp;ssl=1 499w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Installing-Thonny-IDE-Windows.png?resize=300%2C236&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 size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"617\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/opening-thonny-ide.png?resize=688%2C617&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE Window\" class=\"wp-image-180840\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/opening-thonny-ide.png?w=688&amp;quality=100&amp;strip=all&amp;ssl=1 688w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/opening-thonny-ide.png?resize=300%2C269&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/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 size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"712\" height=\"729\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/download-thonny-ide-for-mac.png?resize=712%2C729&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Download Thonny IDE For MAC\" class=\"wp-image-180842\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/download-thonny-ide-for-mac.png?w=712&amp;quality=100&amp;strip=all&amp;ssl=1 712w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/download-thonny-ide-for-mac.png?resize=293%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 293w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/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. That&#8217;s the method we&#8217;ll use in this tutorial.<\/p>\n\n\n\n<p class=\"rntbox rntclgray\"><strong>Note<\/strong>: flashing your boards with MicroPython is reversible. This means that after you flash the ESP32\/ESP8266 with MicroPython, you can still use Arduino IDE in the future. You just need to upload a code using the Arduino IDE to your board.<\/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 MicroPython<\/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=\"560\" height=\"558\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-Interpreter-Install-Update-Firmware.png?resize=560%2C558&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE Interpreter - Install or Update Firmware\" class=\"wp-image-180843\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-Interpreter-Install-Update-Firmware.png?w=560&amp;quality=100&amp;strip=all&amp;ssl=1 560w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-Interpreter-Install-Update-Firmware.png?resize=300%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Thonny-IDE-Interpreter-Install-Update-Firmware.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure><\/div>\n\n\n<p><strong>4) <\/strong>Then, select the port once again, the board you\u2019re using, and the variant. It will automatically pick up the most recent MicroPython firmware version\u2014see the screenshot below. Finally, you can click <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=\"560\" height=\"550\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Install-MicroPython-Thonny-IDE-esptool.png?resize=560%2C550&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Install MicroPython Firmware esptool\" class=\"wp-image-180844\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Install-MicroPython-Thonny-IDE-esptool.png?w=560&amp;quality=100&amp;strip=all&amp;ssl=1 560w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/Install-MicroPython-Thonny-IDE-esptool.png?resize=300%2C295&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntcred\"><strong>Note<\/strong>: On some ESP8266 boards, you may need to try different options for the<strong> Flash mode<\/strong> and select <em>detect <\/em>for the <strong>Flash size<\/strong>.<\/p>\n\n\n\n<p>After a few seconds, the installation should be completed. If you\u2019re using an ESP32, you may need to press the BOOT button for a few seconds after clicking the <em>Install <\/em>button.<\/p>\n\n\n\n<p>5) When the installation is completed, you can close the window. You should get the following message on the Shell (see the picture below), and at the bottom right corner, it should have the Interpreter it\u2019s using and the COM port.<\/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=\"688\" height=\"617\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/thonny-ide-micropython-installed-on-ESP32.png?resize=688%2C617&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE, Micropython successfully installed on Thonny IDE\" class=\"wp-image-180846\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/thonny-ide-micropython-installed-on-ESP32.png?w=688&amp;quality=100&amp;strip=all&amp;ssl=1 688w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/thonny-ide-micropython-installed-on-ESP32.png?resize=300%2C269&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgray\"><strong>Troubleshooting:<\/strong><br>If it doesn\u2019t recognize the device, and you have a message saying \u201cno backend\u201d in the bottom-right corner, it may be the case that it is not detecting the COM port automatically. If that\u2019s the case, go to <strong>Tools <\/strong>&gt; <strong>Options <\/strong>&gt; <strong>Interpreter <\/strong>and select the COM port manually. After that, it should recognize the MicroPython device, and you should get the previous message.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The REPL<\/h3>\n\n\n\n<p>You should also see the <strong>&gt;&gt;&gt; <\/strong>symbol (if you don\u2019t, click on the <strong>Stop <\/strong>icon at the top).<\/p>\n\n\n\n<p>This symbol represents the MicroPython REPL (Read-Eval-Print-Loop) prompt. This symbol means you\u2019re interacting with MicroPython (the board with MicroPython firmware installed) in interactive mode in real time. This simply means that you can enter and execute commands directly. Let\u2019s test it in the next section<\/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>Type <span class=\"rnthl rntliteral\">help()<\/span> in the Shell after the prompt <strong>&gt;&gt;&gt; <\/strong>and see if your device responds.<\/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=\"582\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/ESP32-help-command-thonny-ide.png?resize=651%2C582&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 help command in MicroPython using Thonny IDE\" class=\"wp-image-180848\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/ESP32-help-command-thonny-ide.png?w=651&amp;quality=100&amp;strip=all&amp;ssl=1 651w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/ESP32-help-command-thonny-ide.png?resize=300%2C268&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/figure><\/div>\n\n\n<p>It should print some useful information about programming your board using MicroPython.<br>You can test other commands. For, example type the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt; print('Hello')<\/pre>\n\n\n\n<p>It should print <strong>Hello <\/strong>on the Shell right after you enter the command.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"69\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/print-hello-esp32-micropython-shell.png?resize=306%2C69&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"print command on the MicroPython Shell and the response\" class=\"wp-image-180849\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/print-hello-esp32-micropython-shell.png?w=306&amp;quality=100&amp;strip=all&amp;ssl=1 306w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/print-hello-esp32-micropython-shell.png?resize=300%2C68&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 306px) 100vw, 306px\" \/><\/figure>\n\n\n\n<p>You can also run the following commands successively on the Shell after the prompt (<strong>&gt;&gt;&gt;<\/strong>) one at a time to turn on the ESP32\/ESP8266 built-in LED.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; from machine import Pin<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; led = Pin(2, Pin.OUT)<\/pre>\n\n\n\n<p>If you\u2019re using an ESP32, turn the onboard LED as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; led.value(1)<\/pre>\n\n\n\n<p>If you\u2019re using an ESP8266, the built-in LED works with inverted logic. So, you turn it on as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; led.value(0)<\/pre>\n\n\n\n<p>The on-board LED should light up.<\/p>\n\n\n\n<div class=\"wp-block-jetpack-tiled-gallery aligncenter is-style-rectangular\"><div class=\"\"><div class=\"tiled-gallery__gallery\"><div class=\"tiled-gallery__row\"><div class=\"tiled-gallery__col\" style=\"flex-basis:49.94095%\"><figure class=\"tiled-gallery__item\"><img decoding=\"async\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?strip=info&#038;w=600&#038;ssl=1 600w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?strip=info&#038;w=750&#038;ssl=1 750w\" alt=\"\" data-height=\"422\" data-id=\"120420\" data-link=\"https:\/\/randomnerdtutorials.com\/?attachment_id=120420#main\" data-url=\"https:\/\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg\" data-width=\"750\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?ssl=1\" data-amp-layout=\"responsive\"\/><\/figure><\/div><div class=\"tiled-gallery__col\" style=\"flex-basis:50.05905%\"><figure class=\"tiled-gallery__item\"><img decoding=\"async\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?strip=info&#038;w=600&#038;ssl=1 600w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?strip=info&#038;w=750&#038;ssl=1 750w\" alt=\"ESP8266 board with the built-in LED on\" data-height=\"421\" data-id=\"88063\" data-link=\"https:\/\/randomnerdtutorials.com\/interrupts-timers-esp8266-arduino-ide-nodemcu\/esp8266-blinking-led\/#main\" data-url=\"https:\/\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg\" data-width=\"750\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?ssl=1\" data-amp-layout=\"responsive\"\/><\/figure><\/div><\/div><\/div><\/div><\/div>\n\n\n\n<p>Now, you can turn off the built-in LED. On the ESP32, run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; led.value(0)<\/pre>\n\n\n\n<p>And like this for the ESP8266:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; led.value(1)<\/pre>\n\n\n\n<p>If everything is working as expected, it means you have successfully installed Thonny IDE, as well as MicroPython firmware on your ESP32 or ESP8266 boards.<\/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>In the <strong>MicroPython Shell<\/strong>, 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 to the uploading process, 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 &#8211; Blinking an LED<\/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<p>When you open Thonny IDE for the first time, the Editor shows an untitled file. Copy the following script to that 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\n<h3 class=\"wp-block-heading\">Running the Script<\/h3>\n\n\n\n<p>To run that script on your board, simply click on the <strong>Run <\/strong>icon in Thonny IDE.<\/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=\"642\" height=\"364\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/blink-led-script-thonny-ide.png?resize=642%2C364&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Blink LED script on Thonny IDE with run button highlighted\" class=\"wp-image-180860\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/blink-led-script-thonny-ide.png?w=642&amp;quality=100&amp;strip=all&amp;ssl=1 642w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/blink-led-script-thonny-ide.png?resize=300%2C170&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/figure><\/div>\n\n\n<p>The on-board LED will start blinking.<\/p>\n\n\n\n<div class=\"wp-block-jetpack-tiled-gallery aligncenter is-style-rectangular\"><div class=\"\"><div class=\"tiled-gallery__gallery\"><div class=\"tiled-gallery__row\"><div class=\"tiled-gallery__col\" style=\"flex-basis:49.94095%\"><figure class=\"tiled-gallery__item\"><img decoding=\"async\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?strip=info&#038;w=600&#038;ssl=1 600w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?strip=info&#038;w=750&#038;ssl=1 750w\" alt=\"\" data-height=\"422\" data-id=\"120420\" data-link=\"https:\/\/randomnerdtutorials.com\/?attachment_id=120420#main\" data-url=\"https:\/\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg\" data-width=\"750\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?ssl=1\" data-amp-layout=\"responsive\"\/><\/figure><\/div><div class=\"tiled-gallery__col\" style=\"flex-basis:50.05905%\"><figure class=\"tiled-gallery__item\"><img decoding=\"async\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?strip=info&#038;w=600&#038;ssl=1 600w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?strip=info&#038;w=750&#038;ssl=1 750w\" alt=\"ESP8266 board with the built-in LED on\" data-height=\"421\" data-id=\"88063\" data-link=\"https:\/\/randomnerdtutorials.com\/interrupts-timers-esp8266-arduino-ide-nodemcu\/esp8266-blinking-led\/#main\" data-url=\"https:\/\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg\" data-width=\"750\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/ESP8266-blinking-LED.jpg?ssl=1\" data-amp-layout=\"responsive\"\/><\/figure><\/div><\/div><\/div><\/div><\/div>\n\n\n\n<p>To stop the execution of the program, you can hit the STOP button or simply press <strong>CTRL<\/strong>+<strong>C<\/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=\"29\" height=\"28\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/thonny-ide-stop-button.png?resize=29%2C28&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE Stop button\" class=\"wp-image-180861\"\/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Running your Code Automatically<\/h3>\n\n\n\n<p>Just running the file with Thonny doesn\u2019t copy it permanently to the ESP32 or ESP8266 filesystem. This means that if you unplug it from your computer and apply power to the board, nothing will happen because it doesn\u2019t have any MicroPython file saved on its filesystem.<\/p>\n\n\n\n<p>The Thonny IDE Run function is useful to test the code, but if you want to upload it permanently to your board, you need to create and save a file to the board&#8217;s filesystem. Let\u2019s see how to do that.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Uploading Code to the ESP32\/ESP8266 Boards<\/h3>\n\n\n\n<p>Stop the execution of the previous program by clicking on the Stop button if you haven\u2019t already.<\/p>\n\n\n\n<p><strong>1)<\/strong> With the code copied to the file, click on the <strong>Save<\/strong> icon or go to <strong>File<\/strong> &gt; <strong>Save as\u2026<\/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=\"26\" height=\"31\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/03\/thonny-ide-save-button.png?resize=26%2C31&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Thonny IDE Save Button\" class=\"wp-image-180865\"\/><\/figure><\/div>\n\n\n<p><strong>2)<\/strong> Then, select <strong>MicroPython device<\/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=\"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\"\/><\/figure><\/div>\n\n\n<p><strong>3)<\/strong> Name the file <span class=\"rnthl rntliteral\">main.py<\/span>, otherwise, it will not run automatically on the ESP32 or 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=\"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\" \/><\/figure><\/div>\n\n\n<p>Notice that the window that pops up shows the files currently saved on the board&#8217;s 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\n<p><strong>4)<\/strong> Finally, click <strong>Ok <\/strong>to proceed.<\/p>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Important: <\/strong> when you name a file main.py, the ESP will run that file automatically on boot (when it starts). If you call it a different name, it will still be saved on the board filesystem, but it will not run automatically on boot.<\/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<p>After saving the file, you can remove and apply power again to the board, or you can even power it using a different power supply that is not your computer.<\/p>\n\n\n\n<p>Notice that the board will automatically start blinking the LED when you apply power to it. This means the <span class=\"rnthl rntliteral\">main.py<\/span> file was successfully uploaded to the board and that it is running that file automatically.<\/p>\n\n\n\n<p>Congratulations! You\u2019ve just written and uploaded your first MicroPython script to your ESP32\/ESP8266 board<\/p>\n\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 by 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 on your board, sometimes it\u2019s busy running that script and performing the tasks.<\/p>\n\n\n\n<p>So, you need to try starting the connection by pressing &#8220;Stop\/Restart backend&#8221; button multiple times or restarting the ESP to make it 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\n\n\n<p><\/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":180937,"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\/2022\/03\/Thonny-IDE-ESP32-ESP8266-Getting-Started.jpg?fit=1920%2C1080&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":12,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/80235\/revisions"}],"predecessor-version":[{"id":189980,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/80235\/revisions\/189980"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/180937"}],"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}]}}