Developing for the Raspberry Pi Pico in VS Code — Getting Started

Chris Wood
All Geek To Me
Published in
3 min readJan 29, 2021

I picked up my Raspberry Pi Pico on the cover of the latest HackSpace magazine last week and have been tinkering with it ever since.

It’s been a journey in multiple ways: this is my first real attempt at physical computing and it’s meant getting used to Python, which isn’t a language I’ve ever worked with in the past. I’m more of a C# kinda guy who prefers Node when leaving my .NET comfort zone!

All of the official documentation and tutorials recommend using Thonny to get started, which I did myself and was delighted to have the onboard LED flashing on or off within a few minutes.

As good as Thonny is, though, I’d rather use one of my preferred IDEs — Visual Studio Code — and missed having any kind of code completion.

So I investigated and experimented, created two new Github repos [1, 2] and a VS Code extension, and I’m now tinkering merrily with my Pico using Code.

Here’s how to get started yourself! Part one covers all the one-time setup tasks you’ll need to perform before you begin your first project. It’s aimed at developers with some experience of coding, but doesn’t assume knowledge of Python, MicroPython or microcontrollers specifically.

The Very Basics

You’ll need a few things installed:

  • Python — download and install for your platform;
  • NodeJS — download and install the LTS version for your platform;
  • Visual Studo Code — obviously!

Once you’ve got Python installed, you’ll also want to install Pip. Download this file and then issue the following command from a terminal / Command Prompt window:

# On Linux or macOS
python get-pip.py
# On Windows
py get-pip.py

Keep a lookout for any warnings about Pip not being within your PATH environment variable. If you see such a warning, copy the path it mentions and add it into your PATH.

Also, if you’re on a Mac, launch VS Code and from the Command Palette (Command + Shift + P), choose to install the “code” command in PATH:

Other Prerequisites

Right, time to install some stuff specific to our goal: writing code in MicroPython for your Pico board!

pip install micropy-cli
pip install pylint

The Micropy CLI is used to quickly setup new projects so that they include code completion and linting (i.e. trying to detect problems and errors).

Pylint is what will actually do that linting!

Configuring Micropy CLI

In order to do our code completion and linting, Micropy CLI needs to know a little bit more about the Pico and what it can do. Specifically, it needs to know which Python modules are baked into the board for our use and which functions and properties are included in each.

This is where the first of my new Github projects comes in: Pico-Stub.

“Stubs” are what provide Micropy (and Pylint) with that intelligence. They’re generated automatically by running Python code on the Pico board itself. They’re then brought back to a normal computer and are made available for use within Micropy CLI through my repo.

Download a copy of the repo and extract the zip file. Then add the stubs to Micropy CLI:

cd Pico-Stub-main/stubs
micropy stubs add micropython-rp2-1_13-290

Other VS Code Extensions

Inside VS Code, search for and install the following two extensions:

  • ms-python.python
  • VisualStudioExptTeam.vscodeintellicode

Then install my new extension: Pico-Go. This allows you to have a REPL-based terminal session within VS Code and provides some handy shortcuts for common tasks.

And with that, you’re done! Move onto Part Two, where we’ll make an LED flash!

--

--