element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog VSCode and MicroPython for the Pi Pico
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 3 Mar 2021 7:37 AM Date Created
  • Views 24909 views
  • Likes 8 likes
  • Comments 4 comments
Related
Recommended
  • micropython
  • pi pico

VSCode and MicroPython for the Pi Pico

Workshopshed
Workshopshed
3 Mar 2021

I've recently been experimenting with MicroPython on the Pi PicoPi Pico. There are a few steps you need to get this setup.

 

  • Install the MicroPython Firmware
  • Suitable editor
  • Upload the code
  • Setting the code to run at boot

 

Although it is designed for a younger audience, I found the "Getting Started with MicroPython" book to be a useful reference. I also used the pi-pico-python-sdk

image

 

Installing the firmware

Installing the firmware is covered on the the https://www.raspberrypi.org/documentation/rp2040/getting-started/ page.

 

You need to download a suitable uf2 image and then copy it to the Pi Pico as a file. Before you first plug in the Pi Pico, hold down the "BootSel" button then connect the USB. This makes the device appear as a harddisk on your computer and you can copy over the UF2 image. If you then un-plug and replug the Pico Pi it reverts to programming mode.

 

https://micropython.org/download/rp2-pico/

 

Suitable Editor

The recommendation from the Raspberry Pi foundation is Thonny, you can also use the Mu editor.  However, as I already had VSCode installed I didn't want to install yet another editor just for this project so I decided to use VSCode instead. You can use any text editor or IDE for writing your code, the Pico Pi does seem to support UTF-8 and ASCII formats for the files. As I had already done some python development with VSCode I had the extensions for syntax highlighting and intellisense already installed but needed something that would allow me to upload and run the code.

 

Upload the code

The Pico Pi defaults to being a USB Serial device. So should appear on your machine as a COM port. So for this reason some kind of tool is needed to copy the files to the board. I used the Pico-Go extension for VSCode but the Pymakr extension should also work. These provide buttons on the status bar at the bottom of the screen to upload and run the code. You can also get more options from the menus such as deleting all the files on the board or downloading the board content. Note that these work at a project level so will upload all of the files in the working folder including subfolders. The extension also gives you access to the REPL via a terminal window.

REPL is the read–eval–print loop, an interactive prompt. This allows you to run Micropython commands one at a time.

image

You can also upload code using the command line using RShell or Ampy
https://mikeesto.medium.com/uploading-to-the-raspberry-pi-pico-without-thonny-53de1a10da30

 

Setting the code to run at boot

To auto run the code, it is simply a case of having the file named "main.py". This will be run when the board starts up.

Note that there is also "boot.py", this typically sets up the hardware on the board so if you make an error in that you can stop the board working. You'll need to reflash the firmware to get your board back in operation.

  • Sign in to reply

Top Comments

  • BigG
    BigG over 4 years ago +3
    Glad I read this article. I had originally found the Pymakr extension on VSCode and thought to give it a go but it did not work straight out the box. Looks like you have to tweak the global settings to…
  • neilk
    neilk over 4 years ago +1
    Hi Andy, nice post. I've been playing around with VS Code and C/C++, trying to get the process nice and simple. MicroPython looks a lot simpler!!!!!!!!!!! I've also seen some references to Circuitpython…
  • Workshopshed
    Workshopshed over 4 years ago in reply to neilk +1
    Yes there is a Circuit Python firmware you can use. Makes putting files on easier as it just acts like a disk. As AdaFruit are making their own RP2040 board you should expect good tutorials and code available…
  • asanjib28
    asanjib28 over 3 years ago

    Hi Andy, thank you for the post!

    I am using Vscode along with Pico-go extension and found it extremely easy for a beginner like me to get started with PICO hardware. Only one thing I could not figure out is how I could add a micropython .py file into the library, so that I could import the same from my code? What is the easiest way to do this with Vscode and Pico-go? 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • BigG
    BigG over 4 years ago

    Glad I read this article.

     

    I had originally found the Pymakr extension on VSCode and thought to give it a go but it did not work straight out the box. Looks like you have to tweak the global settings to get the Pymakr terminal to connect to the Pico board. So I've now uninstalled Pymakr and switched to Pico-Go and this connected without bother.

     

    According to VSCode marketplace, Pico-Go originally was a derivative product of Pymakr but it has now received significant rewrites.

    I see there is some good docs to read through too at: Quick Start - Pico-Go

     

    Just to add... as quick start guides go, this Pico-Go guide is very good.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 4 years ago in reply to neilk

    Yes there is a Circuit Python firmware you can use. Makes putting files on easier as it just acts like a disk. As AdaFruit are making their own RP2040 board you should expect good tutorials and code available for Circuit Python.

     

    https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython

     

    The choice between Python and C is mostly about what you are familiar with. And it should be possible to compile C code as add-ons for Python meaning that you can have performance critical stuff too in Python if you need it.

     

    https://docs.micropython.org/en/latest/develop/cmodules.html

     

    For me the next thing is to look at those PIO blocks, wondering if I can use them as tone generators for a buzzer.

     

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neilk
    neilk over 4 years ago

    Hi Andy, nice post.

     

    I've been playing around with VS Code and C/C++, trying to get the process nice and simple.

     

    MicroPython looks a lot simpler!!!!!!!!!!!

     

    I've also seen some references to Circuitpython being available to load as an image on the pico, but haven't followed it up yet. Any comments?

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube