PlatformIO installation

Hello and welcome to today's blog post.


Our blog posts and eBooks are primarily aimed at beginners.

However, there is also a very active part of our community with highly qualified professionals, amateur radio operators, engineers, software developers, etc.
People who have been working professionally in research and development for many years, and who blindly master tools like Atmel Studio, or even voluntarily use Eclipse as a code editor.

The Arduino IDE is very suitable for getting started. Most customers start the IDE, insert a sample code via Copy & Paste, possibly adjust a few more lines, and load the whole thing onto your microcontroller.

But if you want to implement larger projects, you will quickly reach the limits of the IDE. This starts with the lack of versioning, the lack of features such as code completion, and at the latest when you are working on multiple projects that require different versions of the same library, it becomes frustrating.

Today, we would like to introduce you to probably the most popular alternative at the moment: PlatformIO.

Those who have only recently started working with microcontrollers, going to the manufacturer's side, will probably be deterred first. There is talk of 'IoT', 'ecosystem', 'frameworks'. Then comes a list of features, and overloaded screenshots.
If you haven't been deterred by it yet, and go to "Install PlatformIO Now", you'll be offered two options: Atom or VSCode.
I could imagine that many have made it to this site, and then thought "this is not for me - I prefer to stay with the Arduino IDE".

Just don't let it deter ...


This is a pity because PlatformIO is much more powerful than the Arduino IDE.

 

1. The beginner

This section is intended for people who have so far programmed little or not at all, and whose preferred program for editing texts and saving screenshots is MS Word.

Maybe you're wondering why you need your own "code editor"?

On a normal PC there are usually several programs to create a text:

  • Notepad
  • Wordpad
  • Word (Office) or Writer (LibreOffice/OpenOffice)


If you want to write a letter, with letterhead, header and footer, etc., you usually resort to a word processor like Word. A word processor is a powerful tool and offers a variety of functions and options such as spell checking. It therefore makes sense for such a text document to take a word processor.

Of course, you could also write the letter in Notepad. Notepad is not a word processor, but a text editor. This is usually used to edit configuration files. However, as soon as someone tries to write a letter in Notepad, you quickly reach the limits.

The same is true of a code editor. You can easily write and save a program for the Arduino in Notepad. Here you can see the same code in both a simple text editor and in the Arduino IDE:

Notepad Code View Code view in the Arduino IDE

The most striking is the fact that the source code is displayed in color in the Arduino IDE. However, the Arduino IDE offers some practical tools that are not available in the simple text editor. It is e.g. possible to mark a text area with the mouse and to indent the entire text block with the TAB key. In the options we can also turn on line numbering and enable code folding to easily show and hide logically related sections of code such as classes or methods.

This functionality makes working with source code a lot more convenient. However, there are a variety of other editors that outshine the Arduino IDE.

 

2. The code editor


The range of text editors is rather confusing. When asked which is now best suited for programming your microcontroller, everyone will answer you differently. I made my first steps in programming in an editor called "vi" on Solaris. For years I was convinced that I would never need another text editor because I can do everything much faster in "vi" than in these "klickibunti" alternatives. In the meantime I am happy if I manage to edit a configuration file in the vi editor the first time without inserting an unwanted line break, daring the change and opening the file again.
Since we want to use PlatformIO, we have the choice between the Atom Editor or VSCode. Both are very popular and powerful editors. If you already use and love the Atom Editor, you will almost certainly want to stick with it and install the PlatformIO extension for Atom. For everyone who comes from the Arduino IDE I recommend installing VSCode.

There are 2 arguments I keep hearing when it comes to VSCode:

  • VS stands for Visual Studio and I don't want to use Visual Studio
  • VSCode comes from Microsoft


VSCode stands for Visual Studio Code and is a free, open source program. The name is somewhat unfortunate because it is a newly developed product and only shares the name with the existing Visual Studio products. Even though Microsoft tiredly laughed at the open source idea in the past and did not have the best reputation in the open source community, the company has been active in this area since 2004. A list of all open source releases is available at https://opensource.microsoft.com/. Microsoft has been actively involved in a variety of open source projects over the years.
Microsoft itself advertises the editor with the following highlights:
- it uses IntelliSense - color syntax highlighting and auto completion
- extensive debugging functions
- Version control using Git
- expandable via extensions

The first three highlights describe exactly the functions that we lack in the Arduino IDE. And the fourth highlight, the integration of extensions, enables us to use PlatformIO.

3. Installation of VSCode

First we go to the side https://code.visualstudio.com/,  download the current version and install it.

VScode Download Page

After the download, we install the software. With the installation options there is nothing that you really have to consider. You can adjust it according to your wishes or always click on "Next":

VSCode Installation

 

After the first start, a couple of messages appear at the bottom right. The first allows the installation of a language pack. We go to "Install and Restart".

VSCode first start

After the restart the message appears that Git is not installed. Git is a version management tool and should be installed at this point by clicking on "Download Git".

Git was not found

A browser window opens with the Git page. Using the link "Download 2.18.x for Windows" we can download the current version and start the installation.

Download page for Git

There are a few options to consider when installing Git. Therefore, I document the complete installation using screenshots:

Git Installation Step 1

Git Installation Step 2

Git Installation Step 3

Git Installation Step 4

Git Installation Step 5

In this window, we select Visual Studio Code as the editor. If the "Next >" field remains grayed out, please go to "< Back" and then it should go further.

Git Installation Step 6  

Git Installation Step 7

Git Installation Step 8

Git Installation Step 9

Git Installation Step 10

Git Installation Step 11

 

After restarting VSCode, the following screen should appear.

 

Git installation completed

 

Now we have installed a powerful text editor, but it does not bring us much in its current form. When I insert my Arduino code it doesn't look much different than in the notepad.

Code in vsCodeCode in the text editor


There is no way to compile the code, install libraries, or select a microcontroller. This is where the extensions come in: PlatformIO extends VSCode with these functions.

3. Install the PlatformIO extension

There are 5 icons on the left side of the VSCode window. The lowest symbol (quadrangular) opens the panel to manage the extensions.

PlatformIO Installation

In the search box, we now enter PlatformIO and install the latest version of the PlatformIO IDE by clicking "Install".

PlatformIO Installation 2

After a few moments, the button changes to "Restart" . After the restart, the "Microsoft C/C++ Extension for VS Code" is automatically installed. A little patience is required here. 


The message "Installing PlatformIO Core..." appears in the output. Depending on the system, the installation will take some time.

PlatformIO Core Installation

Please wait until the message "PlatformIO IDE has been successfully installed! Please reload window" appears:

PlatformIO Core Install stopped

After the restart, a message appears that extensions have been modified on the hard disk and are prompted to reload the window.

After a few moments, the home page of PlatformIO will appear.

Here you can start a new project, import an existing Arduino project, and see the news.

 

Now it's done. It wasn't that hard. 

I hope today's post was a little bit of a joke in installing PlatformIO.

In a future post, we'll show you how to install libraries, and how to compile and upload your first project.

Until then, I say goodbye and wish everyone a lot of fun experimenting with PlatformIO.

Yours Markus Neumann

Grundlagen software

9 comments

Michael aka Tyrannus

Michael aka Tyrannus

Ist zwar schon was älter der Blog, aber
ich möchte gerne dem VS-Code noch eine Info hinzufügen wenn ich darf.

Ich persönlich arbeite schon längere Zeit fast ausschliesslich mit VSC und möchte es nicht mehr missen.
Wer sich für die Zukunft für VSC entscheidet als quasi Backend für das proggen, dem sei als plugin für VSC auch Flutter zu empfehlen. Flutter basiert auf dart, ist easy zu erlernen (falls man das überhaupt noch muss) und bietet die Möglichkeit in einen Code native frontends für IOS, Android und Web zu entwickeln.

Gruss nach Deggendorf
Michael

Thorsten Papendorff

Thorsten Papendorff

Nachtrag zu meinem Kommentar von vorhin……. ich habe keine Möglichkeit über meine Tastatur Eingaben zu tätigen, sprich nach Boards suchen oder auch ein Projekt benennen

Thorsten Papendorff

Thorsten Papendorff

Bei mir kam nach der Installation keine Meldung das Git fehlt und auch die Installation eines Sprackpaketes wurde nicht angeboten…..
Kann das an der Version von VSCode liegen?

Heiko Hobein

Heiko Hobein

Hallo,
mit Interesse habe ich Ihren Artikel gelesen.
Prima und sehr informativ.
Eine drängende Frage habe ich:
Für ein Druckerprojekt habe ich zwei Projektdateien, welche für die PlatformIO vorbereitet waren, heruntergeladen. Die eine Datei war für Atom, die andere für VScode.
Nun habe ich die für VSCode unter Atom bearbeitet und wollte sie kompilieren, erhielt jedoch ständig eine Fehlermeldung. Dann habe ich sie unter VSCode kompiliert, da lief alles einwandfrei.
Aber ich möchte sehr ungern mit zwei unterschiedlichen Editoren (VSCOde und Atom) arbeiten.
Habe ich etwas falsch gemacht und dürfte der Editor gar nicht das Problem sein? Und wie kann ich ein Projekt so abspeichern, dass es beispielsweise von VSCOde kommt und für Atom vorbereitet ist?
Ich weiß, dass noch viele Angaben fehlen, aber ich wollte meinen Text nicht noch weiter aufblähen und hoffe, er ist einigermaßen verständlich rübergekommen.
Herzlichen Dank

Martin Fitzke

Martin Fitzke

Hallo Markus Neumann,
danke für den Artikel. Ich habe VS Code eigentlich als reinen Editor abgetan, nach dem Artikel habe ich dem Ganzen noch mal eine Chance gegeben. PlattformIO kannte ich noch garnicht, Installation war gut zu machen. Nach ein bisschen hin und her hat es prima geklappt. Danke für die Information :) Ich finde auch: tolle Arbeit.

Viele Grüße,
Martin

Heiner

Heiner

Hallo,
die Installation von VS Code hat funktioniert. Bei der Installation des Sprachpakets und der PlatformIO startet in beiden Fällen die Installation, kommt aber jeweils zu keinem Ende. Obwohl sich die Installationsanzeige bewegt, scheint es als ob nichts installiert werden würde. Habe das ganze über 2 Stunden laufen lassen.
Weiß jemand hierzu einen Rat wie man diese zwei Pakete installiert bzw. woran es liegt, dass sie sich nicht installieren lassen (Windows 7, 64Bit) ?

Grüße, Heiner

Markus Neumann

Markus Neumann

Hallo Peter,
Ich nutze auch Win 10 64 Bit, Version 1803. Die Fehlermeldung habe ich so noch nie gesehen. Ist das der genaue Wortlaut der Fehlermeldung?

Hat Ihre Installationsdatei den Namen "VSCodeUserSetup-x64-1.26.0.exe " ?
Sigi

Sigi

Installation auf Win 10, Home, 64bit, Version 1803 hat nach eurer Anleitung bestens geklappt.
Freue mich auf die nächsten Blogs.
Tolle Arbeit!!!

Peter Necas

Peter Necas

Ich wollte VSCode unter Win 10, Home, 64bit, Version 1803 installieren.
Leider kommt die Meldung: “Dieses Programm unterstützt die auf ihrem Computer installierte Version nicht.”
Was nun?
LG Peter

Leave a comment

All comments are moderated before being published