Raspberry Pi Pico MicroPython Getting Started
This tutorial introduces MicroPython and guides you through setting up the MicroPython development environment for Pico.
The core logic of this tutorial applies to all RP series development boards. However, all operational steps are explained using the Raspberry Pi Pico as an example. If you are using a development board of another model, please modify the corresponding settings according to the actual situation.
Welcome to the Waveshare Raspberry Pi Pico MicroPython Getting Started Tutorial!
This series of tutorials is based on the Waveshare Raspberry Pi Pico development board and the Thonny IDE environment, aiming to help learners get started with Raspberry Pi Pico development. It is recommended to study in order, or you can choose the chapters you are interested in according to your own needs.
- Section 1: Basic Introduction
- Section 2: GPIO
- Section 3: PWM
- Section 4: ADC
- Section 5: UART
- Section 6: I2C
- Section 7: SPI
- Section 8: PIO
You can use any RP series development board you have on hand and follow along with components you prepare yourself.
If you wish to avoid the hassle of selecting components, we also offer the following learning kits, which contain the core hardware for learning Raspberry Pi Pico:
- Raspberry-Pi-Pico-Basic-Kit: Raspberry Pi Pico Basic Starter Kit, MicroPython Programming Learning Kit
- Raspberry-Pi-Pico-Sensor-Kit-B: Raspberry Pi Pico Entry-Level Sensor Kit, Including Pico Expansion Board and 15 common modules
Of course, you can also choose the more powerful Raspberry Pi Pico 2 learning kits:
- Raspberry-Pi-Pico-2-Basic-Kit: Raspberry Pi Pico 2 Basic Starter Kit, MicroPython Programming Learning Kit
- Raspberry-Pi-Pico-2-Sensor-Kit: Raspberry Pi Pico 2 Sensor Kit, including Pico expansion board and 15 common modules
1. What is MicroPython?
MicroPython is a lean and efficient implementation of the Python 3 programming language, specifically optimized to run on microcontrollers and other resource-constrained environments.
MicroPython supports a variety of microcontroller platforms. It can run on devices with as little as 16KB of RAM. On the RP2040 (264KB RAM) and RP2350 (520KB RAM), you will get a more complete and smoother functional experience.
Simply put, MicroPython is a "miniature version" of Python that runs on microcontrollers. It allows developers to control hardware using Python syntax, lowering the barrier to entry for embedded development.
A comparison of using MicroPython with other development methods is as follows:
| Feature | MicroPython | Arduino | VS Code |
|---|---|---|---|
| Learning Difficulty | Low | Medium | High |
| Development Efficiency | High | Medium | Low |
| Performance | Medium | High | Highest |
| Memory Usage | Relatively High | Medium | Controllable |
1.1 Operating Principle
The operation of MicroPython relies primarily on the firmware flashed onto the device.
- Interactive Interpreter (REPL):
When the MicroPython firmware starts, it runs a miniature Python interpreter and enters a standby state. At this point, through a serial connection, the user can enter the REPL (Read-Eval-Print Loop) environment. Python commands sent in this environment are executed immediately and return results. This immediate feedback mechanism significantly improves debugging efficiency.

- File Execution Mechanism:
In addition to interactive input, MicroPython also supports running code saved in the file system. When the device boots, it attempts to run
boot.py(the system boot script) andmain.py(the user's main program) in sequence. Saving your code asmain.pyenables the program to run automatically upon device power-up.
1.2 Differences from Standard Python
- Independent Implementation: MicroPython is not a modification of the standard Python (CPython) source code; it is written from the ground up for embedded environments. It strictly adheres to Python 3 syntax, but its internal implementation is different.
- Functionality is a Subset: Due to the limited memory (RAM) and flash (Flash) of microcontrollers, MicroPython only includes a subset of the core libraries from standard Python. Some large libraries or libraries that are not suitable for embedded scenarios (such as the full versions of
numpyorrequests) are removed or replaced with more streamlined modules. - Hardware Support: The most distinctive feature of MicroPython is the addition of modules for controlling hardware, such as the
machinemodule (for controlling GPIO, I2C, SPI, etc.) and thenetworkmodule (for controlling Wi-Fi, Bluetooth). - Cross-Platform: In addition to the RP series development boards, it supports many other boards, such as the ESP32 series, ESP8266, STM32 series, etc.
2. Setting Up Development Environment
Thonny is a Python Integrated Development Environment (IDE) designed for beginners, with built-in, comprehensive support for MicroPython. It allows you to easily perform all operations such as firmware flashing, file management, and code debugging.
The following content of this tutorial will be demonstrated uniformly using Thonny IDE.
2.1 Installing Thonny
If the download speed is slow or the download fails, you can download from this link (Windows).
Go to the Thonny official website to download and install Thonny.
2.2 Configuring Thonny
After installation, configure the language and board environment on the first run. Since we are using RP series development boards, make sure to select the Raspberry Pi option for the board environment.
- First, connect the development board to your computer. Left-click the "Configure interpreter" option in the bottom-right corner of Thonny.

- In the pop-up window, select MicroPython (Raspberry Pi Pico), and choose the corresponding port

2.3 Flashing Firmware
-
Flash the Firmware: Press and hold the BOOT button, then connect the board to your computer. Release the BOOT button, and a removable disk will appear on your computer. Copy the firmware file into it.
NoteFlashing the firmware provided by MicroPython's official source may cause the device to be unrecognized. Please use the firmware from the links below or the one in the development board's corresponding program package.

-
Restart the Interpreter: After successful flashing, click the red Stop button on the toolbar to restart the on-board interpreter.
-
Check the Prompt: After successful connection, the MicroPython version information, board information, and the
>>>prompt should appear in the Shell window, indicating that you have successfully entered the board's MicroPython REPL environment.
2.4 Verifying the Development Environment
-
Run Test Code: At the
>>>prompt, type your first line of MicroPython code and press Enter:print('Hello, Raspberry Pi Pico!')
You should immediately see Raspberry Pi Pico return the message
Hello, Raspberry Pi Pico!.
At this point, the Raspberry Pi Pico MicroPython development environment has been set up, and you have successfully run the first line of code.
