Raspberry Pi 2W Pico

../_images/Pico-2W.jpg

The Raspberry Pi Pico 2 is a low-cost microcontroller board from the Raspberry Pi Foundation. It supports programming in CircuitPython, MicroPython, and C++. We will be using CircuitPython, which needs to be installed once on each new board.

This is the 2W version of the part, the “2” meaning it is the second major version of the part, and the “W” meaning it includes a WiFi interface chip.

Pico 2W Features

The board includes many I/O pins but no on-board sensors. The only I/O device is a single green LED. The core specifications include:

  • RP2350 microcontroller chip designed by Raspberry Pi in the United Kingdom

  • Dual Cortex-M33 or Hazard3 processors at up to 150MHz

  • 520KB of SRAM, and 4MB of on-board flash memory

  • USB 1.1 with device and host support

  • Low-power sleep and dormant modes

  • Drag-and-drop programming using mass storage over USB

  • 26× multi-function GPIO pins including 3 that can be used for ADC

  • 2× SPI, 2× I2C, 2× UART, 3× 12-bit 500ksps Analogue to Digital Converter (ADC), 24× controllable PWM channels

  • 2× Timer with 4 alarms, 1× AON Timer

  • Temperature sensor

Pico 2W Pinout Diagram

../_images/pico-2-w-pinout.png

CircuitPython Firmware Installation

The Pico ships with a permanent bootloader in firmware but without CircuitPython onboard. Installation of the CircuitPython firmware is as easy as copying a file to a USB stick, but there are a few steps to prepare.

The basic process for installing CircuitPython is as follows:

  1. You will need a Raspberry Pi Pico 2W and a USB micro-B cable compatible with your computer.

  2. Download a current stable CircuitPython installer for this particular board. This will be a .uf2 file from https://circuitpython.org/board/raspberry_pi_pico2_w/. Multiple language translations are available.

  3. Locate the white BOOTSEL pushbutton on the Pico. It’s the only switch, on the top side close to the micro-USB connector.

  4. Press and hold BOOTSEL while connecting the USB cable. Note: holding down the switch is not strictly necessary for the very first installation, but is needed to enter firmware mode for subsequent updates.

  5. If successful, a new ‘drive’ will be mounted on your computer as RP2350.

  6. Copy the CircuitPython .uf2 file that you downloaded to this drive RP2350; drag-and-drop works fine.

  7. After a brief delay, RP2350 will disappear, a new ‘drive’ called CIRCUITPY will appear, and a new USB serial port will become available.

After installing the core system, you can test it using your terminal emulator to interact directly with the CircuitPython command line.

CircuitPython Programming

Please see CircuitPython Introduction for a general guide to getting started with CircuitPython. This section will address only the details specific to the Pico 2W.

The Pico 2W plugs into a USB port on your computer using a micro-B USB cable. This has three effects:

  1. the Pico presents itself as a virtual ‘disk drive’ for programming

  2. the Pico provides a virtual serial port for console text interaction

  3. the port powers the Pico enough for computing and sensing (although not actuation)

Now you may try out the course-supplied Pico sample code by copying the corresponding .py file into the CIRCUITPY drive as code.py. A good starting point is Introductory Examples - Raspberry Pi Pico.

For online examples, you can simply cut and paste into code.py using your Python editor. The default behavior is that saving a new version of code.py on CIRCUITPY will trigger a reload and it will immediately run. Syntax errors will generate messages on the serial console.

Note: It is convenient to edit your code directly on the Pico, but please remember to back up your code.py files to a laptop for documentation and reference.

Optional CircuitPython Library Installation

If you wish to install additional modules to support particular hardware, you’ll also need to download a CircuitPython Library Bundle.

Note that the bundle is not specific to the Pico, but the major version must match your CircuitPython firmware version.

  1. Download the matching release of the CircuitPython library bundle from https://circuitpython.org/libraries. This will be .zip file containing a large number of .mpy library files and sample code.

  2. Unpack the zip file in a convenient place on your desktop or laptop. You’ll be installing just a subset of files.

  3. Locate the specific modules withing the lib/ folder of the unpacked zip. These may be individual .mpy files or sub-folders. Copy them as-is into the lib/ folder on your CIRCUITPY drive, preserving any folder structure. For example, adafruit_motor/ is a subfolder containing individual files for several types of motor.

  4. You may also wish to explore the examples/ folder of the zip file. These are Python sources which demonstrate usage of the libraries.

  5. You may need to add additional modules if an installed module has dependencies. The requirements/ folder of the zip has machine-readable specifications which include dependencies.

Tutorials and Information Online

Please see CircuitPython Programming Documentation for general CircuitPython programming information.

The following notes may help guide you to board-specifice Pico information online.

  1. Adafruit Store - Raspberry Pi Pico 2W with Header. This is the purchasing page at Adafruit, one of many sources for the board.

  2. Raspberry Pi Foundation - Pico-series Microcontrollers. Specifications, MicroPython guide, C/C++ guide, pinouts, design files.

  3. Raspberry Pi Foundation - Pico 2W pinout diagram.

  4. CircuitPython Pico 2W Downloads

  5. networking with CircuitPython

Technical Notes

Variants

There are now several variants of the Raspberry Pi Pico. Current details can be found at https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html

  • Pico (stocked as lab part 1005: https://ioref.org/parts/1005)

  • Pico H, same but with pre-soldered header pin (also stocked as lab part 1005: https://ioref.org/parts/1005)

  • Pico W, includes WiFi interfaces

  • Pico WH, includes WiFi interface and pre-soldered header pins

  • Pico 2, based on faster RP2350 chip, 520KB memory

  • Pico 2W, also includes a WiFi transceiver