Skip to content

Tutorial

Install MicroPython on ESP32 with Thonny or esptool (S3, C3 and C6 too)

Install Thonny, download the right firmware for your exact board, flash it with Thonny or esptool, open the REPL and save a first script. Includes chip-specific flash offsets, USB driver and cable problems, and what to do when the port is not found.

  • 5 min read
  • Updated November 7, 2026
Install MicroPython on ESP32 with Thonny or esptool (S3, C3 and C6 too)

MicroPython lets you program an ESP32 in Python: type a line in the REPL and the board runs it immediately, with no compile-and-upload cycle. Getting started takes two steps: flash the MicroPython firmware once, then connect an editor to the board.

Quick answer: in Thonny, open Tools → Options → Interpreter, choose MicroPython (ESP32), click Install or update MicroPython (esptool), pick your port and chip family, and click Install. Prefer the command line? Erase the flash, then write the firmware from micropython.org with esptool: offset 0x1000 for the original ESP32 and ESP32-S2, 0x0 for the ESP32-S3, C3 and C6. If the board won't connect, hold BOOT, tap EN/RST, then release BOOT.

Which firmware to download (all from micropython.org/download):

Your chipFirmware pageesptool offsetNotes
ESP32 (WROOM-32, DevKit V1, most cheap boards)ESP32_GENERIC0x1000Use the SPIRAM build only if the module has PSRAM (WROVER)
ESP32-S2ESP32_GENERIC_S20x1000Native USB
ESP32-S3ESP32_GENERIC_S30x0Pick the SPIRAM_OCT variant for N8R8/N16R8 modules
ESP32-C3ESP32_GENERIC_C30x0RISC-V; also XIAO ESP32C3, SuperMini
ESP32-C6ESP32_GENERIC_C60x0RISC-V; also XIAO ESP32C6

Firmware for the wrong chip won't boot, so check the marking on the metal module can ("ESP32-WROOM-32", "ESP32-S3-WROOM-1", "ESP32-C3") before you download anything. A board sold as "ESP32 DevKit" can carry any of these.

What You Need

  • An ESP32 board and a USB data cable. Many cables that come with power banks carry power only: the board's LED lights but no serial port appears. If no port shows up, try another cable before anything else.
  • Thonny 4.x from thonny.org (Windows, macOS, Linux). It bundles esptool, so you don't need to install Python separately.
  • A USB-serial driver, only if Windows shows no COM port. Look at the small chip next to the USB connector: CP2102 needs the Silicon Labs CP210x driver, CH340/CH9102 needs the WCH driver. Boards with native USB (S2, S3, C3, C6 on the USB port marked "USB") need no driver on Windows 10/11.

Close the Arduino IDE Serial Monitor, PuTTY and any VS Code serial extension first. Only one program can hold a serial port, and a busy port is the most common reason flashing fails.

Method 1: Install MicroPython with Thonny

  1. Plug in the ESP32 and open Thonny.
  2. Go to Tools → Options → Interpreter.
  3. In the first drop-down choose MicroPython (ESP32). For an S2, S3 or C3, the generic ESP32 entry still works for the REPL.
  4. Click Install or update MicroPython (esptool) at the bottom right.
  5. Set Target port to the board's port (COM5, /dev/ttyUSB0, /dev/cu.usbserial-…). If you're unsure which it is, unplug the board, see which entry disappears, and plug it back in.
  6. Set MicroPython family to your chip (ESP32, ESP32-S3, ESP32-C3…), then the variant (for example Espressif • ESP32 / WROOM) and the latest stable version.
  7. Click Install and wait for "Done!". This takes about a minute. If it stalls at Connecting…, hold BOOT, tap EN/RST, and release BOOT.
  8. Close the dialog, click OK, then click in the Shell and press Enter.

You should see a banner like MicroPython v1.2x on 2025-xx-xx; Generic ESP32 module with ESP32 and the >>> prompt. That's the REPL: MicroPython is running.

Thonny downloads the firmware for you. To flash a file you've downloaded yourself, use the ≡ menu in the install dialog and choose a local image.

Method 2: Install MicroPython with esptool

The command line is faster when you flash several boards and it shows clearer error messages. Install esptool with pip:

terminal
pip install --upgrade esptool

Check that esptool can reach the chip. Replace COM5 with your port:

terminal
esptool --port COM5 chip-id

It should print the detected chip, such as Chip is ESP32-D0WD-V3. Then erase the flash and write the firmware. For an original ESP32 (offset 0x1000):

terminal
esptool --port COM5 erase-flash
esptool --port COM5 --baud 460800 write-flash 0x1000 ESP32_GENERIC-v1.2x.x.bin

For an ESP32-S3, C3 or C6, the offset is 0:

terminal
esptool --port COM5 erase-flash
esptool --port COM5 --baud 460800 write-flash 0 ESP32_GENERIC_S3-v1.2x.x.bin

Use the exact filename you downloaded. Two details worth knowing:

  • esptool 4.x uses the older names: esptool.py instead of esptool, and underscores (chip_id, erase_flash, write_flash). Version 5 still accepts them with a warning.
  • The wrong offset is the classic mistake. Writing an original-ESP32 image at 0x0, or an S3 image at 0x1000, gives a board that boot-loops with invalid header messages. Erase and flash again at the right offset.

Erasing wipes every file on the board. Copy your scripts off first if they matter.

Your First Commands in the REPL

Click in Thonny's Shell and type:

main.py
print("Hello from SolderHub")

Then check what you're running and how much memory is free:

main.py
import sys, gc, esp
print(sys.implementation)     # MicroPython version
print(esp.flash_size())       # flash in bytes, e.g. 4194304 = 4 MB
gc.collect(); print(gc.mem_free())

A plain ESP32 gives you about 100–150 KB free for your program; boards with PSRAM and a SPIRAM build give several megabytes.

Useful keys in the REPL: Ctrl+C stops a running program, Ctrl+D soft-reboots and re-runs main.py, and the Stop/Restart button in Thonny does the same. A "soft reboot" message is normal.

Save a Script That Runs on Boot

MicroPython runs two files automatically at power-up, in this order:

FileRunsUse it for
boot.pyFirst, on every resetLow-level setup; leave it almost empty
main.pyAfter boot.pyYour program

Create a new file in Thonny and paste:

main.py
from time import sleep

count = 0
while True:
    count += 1
    print("SolderHub test:", count)
    sleep(2)

Choose File → Save as… → MicroPython device and name it main.py. Press the board's EN/RST button: the counter starts on its own, without Thonny. To try code without making it autostart, save it under another name (test.py) and run it with the green Run button.

If a bad main.py locks you out, click in the Shell and press Ctrl+C a few times right after a reset to break into the REPL, then delete or rename the file from Thonny's Files view (View → Files).

Prefer a terminal? mpremote, the official MicroPython tool, copies files and opens the REPL:

terminal
pip install mpremote
mpremote connect COM5 fs cp main.py :main.py
mpremote connect COM5 repl

The board isn't a safe place to keep your only copy: erasing or reflashing deletes it. Keep your scripts on your computer.

Blink an LED

Many ESP32 DevKit V1 boards have a blue LED on GPIO2, so this works with no wiring. The official ESP32-DevKitC has no user LED, and the ESP32-S3-DevKitC has an RGB LED instead (see below). If nothing blinks, wire an LED with a 220 Ω resistor from GPIO2 to GND.

main.py
from machine import Pin
from time import sleep

led = Pin(2, Pin.OUT)
while True:
    led.value(not led.value())
    sleep(0.5)

For the ESP32-S3-DevKitC RGB LED (GPIO48 on most boards, GPIO38 on v1.1):

main.py
from machine import Pin
from neopixel import NeoPixel

np = NeoPixel(Pin(48), 1)
np[0] = (0, 0, 40)   # dim blue
np.write()

Before wiring anything else, check the ESP32 pinout guide: GPIO6–11 are used by the flash chip, GPIO34–39 are input-only, and GPIO0, 2, 12 and 15 affect booting. Never drive a motor or relay coil straight from a GPIO; use a transistor or driver module.

Troubleshooting

ProblemFix
No COM port appearsTry a data cable and a different USB port; install the CP210x or CH340 driver
Could not open port / access deniedAnother program has the port. Close the Arduino Serial Monitor, other Thonny windows, PuTTY
Failed to connect… Timed out waiting for packet headerHold BOOT, tap EN/RST, release BOOT, retry. Some boards need BOOT held until writing starts
Boot loop with invalid headerWrong firmware or wrong offset. Erase and flash again with the table at the top
Flashed OK but no >>> promptPress Enter or Ctrl+C in the Shell; click Stop/Restart; on native-USB boards the port name can change after flashing, so reselect it
Brownout detector was triggeredWeak USB port or cable; use a powered hub or a shorter cable
ImportError: no module named …Not every Python module exists in MicroPython. Install pure-Python libraries with mip (see below)
OSError: [Errno 28]The filesystem is full. Delete old files from the device

To install a library from micropython-lib once the board is on Wi-Fi:

main.py
import mip
mip.install("umqtt.simple")

Can you brick an ESP32 by flashing? Practically, no. The bootloader is in ROM, so download mode (BOOT + EN/RST) always works, and a fresh erase and flash brings the board back. If esptool can't see the chip even in download mode, the problem is the cable, driver or USB port, not the firmware. For errors after setup, see MicroPython troubleshooting.

FAQ

Do I need to install Python on my computer? No, for Thonny. It bundles its own Python and esptool. You only need Python for the esptool or mpremote command-line route.

Which firmware for an ESP32-WROOM-32? ESP32_GENERIC, written at 0x1000. Use the SPIRAM build only for a WROVER module.

Can I go back to Arduino later? Yes. Uploading any Arduino sketch overwrites MicroPython. Flash MicroPython again whenever you want it back.

Thonny, VS Code or mpremote? Thonny is the easiest start: one window for code, files and the REPL. Move to VS Code with mpremote when projects grow to several files.

Why doesn't my code run after I unplug the USB cable? It was run from Thonny, not saved to the board. Save it as main.py on the MicroPython device.

Does MicroPython work on the ESP8266? Yes, with the ESP8266_GENERIC firmware written at offset 0, but it has far less memory than an ESP32.

Next Steps

Once you have a >>> prompt and a blinking LED, work through these in order:

  1. Connect the ESP32 to Wi-Fi with MicroPython
  2. Publish sensor data over MQTT with umqtt
  3. Deep sleep and wake sources in MicroPython for battery projects
  4. Fix common MicroPython errors

Using a Raspberry Pi Pico instead? See Install MicroPython on the Pico W and Pico 2 W.

Continue learning

Related articles

All articles

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.