How to flash MicroPython onto a fresh ESP32 (with screenshots)

Asked 1 week ago Modified 3 days ago Viewed 5 times
How to flash MicroPython onto a fresh ESP32 (with screenshots)

If you've never flashed firmware before, this is the gentlest entry point into programming microcontrollers. End result: you can type Python directly into a REPL prompt on your ESP32 and see LEDs blink in real time.

You need

  • Any ESP32 dev board (DevKit V1, NodeMCU-32S, etc.)
  • A USB cable that supports data, not just power
  • Python 3 installed on your computer

Step 1 — Install esptool

pip install esptool

On Linux/Mac you may need sudo, on Windows open an Admin Command Prompt.

Step 2 — Identify your serial port. Plug the ESP32 in, then:

  • Windows: open Device Manager → Ports (COM & LPT), look for 'Silicon Labs CP210x' or 'CH340'.
  • Mac/Linux: `ls /dev/tty.*` or `ls /dev/ttyUSB*`.

If nothing shows up, install the CP210x or CH340 USB driver depending on the chip on your board.

Step 3 — Erase the flash

esptool.py --chip esp32 --port COM3 erase_flash

(replace COM3 with your actual port)

Step 4 — Download the latest MicroPython firmware .bin from micropython.org/download/esp32. Then flash it:

esptool.py --chip esp32 --port COM3 --baud 460800 write_flash -z 0x1000 esp32-xxxxxx.bin

Step 5 — Open a serial terminal at 115200 baud and press the reset button on the board. You should see:

>>>

This is the MicroPython REPL. Try:

from machine import Pin
led = Pin(2, Pin.OUT)
led.value(1)

The blue LED next to the antenna lights up. Welcome to embedded Python.

Recommended tools

  • Thonny IDE — has a built-in REPL and lets you upload .py files with one click.
  • ampy or rshell — command-line file transfer if you prefer scripts.

Common errors

  • 'Permission denied' on /dev/ttyUSB0 — add your user to the dialout group on Linux.
  • 'Failed to connect to ESP32' — hold the BOOT button while esptool says 'Connecting...'.
  • Garbled REPL — your baud rate is wrong, set it to 115200.