Last modified: Jun 16, 2026
Install MicroPython: Quick Guide
MicroPython is a lean and efficient implementation of Python 3, designed to run on microcontrollers. It brings the simplicity of Python to hardware, making it perfect for IoT projects, robotics, and embedded systems. Installing MicroPython is the first step to unlocking this power. This guide will walk you through the process on popular boards like the ESP32 and Raspberry Pi Pico. We will use clear steps, short paragraphs, and code examples to make it easy.
What You Need Before You Start
To install MicroPython, you need a few basic items. First, a compatible microcontroller board. The ESP32 and Raspberry Pi Pico are the most common choices. Second, a USB cable to connect the board to your computer. Third, a computer with an internet connection. Finally, install a serial terminal program. Tools like Thonny IDE or PuTTY work well. These tools let you communicate with the board after installation.
Download the MicroPython Firmware
MicroPython firmware is a single binary file that you flash onto your board. Visit the official MicroPython website to download it. Choose the firmware for your specific board. For the ESP32, look for a file named esp32-20230426-v1.20.0.bin or similar. For the Raspberry Pi Pico, download the .uf2 file. Always download the latest stable version. This ensures you get all bug fixes and new features.
How to Install MicroPython on ESP32
The ESP32 is a powerful chip with built-in Wi-Fi and Bluetooth. Installing MicroPython on it requires a tool called esptool. This tool runs on your computer and writes the firmware to the board. Follow these steps carefully.
Step 1: Install esptool
Open a terminal or command prompt on your computer. Run the following command to install esptool using pip:
# Install esptool
pip install esptoolThis command downloads and installs the tool. Make sure Python is already installed on your computer. If not, install Python first from the official website.
Step 2: Erase the Flash Memory
Before flashing new firmware, erase the existing memory on the ESP32. Connect the board via USB. Find the serial port name. On Windows, it is often COM3 or COM4. On Linux or macOS, it looks like /dev/ttyUSB0. Run this command to erase the flash:
# Erase flash on ESP32
esptool.py --port /dev/ttyUSB0 erase_flashReplace /dev/ttyUSB0 with your actual port. The process takes a few seconds. You will see output confirming the erase.
Step 3: Flash the MicroPython Firmware
Now, write the firmware to the board. Use this command with the downloaded binary file:
# Flash MicroPython firmware
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp32-20230426-v1.20.0.binThe --baud flag sets the speed. A higher baud rate makes flashing faster. After the command finishes, the board restarts automatically. You have successfully installed MicroPython on the ESP32.
How to Install MicroPython on Raspberry Pi Pico
The Raspberry Pi Pico is a low-cost board based on the RP2040 chip. Installing MicroPython on it is simpler than the ESP32. It uses a drag-and-drop method. No extra tools are needed.
Step 1: Download the UF2 File
Go to the MicroPython download page for the Raspberry Pi Pico. Download the .uf2 file. This is a special format that the Pico can read directly.
Step 2: Enter Bootloader Mode
To install the firmware, put the Pico into bootloader mode. Disconnect the board from USB. Then, hold down the BOOTSEL button on the Pico. While holding it, connect the USB cable to the computer. Release the button after a second. The Pico appears as a removable drive called RPI-RP2 on your computer.
Step 3: Copy the Firmware
Drag and drop the downloaded .uf2 file onto the RPI-RP2 drive. The file copies automatically. The Pico then reboots and runs MicroPython. The drive disappears, and the board is ready. This process takes only a few seconds.
Verify the Installation
After flashing, test the installation. Open Thonny IDE. Set the interpreter to MicroPython. Select the correct serial port. Then, run a simple script to confirm everything works. Here is an example:
# Test MicroPython installation
import machine
import time
# Blink the built-in LED
led = machine.Pin(2, machine.Pin.OUT) # On ESP32, Pin 2 often controls the LED
while True:
led.value(1) # Turn LED on
time.sleep(1) # Wait 1 second
led.value(0) # Turn LED off
time.sleep(1)If the LED blinks, MicroPython is working. For the Raspberry Pi Pico, use Pin 25 instead of Pin 2. The built-in LED on the Pico is connected to Pin 25.
Troubleshooting Common Issues
Sometimes things go wrong. Here are common problems and how to fix them. If the board is not detected, check the USB cable. Some cables only charge and do not transfer data. If esptool fails, try a lower baud rate like 115200. If the Pico does not appear as a drive, re-enter bootloader mode. Make sure you hold the BOOTSEL button before connecting USB.
Best Practices for First Use
After installation, update the MicroPython firmware if a new version is available. Always back up your scripts. Use a good serial terminal like Thonny to write and test code. Thonny is beginner-friendly and includes a built-in debugger. It also shows the output from your board directly. This makes learning easier.
Conclusion
Installing MicroPython is straightforward. On the ESP32, use esptool to erase and flash the firmware. On the Raspberry Pi Pico, simply drag and drop the .uf2 file. Both methods take only a few minutes. Verify the installation with a simple LED blink test. With MicroPython installed, you can start building amazing projects. From weather stations to robots, the possibilities are endless. Now go ahead and flash your board. Happy coding