AI agents & screen readers: for a machine-readable, text-only catalogue, start at /llms.txt. Products are available as Markdown (/products.md, /products/{handle}.md) and JSON (/products.json, /products/{handle}.json).
Store

Getting started with MicroPython on Raspberry Pi Pico

Put MicroPython on a Pico, Pico W, Pico 2 or Pico 2 W, talk to it from Thonny, blink the onboard LED and make your program start every time the board powers up.

MicroPython is a compact Python 3 that runs directly on the Pico's chip. There's no operating system to install: you copy a single firmware file onto the board, and from then on it gives you a Python prompt over its USB cable.

What you need

  • A Pico-series board
  • A micro USB cable that carries data (some cheap cables only carry power, and the board never shows up)
  • A computer running Windows, macOS, Linux or Raspberry Pi OS

Pick the right firmware

Each board needs its own build of MicroPython. Get the one that matches your board from the MicroPython download pages:

Board Chip Download page
Pico, Pico H RP2040 RPI_PICO
Pico W, Pico WH RP2040 + wireless RPI_PICO_W
Pico 2 RP2350 RPI_PICO2
Pico 2 W, Pico 2 WH RP2350 + wireless RPI_PICO2_W

The H versions are the same boards with headers fitted, so they take the same firmware. On each page, download the release marked "latest": a .uf2 file named after the board and version, such as RPI_PICO_W-20260824-v1.29.0.uf2. The Pico 2 and Pico 2 W pages also offer a RISCV build; unless you specifically want to run the RP2350's RISC-V cores, take the standard one.

Install it with BOOTSEL

  1. Unplug the Pico from USB, and from anything else that might be powering it through VSYS or VBUS.
  2. Hold down the BOOTSEL button (beside the USB socket) and plug the USB cable in.
  3. Let go once a new drive appears on your computer: RPI-RP2 for an RP2040 board, RP2350 for a Pico 2.
  4. Drag the .uf2 file onto that drive.

After a few seconds the drive vanishes by itself. That's the board rebooting into MicroPython, not an error. Nothing visible happens next: MicroPython simply waits for instructions.

BOOTSEL mode lives in the chip's read-only memory, so whatever you flash, holding the button while you plug in will always get you back here. You can't brick a Pico from software. Once MicroPython is running, typing machine.bootloader() at the prompt does the same thing without the button.

Set up Thonny

Thonny is a free Python editor for beginners that knows how to talk to a Pico.

  • Windows and macOS: download the installer from thonny.org. It includes its own Python, so there's nothing else to set up.
  • Linux: thonny.org has a one-line installer, or use your distribution's package.
  • Raspberry Pi OS: look under Programming in the menu, and if it isn't there, run sudo apt install thonny.

Plug the Pico in normally (no BOOTSEL this time), then:

  1. Click the interpreter name in the bottom-right corner of Thonny's window.
  2. Choose MicroPython (Raspberry Pi Pico). On an older Thonny without that entry, MicroPython (generic) also works.
  3. The Shell panel at the bottom should show a MicroPython banner and a >>> prompt.

Thonny can also install the firmware for you: the interpreter settings (under the Run menu) have a button for installing or updating MicroPython.

Try the REPL

Anything you type at the >>> prompt runs on the Pico straight away. Switch the onboard LED on and off:

>>> from machine import Pin
>>> led = Pin("LED", Pin.OUT)
>>> led.on()
>>> led.off()

Two keys worth knowing in the Shell: Ctrl-C interrupts a running program, and Ctrl-D soft-reboots MicroPython, printing the version and board it was built for.

Why the LED is called "LED"

Board Onboard LED connects to
Pico, Pico 2 GPIO 25
Pico W, Pico 2 W the wireless chip, not a GPIO pin

So Pin(25) only lights the LED on the non-wireless boards. The name "LED" works on all four, provided you flashed the matching firmware. If the LED stays dark on a W board, you've probably loaded the plain Pico build. To check which build is running:

>>> import sys
>>> sys.implementation._machine
'Raspberry Pi Pico W with RP2040'

Type this into Thonny's main editor:

from machine import Pin
import time

led = Pin("LED", Pin.OUT)

while True:
    led.toggle()
    time.sleep(0.5)

Click Run. Thonny asks where to save the file: choose the Pico (listed as "Raspberry Pi Pico" or "MicroPython device") and call it blink.py. The LED flips on and off every half second. Click Stop to end it.

Run it at power-up

MicroPython looks for a file called main.py on the board each time it starts, and runs it if it's there. Use File → Save as, pick the Pico, and save your program as main.py. Now it runs whenever the board gets power, from a computer, a USB charger or a battery, with no computer needed.

To test without unplugging, press Ctrl-D in the Shell. To stop a program starting automatically, open View → Files, which shows the Pico's storage beside your computer's, and rename or delete main.py.

Starting from scratch

If you want a completely clean board, Raspberry Pi publishes a nuke_universal.uf2 file (in the releases of its pico-sdk-prebuilts repository on GitHub). Copy it across in BOOTSEL mode and it erases the whole flash, MicroPython and your files included. Then install the firmware again as above.

Parts in this guide

Maddy from the Pi Australia team

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.