hack4electronics.com

Getting Started with VS Code and PlatformIO IDE

Getting Started with VS Code and PlatformIO IDE

Getting Started with VS Code and PlatformIO IDE

Learn how to setup PlatformIO IDE extension with VS Code (Microsoft Visual Studio Code) . This guide covers the installation process for Mac OS X, Windows, and Ubuntu operating systems.

The Arduino IDE is excellent for small applications. However, for advanced projects with more than 200 lines of code, multiple files, and features like auto-completion and error checking, VS Code with the PlatformIO IDE extension is the best alternative.

In this tutorial, we’ll cover:

  1. Setting up Visual Studio Code
  2. Installing PlatformIO IDE extension in VS Code

Setting Up VS Code and PlatformIO IDE

Getting up and running with Visual Studio Code is quick and easy. It’s a small download, so you can install it in a matter of minutes and give VS Code a try. VS Code is a free code editor available for macOS, Linux, and Windows operating systems.

Installation Guidelines for macOS

  1. Download Visual Studio Code for macOS.
  2. Locate the downloaded app or archive in the browser’s download list.
    • If it’s an archive, extract its contents by double-clicking or using the ‘magnifying glass’ icon with Safari.
  3. Drag Visual Studio Code.app to the Applications folder to make it available in the macOS Launchpad.
  4. Open VS Code from the Applications folder by double-clicking the icon.
  5. Add VS Code to your Dock by right-clicking on the icon in the Dock, selecting Options, and choosing Keep in Dock.

Installation Guidelines for Ubuntu

The easiest way to install Visual Studio Code for Debian/Ubuntu-based distributions is to download and install the .deb package (64-bit). You can do this either through the graphical software center or via the command line:

sudo apt install ./<file>.deb

If you’re on an older Linux distribution, you might need to run:

sudo dpkg -i <file>.deb
sudo apt-get install -f # Install dependencies

Other binaries are available on the VS Code download page.

Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system’s package manager. Alternatively, you can manually install the repository and key with the following script:

sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg

Then update the package cache and install the package:

sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders

Installation Guidelines for RHEL, Fedora, and CentOS

For RHEL, Fedora, and CentOS-based distributions, you can install the stable 64-bit VS Code from a yum repository with the following script:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null

Then update the package cache and install the package using dnf (Fedora 22 and above):

dnf check-update
sudo dnf install code # or code-insiders

By following these guidelines, you’ll have Visual Studio Code installed and ready to use with the PlatformIO IDE extension for programming your ESP32.

Installing Visual Studio Code on Windows

  1. Download the Visual Studio Code installer for Windows.
  2. Once the download is complete, run the installer (VSCodeUserSetup-{version}.exe). This process only takes a minute.
  3. By default, VS Code will be installed under C:\Users\{Username}\AppData\Local\Programs\Microsoft VS Code.
  4. Alternatively, you can download a Zip archive, extract it, and run Code directly from the extracted files.

PlatformIO IDE for VSCode

  1. Open VSCode Extension Manager
  2. Search for official PlatformIO IDE extension
  3. Install PlatformIO IDE.

Leave a Reply

Your email address will not be published. Required fields are marked *