Overview
One of the great features of CircuitPython is that you can edit your code with a simple text editor - no integrated development environment (IDE) required! But what if you do want to use an IDE? You can use the CircuitPython v2 extension for VS Code for a fully featured CircuitPython development experience - including the REPL.
The CircuitPython v2 extension is easily installed from the extensions tab in VS Code. After installation, you can open your CIRCUITPY drive with VS Code and access your connected CircuitPython board over the serial monitor or REPL.
Install VS Code
Before following this guide, you'll need to install VS Code on your computer. Microsoft has extensive documentation detailing the installation process and features available in VS Code.
Page last edited December 10, 2024
Install the CircuitPython Extension for VS Code
Click on the Extensions tab in VS Code. Search for CircuitPython. Click Install for CircuitPython v2 by wmerkens.
You can confirm the installation by going to your Extensions tab and searching under the Installed column.
Page last edited December 10, 2024
Use the CircuitPython Extension for VS Code
Connect your CircuitPython board to your computer with a known good data USB cable. Next, you'll connect to the board using the CircuitPython extension.
You'll see the contents of your CIRCUITPY drive appear in VS Code. The CircuitPython extension activates when any of these files are opened in VS Code:
- code.py
- code.txt
- main.py
- main.txt
- boot_out.txt
By opening your CIRCUITPY drive, the extension is now activated.
At the bottom of the VS Code window, you'll see text that says <Choose a board> and a little plug icon. Select the plug icon.
In the search bar at the top of VS Code, you'll see Select a serial port appear in the bar. In the dropdown, you should see your CIRCUITPY drive board name and its COM port. Click on the board.
This connects to the Serial Port on your board. At the bottom of the VS Code window, you'll see your board name appear. If you select the Circuit Python Serial Monitor in the terminal tab, you'll see that the board COM port is opened and you can access the REPL by entering CTRL+C.
Using the Serial Monitor and REPL
Press CTRL+D, you should see a soft reboot occur and your code.py file should run.
In the serial monitor above, this simple code.py file is running where the value of i increases by 1 every second and prints to the serial monitor.
You can also enter the REPL by entering CTRL+C. Test this out by entering print("hello world"). You should see hello world print back.
Accessing Special Commands
The CircuitPython extension has special commands available for accessing the serial monitor and library management with circup, a command line tool to manage and update libraries on a CircuitPython device. You can even access a quick link to your board on circuitpython.org.
In the search bar at the top of VS Code, click in the bar. A dropdown menu will appear. Select Show and Run Commands.
Page last edited December 10, 2024