← How-Tos
electronics Jul 3, 2026 ◑ 3 views ◯ 2 min read

ESP32 + MicroPython: Getting Started (vs Arduino IDE)

esp32micropythonpythongetting started

MicroPython vs Arduino C++: The Real Tradeoff

MicroPython trades some performance and memory efficiency for dramatically faster iteration — no compile step, just edit and run, plus Python's generally gentler learning curve for people newer to programming. Arduino/C++ wins when you need maximum performance, tight timing control, or you're building something with a large existing C++ library ecosystem you want to leverage. Neither is objectively "better" — pick based on what you're actually building and what you already know.

Flashing MicroPython Firmware

Unlike Arduino, MicroPython replaces the ESP32's entire firmware with a MicroPython interpreter — this is a one-time flash, not something you do per-project:

pip install esptool esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-firmware.bin

Download the current .bin from micropython.org/download/esp32/ before running the second command.

Connecting and First Commands

Use a serial terminal (see the Flipper CLI guide's screen/minicom/PuTTY instructions — same tools work here, different device) or a MicroPython-specific tool like Thonny IDE (recommended for beginners — has a built-in REPL and file management):

>>> print("hello from micropython") hello from micropython >>> import machine >>> led = machine.Pin(2, machine.Pin.OUT) >>> led.value(1) # LED on, immediately, no compile/upload step

The REPL Is the Killer Feature

That immediate interactive execution above — type a command, see the result instantly — is the core advantage over Arduino's compile-upload-run cycle. For hardware exploration/debugging (figuring out exact sensor behavior, testing pin wiring) this is genuinely much faster than the Arduino workflow's edit-compile-upload-observe loop repeated for every small change.

Writing a Persistent Script

For code that should run automatically on boot rather than typed interactively, save it as main.py via Thonny's file save (targeting the device, not your computer) or by copying it directly to the device's filesystem with ampy/rshell:

import machine import time led = machine.Pin(2, machine.Pin.OUT) while True: led.value(1) time.sleep(0.5) led.value(0) time.sleep(0.5)

Library Ecosystem

MicroPython has a smaller but genuinely solid library ecosystem for common sensors/peripherals — search micropython-lib or PyPI for MicroPython-specific packages before assuming you need to port an Arduino library yourself; most popular sensors (DHT, BMP280, common displays) have existing MicroPython drivers.

Performance Reality Check

For anything timing-critical (precise PWM generation, tight interrupt handling, high-frequency sensor polling), MicroPython's interpreted execution is genuinely slower than compiled Arduino C++ — this matters for some projects (the Arduino guides in this series' interrupt/timer content assumes C++ for exactly this reason) and doesn't matter at all for others (a temperature logger checking once a minute doesn't care about microsecond-level performance differences).