This guide will show you how to use a Raspberry Pi Pico RP2040 to connect various sensors and breakouts to your PC running Windows, Mac OSX, or Linux. Special firmware gets loaded onto the Pico and turns it into a sort of Swiss army knife providing:

  • General Purpose digital Input and Output (GPIO) for things like buttons and LEDs
  • Analog to Digital Conversion (ADC) for reading analog signals
  • Pulse Width Modulation (PWM) for servos or LED dimming
  • I2C and SPI for connecting *lots* of external sensors, displays, etc.
  • NeoPixels (WS2812B) for happy rainbow blinky fun!

This is very similar to what the FT232H and MCP2221 already provide.

The u2if firmware is considered "experimental".

The approach in this guide is useful if you want to run "regular" Python code on your main computer and have it communicate with external devices connected through the Pico (or other RP2040 board). If you are instead trying to run MicroPython code directly on the Pico and use CircuitPython libraries, then see this other guide: CircuitPython Libraries on MicroPython using the Raspberry Pi Pico.

The Magical u2if Firmware

The key element to enabling this capability on the Raspberry Pi Pico is thanks to the excellent u2if firmware written by execuc. The main repo not only contains the firmware that goes on the Pico itself, but micropython compliant Python code for interfacing to the Pico from your PC. So if you're more used to the micropython interface, then checkout the u2if repo. It has everything you need.

In this guide, we will use firmware from the Adafruit fork of the original u2if project:

Then, on the host PC, we will use the Adafruit Blinka library which has support for interfacing with a Pico, or other RP2040 based boards, running the u2if firmware.

CircuitPython Libraries on Personal Computers

This is essentially the same idea as discussed  in the FT232H Guide and the MCP2221 Guide. How can we directly connect common hardware items like buttons and LEDS (GPIO) or sensor breakouts (I2C/SPI) to a PC?

By loading the u2if firmware onto the Pico, it turns it into sort of a bridge using USB on the main PC. So you end up with something like this:

On the computer, we install Blinka which provides a CircuitPython compliant interface to the Pico with u2if. That way, all the CircuitPython libraries can then be used - on your PC!

Required Hardware

The main requirement is a supported RP2040 based board. The main guide and examples are based on the original Raspberry Pi Pico RP2040:

Top view of Raspberry Pi Pico with two 20-pin male headers.
The Raspberry Pi foundation changed single-board computing when they released the Raspberry Pi computer, now they're...
In Stock

However, there are many other RP2040 based boards that are supported. See the Other RP2040 Boards section for details.

You'll need a USB cable for programming and interacting with the Pico - but you probably have one of these laying around. Just make sure it's not a charge only cable.

Beyond that, it all depends on what you want to do. There are examples provided later in this guide that show some typical use cases.

Other Hardware

If you're using STEMMA QT breakout boards, these cables can be helpful.

Top view of JST SH 4-pin to Premium Male Headers Cable next to US quarter for scale.
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium Dupont male headers on the other. Compared with the...
In Stock
Angled shot of JST SH 4-pin Cable with Premium Female Sockets.
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium female headers on the other. Compared with the chunkier...
In Stock

This guide was first published on May 01, 2021. It was last updated on Mar 08, 2024.

This page (Overview) was last updated on Mar 08, 2024.

Text editor powered by tinymce.