Easy Basics: Project 086p ESP32 development board - Using Thonny IDE

of Alek C. in ESP8266 ESP-32

Basics: Project 086p

Project name: ESP32 development board - Using Thonny IDE

Tags: ESP32 Development board, WI FI module, SP32 Dev Module, ESP32 development board, ESP32 Development board with WiFi and Bluetooth, ESP32-DevKitC V4 development board, ESP-WROOM-32 module with ESP32‑D0WDQ6 chip, Espressif Systems, ESP32-based development board, ESP32 modules, ESP32-WROOM-32, ESP32-WROOM-32U, ESP32-WROOM-32D, ESP32-SOLO-1, USB-UART bridge, IOT, ESP-WROOM-32 Dev Module, ESP32 DEVKITV1, micropython, Thonny IDE

Attachments: none

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. ESP32 development board with WiFi and Bluetooth and USB A / micro USB B cable 1 pc

2. Thonny IDE (you can download and read more about it here)


We will learn how to install and use the Thonny IDE with the ESP32 development board.

Understanding the Thonny IDE

Thonny is Python IDE for beginners. 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 with Raspbian OS for Raspberry Pi. Additionally, it's easy to install, so you shouldn’t have problems with the installation process.


  • Easy to get started. Thonny comes with Python 3.7 built in, so just one simple installer is needed and you're ready to learn programming. (You can also use a separate Python installation, if necessary.) The initial user interface is stripped of all features that may distract beginners.
  • No-hassle variables. Once you're done with hello-worlds, select View -> Variables and see how your programs and shell commands affect Python variables.
  • Simple debugger. Just press Ctrl+F5 instead of F5 and you can run your programs step-by-step, no breakpoints needed. Press F6 for a big step and F7 for a small step. Steps follow program structure, not just code lines.
  • Step through expression evaluation. If you use small steps, then you can even see how Python evaluates your expressions. You can think of this light-blue box as a piece of paper where Python replaces subexpressions with their values, piece-by-piece.
  • Faithful representation of function calls. Stepping into a function call opens a new window with separate local variables table and code pointer. Good understanding of how function calls work is especially important for understanding recursion.
  • Highlights syntax errors. Unclosed quotes and parentheses are the most common beginners' syntax errors. Thonny's editor makes these easy to spot.
  • Explains scopes. Highlighting variable occurrences reminds you that the same name doesn't always mean the same variable and helps spotting typos. Local variables are visually distinguished from globals.
  • Mode for explaining references. Variables are initially presented according to simplified model (name -> value) but you can switch to more realistic model (name -> address/id -> value).
  • Code completion. Students can explore APIs with the help of code completion.
  • Beginner friendly system shell. Select Tools -> Open system shell to install extra packages or learn handling Python on command line. PATH and conflicts with other Python interpreters are taken care of by Thonny.
  • Simple and clean pip GUI. Select Tools -> Manage packages for even easier installation of 3rd party packages.

Understanding the ESP32 Development board with WiFi and Bluetooth

You can read more about it here.

Signals and connections of the ESP32 Development board with WiFi and Bluetooth

You can find more information (datasheets, schematics, pins descriptions, functional desgn descriptions) about each board (made by Espresiff Systems) by pressing Getting started link close to each board here.

Let's check our development board - ESP32 DEVKITV1with ESP-WROOM-32 module from Espressif Systems:

Pinout diagram for the ESP Wroom 32 breakout:

ESP32-WROOM-32 - ESP32-WROOM-32 module soldered to the development board. Optionally ESP32-WROOM-32D, ESP32-WROOM-32U or ESP32-SOLO-1 module may be soldered instead of the ESP32-WROOM-32.

USB-UART Bridge - A single chip USB-UART bridge provides up to 3 Mbps transfers rates.

BOOT button - Download button: holding down the Bootbutton and pressing the EN button initiates the firmware download mode. Then user can download firmware through the serial port.

EN button - Reset button: pressing this button resets the system.

Micro USB Port - USB interface. It functions as the power supply for the board and the communication interface between PC and the ESP module.

TX0, TX2 - transmit pin. GPIO pin

RX0, RX2  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND - ground pin.

EN - Chip enable. Keep it on high (3.3V) for normal operation.

Vin - External power supply 5VDC.

Step by Step instruction

We are using Windows 7 64 bit OS version on our PC.

1. Preparations

  1. Install uPyCraft IDE on your PC;
  2. Plug the ESP32 development board to your PC and wait for the drivers to install (or install manually any that might be required).
  3. ESP32 development board - Uploading MicroPython firmware.

2. Installing the Thonny IDE.

  1. Go to thonny.org website and download the file for installation suitable for your OS. We have Windows OS so we downloaded thonny-3.1.2.exe for Windows.
  2. Double-click on thonny-3.1.2.exe to open the file. Click on Run button.
  3. Click on Next button.
  4. Select I accept the agreement and click on Next button.
  5. Click on Next button.
  6. Click on Next button.
  7. Click on Install button.
  8. The installation process will start.
  9. Click on Finish button.
  10. After completing the installation, open Thonny IDE.

3. Testing the installation

  1. Your ESP32 development board should have MicroPython firmware.
  2. Plug the ESP32 development board to your PC and wait for the drivers to install (or install manually any that might be required).
  3. Go to Tools -> Options and select the Interpreter tab.
  4. Select MicroPython on a generic device.
  5. Select your device serial port. You can also select the Try to detect automatically option, but only if you just have one board connected to your computer at a time. Otherwise, select the specific port for the board you're using.
  6. Click on OK button.
  7. Thonny IDE should now be connected to your board and you should see the prompt on the Shell.
  8. Type the command help() in the Shell and see if it responds back.
  9. If iyou received response then everything is working fine. You can send a few more commands to test now.
  10. Send the following commands to light up the ESP32 development board on-board LED: from machine import Pin
  11. Pin(2, Pin.OUT).value(1)
  12. To turn off the on-board LED send the command: Pin(2, Pin.OUT).value(0)
  13. Congrats. You have done.

4. Using the Thonny IDE

  1. When you open the Thonny IDE you can see two sections: Editor and Terminal/Shell. The Editor section is where you write your code and edit your .py files. You can open more than one file, and the Editor will open a new tab for each file. In the Terminal/Shell section you can type commands to be executed immediately by your ESP32 development 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, and so on.
  2. You can customize your Thonny IDE to show other useful tabs. Go to View and you can select several tabs that provide more information.
  3. Let's make a script and run it. It will blink the on-board LED on your ESP32 development board.
  4. When you open Thonny IDE for the first time, the Editor section shows an untitled file. Save that file as main.py - click on save icon and give the name to the file main.py. You will have the tab main.py now.
  5. Type the folowing code in main.py file.
  6. Save it - click on save icon.
  7. Go to Device and select Upload current script as main script.
  8. It should show the following in the Terminal/Shell section. Uploading the code as main script will save the current file with the name main.py on the ESP32 development board, even if you have saved it in your computer with a different name. The same happens for the boot.py file.
  9. After uploading the script press the on-board EN button on your ESP32 development board. When the ESP32 development board restarts, first it runs the boot.py file and afterwards the main.py.
  10. The ESP32 development board on-board LED should be blinking. Congrats.
  11. To list all files saved on the ESP32 development board type the command in the Terminal/Shell: %lsdevice 

  12. If you want to see the file content, use %cat / followed by the file path, for example: %cat /main.py

  13. If you want to see the boot.py and main.py scripts, go to Device, select Show device's main script or Show device's boot script.
  14. If you want to upload the file with script which has a special name. Make the file, save it (for example we had best.py), go to Device and select Upload current script with current name.
  15. The file will be saved on the ESP32 development board with the name best.py.
  16. If you want to remove/delete all files completely from your EESP32 development board, you need to re-flash it with MicroPython firmware. You can also upload a blank script to the ESP32 development board to remove/delete code.


Normally the restarting your ESP32 development board with the on-board EN button fixes your problem or pressing in the Thonny IDE Stop/Restart backend button and repeating your desired action.

If it doesn't work for you check the solutions below:

  1. If you are getting an error: = RESTART = Unable to connect to COM4 Error: could not open port 'COM4': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2) Check the configuration, select Run -> Stop/Restart or press Ctrl+F2 to try again. (On some occasions it helps to wait before trying again.) or = RESTART = Could not connect to REPL.Make sure your device has suitable firmware and is not in bootloader mode!Disconnecting o= RESTART = Lost connection to the device (EOF)Disconnect and connect your ESP32 development board. Then, double-check that you selected correct serial port in the Tools -> Options... -> Interpreter -> Port. Click on Stop/Restart backend button to establish a serial communication. You should now be able to upload a new script or re-run new code. 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 closed all the programs that might be establishing a serial communication with your ESP32 development board. Disconnect and connect your ESP32 development board again. Do restart Thonny IDE.
  2. If Thonny IDE fails to respond or gives an Internal Error window. When it happens, close that window and it will continue to work. If it will continue to crash restart the Thonny IDE software.
  3. Thonny IDE hangs when you click on Stop/Restart backend button. When you click on Stop/Restart backend button you need to wait a few seconds. The ESP32 development board needs time to restart and establish the serial communication with Thonny IDE. If you click on this button multiple times or if you click on this button very quickly, the ESP32 development board will not have enough time to restart properly and it's very likely crash Thonny IDE.
  4. Problem restarting your ESP32 development board, running a new script or opening the serial port - Brownout detector was triggered or if the ESP32 development board keeps restarting and printing the ESP boot information. Brownout detector was triggered error message or constant reboots  means that there's some sort of hardware problem. It's often related to one of the following issues: poor quality USB cable; USB cable is too long; board with some defect (bad solder joints); bad computer USB port; or not enough power provided by the computer USB port. Try a different shorter USB data cable, try a different computer USB port or use a USB hub with an external power supply. If you keep having constant problems or error messages we recommend to re-flash your ESP32 development board with the latest version of MicroPython firmware.
  5. When you try to establish a serial communication with the ESP32 development board in Thonny IDE but can not get it to connect. When you are running a script in your board, sometimes it's busy running that script and performing the tasks. So, you need to try start the connection by click on Stop/Restart backend button multiple times or restart the ESP32 development board to catch available to establish the serial communication. Please  do not click on Stop/Restart backend button multiple times very quickly. After pressing that button, you need to be patient and wait a few seconds for the command to run. If you are running a script that uses Wi-Fi, deep sleep or it's doing multiple tasks we recommend trying 3 or 4 times to establish the communication. If you can not we recommend to re-flash the ESP32 development board with MicroPython firmware.
  6. Debug tools are grayed out. Thonny IDE debug tools are not available for MicroPython. The debug tools are only available for the Python Interpreter, so being grayed out is the expected behavior. 


We have learnt how to install and use the Thonny IDE with the ESP32 development board.


  • None


  • None

Published at 09-08-2019
Viewed: 4063 times