Replacing the Arduino IDE with VS Code & PlatformIO

Just so that we do not lose anyone, an IDE is an integrated development environment and generally as a minimum, it should contain a source code editor, build automation tools and a debugger.

It may include a Compiler / Interpreter e.g. Python, C++, Delphi, Java but quite often it will rely on separately installed language compilers which are called by the IDE.

Selecting the correct IDE can cut hours off development and debugging and managing libraries of code.

Why replace the Arduino IDE?

You might have arrived on this page and wonder why you would replace the Arduino IDE. If this was the first programming IDE you have started with, you might have felt that this was the bee’s knees, especially if you were introduced to programming by the Arduino.

Even though I have worked on several IDE’s over the years, when I first became involved in the Arduino, I loved the Arduino IDE as it allowed me to focus on the Arduino platform and what I could do with it, without looking for an appropriate IDE.

However, after a while, I started missing some of the “concepts” I was used to on other IDE’s I have used, especially when it came to debugging.

What benefits will the VS Code / PlatformIO Provide?

There are many, and the features and benefits will vary from person to person, but some of the larger ones are :

  • Unlike the Arduino Uno IDE, the system can detect the COM port that your Uno is using. Since you set up the board type at the beginning of the project, there’s no fumbling about with whether you’re using a Nano, Uno, or another board
  • VS Code with PlatformIO is a more powerful and feature-rich development environment which includes autocomplete for your code.
  • VS Code with PlatformIO supports a wide range of Microcontroller platforms and development boards which is important as you might move to other embedded platforms, but you can remain on VS Code reducing your learning curve.
  • VS Code with PlatformIO provides a comprehensive set of tools for Library Management, Continuous Integration, Unit testing and debugging.
  • VS Code with PlatformIO is an environment, one that is well trodden, well supported with new extensions to improve your efficiency being developed every day, and the best part is that it is free.
  • Git integration is possible

This link probably says it better than I can :

And here is another for good measure :

What have you got to lose?

Very little. You can keep your Arduino IDE installed whilst having VS Code / PlatformIO installed. If your timelines are tight, then you can drop back to the Arduino IDE, but if you have the time, then well worth attempting a project in VS Code / PlatformIO.

How to install VS Code and PlatformIO

There are two parts to this equation. The first is the download of the VS Code environment

You can find it for the Windows, Linux and Mac systems. In our case we are looking to install it on Windows

Which will bring you to this page

In my case, I downloaded the User Installer X64 for Windows

Once the download has finished, execute (open) the downloaded file, accept the agreement and generally accept the defaults, except under SELECT ADDITIONAL TASKS, I ticked Create a Desktop Icon and continue on with default installation settings.

Now VS Code will start up, and you will have a similar page. We immediately want to install the PlatformIO extension, so we click on

  1. The Icon shown which opens the extension market
  2. Type in platformio ide which will show the PlatformIO IDE extension available to install
  3. Click on Install

This will install the PlatformIO IDE extension

Once installed, you will now see a new icon – Alien face – which you can click on

Now I won’t take you further on this, as there are a number of websites that will take you on the journey and the following link is a great launchpad…

But I will add one more thing, if you are struggling with PlatformIO, there are many other extensions that you might be interested in…just type Arduino in the Extensions Market place and you will see a number of extensions that you can look at, including Microsoft’s Visual Studio Code extension for Arduino which appears to be a “halfway” jump from Arduino IDE and PlatformIO.

The best part is that you are now using a platform (VS Code) that will allow you to take advantage of the various options out there

Just a couple of notes

More of a quick FAQ

PlatformIO is written in pure Python & PlatformIO IDE comes with built-in portable Python 3 for Windows and macOS. YOU DO NOT NEED to install Python interpreter manually. You will come across many saying that you have to install it as it is not installed and try to install the latest and break the links causing frustration.

Other than the PlatformIO extension, to perform programming of the Arduino, no other extension is required to start programming. However, one that you do want to install to start seeing the benefits of your new environment is C/C++ IntelliSense commonly called Code Completion, just look for it in the Extensions Market place and install. Python has the same as well as many other languages.

You do not need to install a C++ compiler to get your Arduino or MCU projects to compile. When you select the board it will download the correct compiler for that board as well as Toolchains that are required. For those that have not heard of toolchains, these are normally associated with the compilation stages and are normally command line tools that ultimately result in the executable being produced which is then uploaded to the board.

Author: dsadmin

Leave a Reply