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 chip | Firmware page | esptool offset | Notes |
|---|---|---|---|
| ESP32 (WROOM-32, DevKit V1, most cheap boards) | ESP32_GENERIC | 0x1000 | Use the SPIRAM build only if the module has PSRAM (WROVER) |
| ESP32-S2 | ESP32_GENERIC_S2 | 0x1000 | Native USB |
| ESP32-S3 | ESP32_GENERIC_S3 | 0x0 | Pick the SPIRAM_OCT variant for N8R8/N16R8 modules |
| ESP32-C3 | ESP32_GENERIC_C3 | 0x0 | RISC-V; also XIAO ESP32C3, SuperMini |
| ESP32-C6 | ESP32_GENERIC_C6 | 0x0 | RISC-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
- Plug in the ESP32 and open Thonny.
- Go to Tools → Options → Interpreter.
- In the first drop-down choose MicroPython (ESP32). For an S2, S3 or C3, the generic ESP32 entry still works for the REPL.
- Click Install or update MicroPython (esptool) at the bottom right.
- 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. - Set MicroPython family to your chip (ESP32, ESP32-S3, ESP32-C3…), then the variant (for example Espressif • ESP32 / WROOM) and the latest stable version.
- Click Install and wait for "Done!". This takes about a minute. If it stalls at Connecting…, hold BOOT, tap EN/RST, and release BOOT.
- 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:
pip install --upgrade esptoolCheck that esptool can reach the chip. Replace COM5 with your port:
esptool --port COM5 chip-idIt 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):
esptool --port COM5 erase-flash
esptool --port COM5 --baud 460800 write-flash 0x1000 ESP32_GENERIC-v1.2x.x.binFor an ESP32-S3, C3 or C6, the offset is 0:
esptool --port COM5 erase-flash
esptool --port COM5 --baud 460800 write-flash 0 ESP32_GENERIC_S3-v1.2x.x.binUse the exact filename you downloaded. Two details worth knowing:
- esptool 4.x uses the older names:
esptool.pyinstead ofesptool, 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 headermessages. 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:
print("Hello from SolderHub")Then check what you're running and how much memory is free:
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:
| File | Runs | Use it for |
|---|---|---|
boot.py | First, on every reset | Low-level setup; leave it almost empty |
main.py | After boot.py | Your program |
Create a new file in Thonny and paste:
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:
pip install mpremote
mpremote connect COM5 fs cp main.py :main.py
mpremote connect COM5 replThe 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.
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):
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
| Problem | Fix |
|---|---|
| No COM port appears | Try a data cable and a different USB port; install the CP210x or CH340 driver |
Could not open port / access denied | Another program has the port. Close the Arduino Serial Monitor, other Thonny windows, PuTTY |
Failed to connect… Timed out waiting for packet header | Hold BOOT, tap EN/RST, release BOOT, retry. Some boards need BOOT held until writing starts |
Boot loop with invalid header | Wrong firmware or wrong offset. Erase and flash again with the table at the top |
Flashed OK but no >>> prompt | Press 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 triggered | Weak 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:
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:
- Connect the ESP32 to Wi-Fi with MicroPython
- Publish sensor data over MQTT with umqtt
- Deep sleep and wake sources in MicroPython for battery projects
- Fix common MicroPython errors
Using a Raspberry Pi Pico instead? See Install MicroPython on the Pico W and Pico 2 W.




