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 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:

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.


Page last edited November 07, 2024
Text editor powered by tinymce.