Getting Started with Raspberry Pi Pico 2 and Pico 2 W

The Raspberry Pi Pico 2 is the successor to the original Raspberry Pi Pico (Pico 1). It’s a microcontroller developed by the Raspberry Pi Foundation, built around the RP2350 chip. It offers a wide range of GPIO pins for connecting peripherals and can be programmed using MicroPython or C/C++. If you’re already familiar with the first version of the Pico, working with the Pico 2 will feel the same. Just make sure to load the correct firmware for its processor

Getting Started with Raspberry Pi Pico 2 and Pico 2W

Learn more about the Raspberry Pi Pico with our eBook: Learn Raspberry Pi Pico with MicroPython (eBook).

Table of Contents

In this tutorial, we’ll cover the following subjects:

Introducing the Raspberry Pi Pico 2 and Pico 2 W

The Raspberry Pi Pico 2 is the successor of the Raspberry Pi Pico. It uses the RP2350 chip. It is a microcontroller board like the ESP32 or ESP8266 (not a microcomputer like the Raspberry Pi).

Raspberry Pi Pico 2 W

Here’s a list of the main features of the Raspberry Pi Pico 2

  • RP2350 microcontroller chip
  • 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 (as less as 10uA )
  • 26× multi-function GPIO pins
  • SPI, 2× I2C, 2× UART, 3× 12-bit 500ksps Analog to Digital Converter (ADC), 24× controllable PWM channels
  • 2× Timer with 4 alarms, 1× AON Timer
  • Built-in temperature sensor
  • 3 × Programmable IO (PIO) blocks, 12 state machines total for custom peripheral support
    • Flexible, user-programmable high-speed IO
    • Can emulate interfaces such as SD Card and VGA

When it comes to the wireless interface and Bluetooth:

  • Wireless (802.11n), single-band (2.4 GHz) (Infineon CYW43439)
  • WPA3
  • Soft access point supporting up to four clients
  • Bluetooth 5.2
    • Support for Bluetooth LE Central and Peripheral roles
    • Support for Bluetooth Classic

Where to Buy Raspberry Pi Pico 2?

The Raspberry Pi Pico 2 W board is widely available on many different stores. Check the following link to compare its price on different stores:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

You may also like: Raspberry Pi Pico: Web Server (MicroPython).

Variants of the Raspberry Pi Pico 2 Board

There are two variants of this board: the Raspberry Pi Pico 2 and the Raspberry Pi Pico 2 W. The latter adds wireless capabilities: Wi-Fi, and Bluetooth.

Raspberry Pi Pico 2 and Raspberry Pi Pico 2 W
Raspberry Pi Pico 2 W, and Raspberry Pi Pico 2

What Raspberry Pi Pico Board Should You Get?

The Raspberry Pi Pico 2 W includes wireless connectivity, making it ideal for IoT and home automation projects that require Wi-Fi or Bluetooth. We recommend getting a Raspberry Pi Pico W, as the price difference is not significant, and you’ll have the flexibility to use Wi-Fi or Bluetooth if needed.

Raspberry Pi Pico 2 W

Main Differences Between the Raspberry Pi Pico and Pico 2

The Raspberry Pi Pico W and Pico 2 W are similar in many ways, making it easy to switch between them. They have the same form factor, the same pinout, and the way they work and how you program them is also similar.

Raspberry Pi Pico vs Raspberry Pi Pico 2

They differ slightly in hardware and performance. If you’re familiar with the Pico W, the Pico 2 W will be a smooth upgrade with the same pinout and MicroPython commands. However, you’ll need to load the correct MicroPython firmware for the RP2350 chip (Pico 2 W) instead of the RP2040 (Pico W). If you’re using Arduino IDE, you’ll need to select the corresponding board.

Here are the main differences when using the Pico 2/ Pico 2 W board:

  • More Processing Power, Increased Memory, and Storage: the Pico 2 W is faster, more powerful (RP2350 SoC), and better suited for complex projects, with double the memory and storage (520 KB SRAM and 4 MB Flash).
  • More Power Efficient: It’s also now more power-efficient, which means it’s better for battery-powered projects.
  • Advanced Security Features: the Pico 2 W offers advanced security features like Secure Boot and Arm TrustZone, while the Pico W has only basic security.
  • The Same Wi-Fi and Bluetooth Features: both boards use the same Infineon CYW43439 chip for Wi-Fi and Bluetooth.

All our previous Raspberry Pi Pico projects work on the Raspberry Pi Pico 2.

Here’s a table highlighting the main differences between the two boards.

Raspberry Pi Pico WRaspberry Pi Pico 2 W
ChipRP2040 (Dual-core, 133 MHz)RP2350 (Dual-core, 150 MHz)
Memory (SRAM)264 KB520 KB
Storage (FLASH)2 MB4 MB
Sleep Mode (comsumption)100 uA10 uA
Wi-Fi/BluetoothInfineon CYW43439 Infineon CYW43439
SecurityNoneArm TrustZone, 8KB OTP, Secure Boot
Language SupportMicroPython, CircuitPython, C, C++MicroPython, CircuitPython, C, C++

Raspberry Pi Pico 2 GPIO Interfaces

The Raspberry Pi Pico comes with 40 pins, 26 of which are programmable GPIOs that you can use to connect peripherals.

Pico 2 W GPIO Interfaces

The Raspberry Pi Pico 2 supports the following peripheral interfaces on its GPIOs:

  • 2x UART
  • 2x I2C
  • 2x SPI
  • 24x PWM channels (8 slices, 3 channels each)
  • 3x ADC pins (12-bit 500ksps)

The Raspberry Pi Pico GPIOs run at 3.3V.

Raspberry Pi Pico 2 Pinout

The pinout of the Raspberry Pi Pico 2 is the same as version 1 of the Pico. Check the following pictures for the Raspberry Pi Pico 2 and Pico 2 W pinouts.

Raspberry Pi Pico 2 Pinout

Raspberry Pi Pico 2 Pinout
Image source: raspberrypi.com

Raspberry Pi Pico 2 W Pinout

Raspberry Pi Pico 2 W Pinout
Image source: raspberrypi.com

The pins marked in red are power pins that output 3.3V or 5V. The black pins are GND pins. All pins in light green can be used as “regular” GPIOs (input and output), and all can generate PWM signals.

SPI, I2C, UART communication protocols, and ADC are supported on the pins with the corresponding labels.

To learn more about the Raspberry Pi Pico GPIOs, check out our guide (this is applicable for all versions of the Raspberry Pi Pico): Raspberry Pi Pico and Pico W Pinout Guide: GPIOs Explained.

How to Program the Raspberry Pi Pico 2 / Pico 2 W?

The Raspberry Pi Pico 2 (like the previous versions) can be programmed using C/C++ programming language (using Arduino IDE) or MicroPython. Currently, MicroPython is the most popular way to program the Raspberry Pi Pico, and Thonny IDE is the recommended IDE to use with the Raspberry Pi Pico.

Raspberry Pi Pico 2 W Board

The Raspberry Pi Pico 2 comes with a micro USB port that can be used for both power and programming. To program the Raspberry Pi Pico, you just need to use a USB cable to connect the board to your computer. Most Raspberry Pi Pico kits include the proper USB cable.

If you want to start programming the Raspberry Pi Pico using Arduino IDE instead, jump to the Arduino IDE section here.

If you want to use MicroPython, continue reading.

Programming Raspberry Pi Pico 2 with MicroPython

micorpython logo

MicroPython is a Python 3 programming language re-implementation targeted for microcontrollers and embedded systems. MicroPython is very similar to regular Python. Apart from a few exceptions, the language features of Python are also available in MicroPython. The most significant difference between Python and MicroPython is that MicroPython was designed to work under constrained conditions.

Because of that, MicroPython does not come with the entire pack of standard libraries. It only includes a small subset of the Python standard libraries, but it includes modules to easily control and interact with the GPIOs, use Wi-Fi, and other communication protocols.

Installing Thonny IDE

Thonny IDE is the recommended software to program the Raspberry Pi Pico board using MicroPython, and that’s the one we’ll use in this tutorial.

Thonny IDE can also be used to program the ESP32 and ESP8266 using MicroPython firmware. Learn more here: Getting Started with Thonny MicroPython (Python) IDE for ESP32 and ESP8266.

Go to this link https://thonny.org/ and click on the right link to download the package for your operating system.

Download Thonny IDE

Run the downloaded executable file and follow the installation procedure (use all the default settings).

Flashing MicroPython Firmware on Raspberry Pi Pico

Connect the Raspberry Pi Pico to your computer while holding the BOOTSEL button at the same time so that it goes into bootloader mode to flash the firmware.

Put Raspberry Pi Pico 2 into Boot Mode

It will open a new window on your computer as a new USB device, you can ignore and close that window.

Open Thonny IDE.

Go to Tools > Options. Select the Interpreter tab on the new window that opens.

Thonny IDE Tools Options

Select MicroPython (Raspberry Pi Pico) for the interpreter, and the Try to detect port automatically for the Port. Then, click on Install or update MicroPython.

Thonny IDE Select Interpreter

The following window will open.

Install MicroPython Raspberry Pi Pico 2 Thonny IDE

Select the MicroPython variant accordingly to the board you’re using. In our case, we’re using the Pico 2 W. Select a different option if you’re using the Pico 2 (without W).

Finally, click Install.

After a few seconds, the installation should be completed.

Installing MicroPython Raspberry Pi Pico 2 Thonny IDE

You can close the window. You should get the following message on the Shell, and at the bottom right corner, it should have the Interpreter it’s using and the COM port.

running executing MicroPython Raspberry Pi Pico 2 Thonny IDE

If it doesn’t recognize the device, and you have a message saying “no backend” in the bottom-right corner, it may be the case that it is not detecting the COM port automatically. If that’s the case, go to Tools > Options > Interpreter and select the COM port manually. After that, it should recognize the MicroPython device, and you should get the previous message.

Testing the Installation

Type help() in the Shell and see if your device responds back.

Raspberry Pi Pico 2 Thonny IDE MicroPython help

It should print some useful information about programming the Raspberry Pi Pico board using MicroPython.

Type the following:

print('Hello')

It should print Hello on the Shell.

Thonny IDE Testing Shell

If you’ve followed until this step, you should have Thonny IDE successfully installed, as well as MicroPython firmware on your Raspberry Pi Pico board.

Running Your First Script

To get you familiar with the process of writing a file and executing code on the Raspberry Pi Pico 2 board, we’ll upload a new script that simply blinks the on-board LED.

Blinking an LED Script

When you open Thonny IDE for the first time, the Editor shows an untitled file. Copy one of the following scripts to that file:

from machine import Pin
from time import sleep
led = Pin('LED', Pin.OUT)
while True:
  led.value(not led.value())
  sleep(0.5)

Running the Script

To run that script on your board, simply click on the Run icon in Thonny IDE.

Thonny IDE Run File

The onboard LED will start blinking.

To stop the execution of the program you can hit the STOP button or simply press CTRL+C.

Thonny IDE Stop button

Important note: just running the file with Thonny doesn’t copy it permanently to the board’s filesystem. This means that if you unplug it from your computer and apply power to the board, nothing will happen because it doesn’t have any Python file saved on its filesystem. The Thonny IDE Run function is useful to test the code, but if you want to upload it permanently to your board, you need to create and save a file to the board filesystem. See the next section.

Saving the Script to the Raspberry Pi Pico Board

Stop the execution of the previous program by clicking on the Stop button if you haven’t already.

With the code copied to the file, click on the Save icon. Then, select Raspberry Pi Pico.

Thonny IDE Save File to Raspberry Pi Pico

Save the file with the following name: main.py.

Note: When you name a file main.py, the Raspberry Pi Pico will run that file automatically on boot. If you call it a different name, it will still be saved on the board filesystem, but it will not run automatically on boot.

Finally, click OK to proceed.

Now, you can remove and apply power again to the board, or you can even power it using a different power supply that is not your computer. You’ll notice that the board will automatically start blinking the LED when it starts.

Raspberry Pi Pico W onboard LED on

Programming the Raspberry Pi Pico 2 Using Arduino IDE

If you prefer to program the Raspberry Pi Pico 2 using Arduino IDE, follow this section.

Installing Arduino IDE

Before proceeding, you need to install Arduino IDE on your computer. Install version 2 of the Arduino IDE. You can download and install Arduino IDE by clicking on the following link:

Adding the Raspberry Pi Pico to the Boards Manager

1. In the Arduino IDE, go to File > Preferences.

Arduino IDE Preferences

2. Enter the following URL into the “Additional Boards Manager URLs” field:

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

Then, click the “OK” button:

Additional Boards Manager URL Arduino IDE 2

Note: if you already have the ESP32 and/or ESP8266 boards URLs, you can separate the three URLs with a comma as follows:

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json, https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json

3. Open the Boards Manager. Go to Tools > Board > Boards Manager…

4. Search for “pico” and install the Raspberry Pi Pico/RP2040/RP2350 boards by Earle F. Phillhower.

Install Raspberry Pi Pico 2 Boards Arduino IDE 2

5. That’s it. It will install after a few seconds.

6. Now, if you go to Tools > Board, there should be a selection of Raspberry Pi Pico boards.

Raspberry Pi Pico Board Options Arduino IDE 2

Now you have everything prepared to start programming your Raspberry Pi Pico board using Arduino IDE. Don’t connect the board to your computer yet.

1. Selecting your Pico Board

Go to Tools > Board and select the Raspberry Pi Pico model you’re using—Pico 2 or Pico 2 W (wireless support).

2. Loading the Blink LED Sketch

As an example, we’ll upload the classic Blink LED sketch. Go to File > Examples > 1. Basic > Blink.

The following example should load.

Programming the Raspberry Pi Pico Using Arduino IDE Blink LED sketch

Or you can copy the following code:

/*
  Blink -  Turns an LED on for one second, then off for one second, repeatedly.
  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at: https://www.arduino.cc/en/Main/Products
  modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi modified 8 Sep 2016 by Colby Newman  This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
  
  Programming Raspberry Pi Pico with Arduino IDE: https://RandomNerdTutorials.com/programming-raspberry-pi-pico-w-arduino-ide/
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

View raw code

3. Connecting the Raspberry Pi Pico in BOOTLOADER mode

For you to be able to upload code to the Raspberry Pi Pico, it needs to be in bootloader mode.

If the Raspberry Pi is currently running MicroPython firmware, you need to manually put it into bootloader mode. For that, connect the Raspberry Pi Pico to your computer while holding the BOOTSEL button at the same time. A new mass storage device window will open on your computer. You can ignore it and close that window.

Put Raspberry Pi Pico 2 into bootloader mode

For future uploads using Arduino IDE, the board should go automatically into bootloader mode without the need to press the BOOTSEL button.

Now, open the top drop-down menu and click on Select other board and port…

arduino IDE 2 select other board and port

For the board, select Raspberry Pi Pico 2 or Raspberry Pi Pico 2 W.

The COM port might not show up on your first upload, so you need to tick the Show all ports option. Then, select the COM port.

Arduino IDE 2 select Raspberry Pi Pico COM port.

Now, you can upload the code.

Arduino IDE 2 Upload Button

You should get a success message.

Upload code to Raspberry Pi Pico 2 using Arduino IDE OK

Demonstration

If everything went as expected, the Raspberry Pi Pico onboard LED should be blinking every second.

And that’s it. You successfully programmed your Raspberry Pi Pico 2 using Arduino IDE.

You may also like: Learn Raspberry Pi Pico with MicroPython eBook

Wrapping Up

The Raspberry Pi Pico 2 is the successor of the Raspberry Pi Pico (version 1). It has a better processor, it’s faster, has more memory and storage. At the same time, it is quite similar to the previous versions. It uses the same form factor, pinout, and the commands to program it are the same.

We hope this guide has helped you getting started or upgrading to the Raspberry Pi Pico 2 boards.

If you want to learn more about the Raspberry Pi Pico, check out our resources:



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

8 thoughts on “Getting Started with Raspberry Pi Pico 2 and Pico 2 W”

    • Hi.
      The Raspberry Pi Pico is a better choice if you prefer to program with micropython.
      I found that the ESP#2 doesn’t work as well as the pico when it comes to micropython.

      Regards,
      Sara

      Reply
    • ESP chips perform very poorly in terms of power consumption. For BLE, an NRF52840 has a ca. 20mA current draw vs. 80mA on any ESP chips, i.e. former have a multiple of battery life. If you are on a battery, ESPs are a no go.

      Reply
      • Peter,

        So far my use of ESP32 has been in systems such that the power consumption of the micro is a negligible proportion of the total. However, I will have a need for a battery powered application soon so I’ll keep your comments in mind. Many thanks.

        Reply
    • The Pico has a few minor advantages over the ESP32 but the main one is that it has 8 (Pico) or 12 (Pico 2) state machines that can execute an instruction per clock cycle independently of how busy is the main CPU.
      This is invaluable if you need high speed I/O devices like a Signal Generator, Frequency Meter or Logic Analyzer. They will be far more superior that the ones with ESP32.
      Plus, you can overclock a Pico to more than double its nominal frequency.

      Reply
  1. A small correction in your text. “Low-power sleep and dormant modes (as less as u10 mA)”. has to be as less as 10 uA

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.