Getting Started with Raspberry Pi Pico W
Getting Started with Raspberry Pi Pico W
Flash MicroPython, set up Thonny, and run your first program.
What is the Raspberry Pi Pico W?
The Raspberry Pi Pico W is a low-cost microcontroller board built around the RP2040 chip designed by Raspberry Pi. The "W" variant adds built-in WiFi (2.4 GHz 802.11n) via a CYW43439 chip.
Key specs:
- Dual-core ARM Cortex-M0+ at up to 133 MHz
- 264 KB SRAM
- 2 MB on-board Flash
- 26 multi-function GPIO pins
- 2G— SPI, 2G— I2C, 2G— UART, 3G— ADC (12-bit)
- Built-in WiFi (Pico W) and optional Bluetooth (Pico WH)
- Micro-USB for power and programming
- 3.3 V I/O (NOT 5 V tolerant)
Programming Languages
The Pico W supports three main approaches:
- MicroPython ߀” easiest to start with, ideal for beginners and quick prototypes
- CircuitPython ߀” similar to MicroPython, maintained by Adafruit
- C/C++ SDK ߀” maximum performance and control, steeper learning curve
This guide focuses on MicroPython ߀” the most beginner-friendly path.
Flashing MicroPython
- Download the latest MicroPython .uf2 file for Pico W from micropython.org/download/rp2-pico-w/
- Hold the BOOTSEL button on the Pico W
- While holding BOOTSEL, plug in the USB cable
- The Pico W appears as a USB drive named RPI-RP2
- Drag and drop the
.uf2file onto the drive - The drive disappears and the Pico W restarts ߀” MicroPython is now installed
Setting Up Thonny IDE
Thonny is the recommended IDE for MicroPython on Pico W:
- Download Thonny from thonny.org
- Open Thonny and go to Tools ߆’ Options ߆’ Interpreter
- Select MicroPython (Raspberry Pi Pico)
- Choose the correct COM port (or let Thonny detect it)
- Click OK ߀” Thonny connects to the Pico W REPL
Your First Program ߀” Blink
from machine import Pin
from time import sleep
led = Pin("LED", Pin.OUT) # "LED" is the built-in LED on Pico W (GPIO 25 on Pico)
while True:
led.toggle()
sleep(0.5)
Click Run (F5) in Thonny to run it. The green LED on the board will blink every 0.5 seconds.
Saving to the Pico W
- Run ߆’ Run current script (F5): runs the file once from your PC
- File ߆’ Save as ߆’ Raspberry Pi Pico: saves the file onto the Pico W's flash
- Save your main program as
main.py߀” it will run automatically every time the Pico W powers on
The REPL
The REPL (Read-Eval-Print Loop) is an interactive Python prompt ߀” type commands and see instant results. In Thonny, click in the Shell area at the bottom.
>>> from machine import Pin
>>> led = Pin("LED", Pin.OUT)
>>> led.on() # LED turns on immediately
>>> led.off()
Pin Numbering
| Reference | Example | Notes |
|---|---|---|
| GPIO number | Pin(15) |
Physical GPIO number, not pin header number |
| "LED" | Pin("LED") |
Built-in LED (Pico W uses CYW43 GPIO, not a numbered pin) |
| Pin header | Board printed numbers | Physical positions 1߀“40 ߀” different from GPIO numbers |
Always check the Pico W pinout diagram ߀” the physical pin numbers on the header are NOT the same as GPIO numbers.
Common First Steps
# Print to Thonny Shell
print("Hello, Pico W!")
# Read the unique board ID
import machine
print(machine.unique_id())
# Check available memory
import gc
gc.collect()
print(gc.mem_free(), "bytes free")