Getting Started with the Raspberry Pi Pico 2 W

Ari Mahpour
|  Created: February 28, 2025
Getting Started with the Raspberry Pi Pico 2 W

The Raspberry Pi has, arguably, revolutionized the way we use single-board computers (SBCs), making powerful yet affordable development platforms accessible to hobbyists, educators, and engineers alike. Some might argue that Arduino played just as big of a role, but realistically, it operates at a much lower level, built for microcontroller-based projects rather than full-fledged computing.

That’s where the Raspberry Pi Pico 2 W comes in. It sits right in between these two worlds—a microcontroller with serious power, built-in wireless connectivity, and enough peripherals to keep an engineer happy as a clam. It won’t run a full Linux OS like a Pi 5, but with dual-core Cortex-M33 and RISC-V processors, Bluetooth 5.2, and significantly more RAM and flash storage than your typical Arduino, it offers a level of flexibility that makes it a compelling choice for embedded systems, IoT applications, and beyond.

In this article, we’re going to look at how to get started with the Raspberry Pi Pico 2 W and run through an example that showcases the new onboard Bluetooth capabilities.

Setting Up

To get started, we’re going to be using MicroPython on the Raspberry Pi Pico 2 W. You’ll need to download the UF2 Bootloader from the Micropython website first. Now, hold on the BOOTSEL button on the Raspberry Pi Pico 2 W device while plugging it into your computer (via the MicroUSB port/cable). This will turn your device into a storage device (just like a flash drive or MicroSD card shows up on your computer). Now copy the UF2 file onto your Raspberry Pi Pico 2 W “storage” device, unplug the USB cable, and plug it back in. Using your favorite serial terminal device such as PuTTY or TeraTerm connect to the COM port that shows up for your device, and you should be greeted with the MicroPython shell interpreter:

Figure 1: MicroPython shell interpreter via serial communication over USB
Figure 1: MicroPython shell interpreter via serial communication over USB

Using VSCode (over Thonny) and LED Blinker

In Getting Started with MicroPython and the Raspberry Pi Pico, we used the Thonny IDE as the editor to write code and load up the Raspberry Pi Pico 2 W device. With the introduction of AI embedded into code editors and extensions up the wazoo, I decided to baseline my environment with VSCode over Thonny. The most important thing to do first (aside from installing VSCode) is to install the official Raspberry Pi Pico extension (published by Raspberry Pi).

Once the extension has been installed, you’ll see a little Raspberry Pi Pico board icon on the left-hand side of your VSCode window (just like where the rest of the extensions live). Click on that and then navigate to “New MicroPython Project” under “General.” Give your project a name and path, and hit “Create.”

Figure 2: Creating a New Project
Figure 2: Creating a New Project

A new editor will open up with just a few files and a MicroPython shell. One of those files is an example LED blink Python file. Open up that blink.py. At this point, you’ll want to make sure that your Raspberry Pi Pico 2 W device is plugged in. At the very bottom of your VSCode editor, you will see a little play button. 

Figure 3: The “Run” Button in VSCode
Figure 3: The “Run” Button in VSCode

This will run blink.py directly on the device (by loading it onto the device first). At this point, you should see a print statement and your LED flashing:

Figure 4: Terminal Output of LED Programming Running
Figure 4: Terminal Output of LED Programming Running

The Run button turns into a Stop button which stops the execution of the code. Once you confirm that the LED blinks we’re now ready to move onto a more sophisticated example.

Bluetooth Proximity Sensor

Now that we've confirmed our Raspberry Pi Pico 2 W is up and running with MicroPython, let's explore one of its most exciting new features—Bluetooth 5.2. This example turns your Pico device into a Bluetooth proximity scanner capable of detecting nearby bluetooth devices (such as smartphones) and determines their signal strength (RSSI). The script, bluetooth_scan.py, operates in two modes: Discovery Mode, which scans for all nearby devices and prints their MAC addresses, and Track Mode, where the Pico continuously monitors a specific device, turning on an LED when it is in close range. This tracking mode is useful for detecting specific Bluetooth devices close by in real-time, though some, like Apple devices, randomize their MAC addresses for privacy reasons.

To achieve this, we use MicroPython’s Bluetooth API, specifically bluetooth.BLE(), to initialize the Pico's Bluetooth interface. The script listens for Bluetooth Low Energy (BLE) advertisement packets using gap_scan(), which repeatedly scans for a given duration and processes the results through an event handler (bt_irq). This event-driven approach allows the Pico to react instantly when a new device is detected (think “interrupts” on more bare metal approaches). Devices are filtered based on their RSSI (Received Signal Strength Indicator), which helps estimate proximity. Closer devices typically have stronger signals (higher RSSI values, which translates to less negative db values), and further devices have weaker signals (i.e., a more negative db value). The Track Mode compares detected MAC addresses against a predefined target and turns on the onboard LED when a match is found. The scanning parameters are carefully selected to balance real-time responsiveness with CPU efficiency, preventing the Pico from being overwhelmed while continuously monitoring Bluetooth signals.

To run the script, simply open bluetooth_scan.py and click the Run button (as we saw with the blink example above) to retrieve the MAC addresses of nearby devices. 

Figure 5: Running in “Discovery” Mode
Figure 5: Running in “Discovery” Mode

Then, update the script with a specific MAC address and switch to Track Mode to detect when that device moves within range. This can be found in the main function at the bottom of the script:

# To track a specific device (replace with discovered MAC address)
# scanner = BLEScanner(mode="track", target_mac="aa:bb:cc:dd:ee:ff")

Figure 6: Running in “Tracking” Mode
Figure 6: Running in “Tracking” Mode

The scanning parameters have been optimized to ensure responsive detection without blocking other operations, making this a great introduction to Bluetooth scanning and event handling on the Raspberry Pi Pico 2 W.

Conclusion

The Raspberry Pi Pico 2 W is an exciting addition to the embedded development world, striking a perfect balance between the flexibility of a microcontroller and the power of built-in wireless connectivity. With MicroPython, we’ve seen how easy it is to get up and running, from blinking an LED to leveraging the onboard Bluetooth 5.2 module for real-time proximity detection. The Bluetooth proximity scanner we implemented introduces fundamental concepts like BLE scanning, event-driven programming, and signal strength analysis, demonstrating just how much can be accomplished with such minimal code.

While this was just a basic example, the Pico 2 W opens up a whole new range of possibilities for IoT applications, real-time tracking, and wireless automation. Whether you're a hobbyist experimenting with BLE peripherals or an engineer developing next-gen embedded systems, this little device proves itself to be a powerhouse in a tiny package. And this is just the beginning—there’s still Wi-Fi, low-power optimizations, and more advanced BLE interactions to explore. The Raspberry Pi Pico 2 W is small, but it packs a serious punch.

To view the repository containing all the code to get started, visit https://gitlab.com/embedded-designs/micropython-bluetooth-example.

About Author

About Author

Ari is an engineer with broad experience in designing, manufacturing, testing, and integrating electrical, mechanical, and software systems. He is passionate about bringing design, verification, and test engineers together to work as a cohesive unit.

Related Resources

Related Technical Documentation

Back to Home
Thank you, you are now subscribed to updates.