Install MS Code and PlatformIO on Windows 10
Go to code.visualstudio.com and click on the big green button to download Visual Studio code for Windows.
If you're using a different operating system, then expand the green menu and download the appropriate installer for your operating system.
If you are using Mac OS, please have a look at the previous article of this series. There, I explain how to install Microsoft Visual Studio Code on Mac OS.
After you download the installer, double-click on it to start the process. Go through the prompts and accept everything. I have chosen to create a start menu folder, and add a desktop icon. I left the rest of the options to the defaults.
Click on install.
When the installer finished, you can start Code by double-clicking on the application icon on the desktop.
Next, we want to install PlatformIO.
From the right sidebar, click on this "Extensions" button (1).
Search for "platformio" (2).
In the first row of the search results, you will see PlatformIO IDE. The current version is 1.7.1.
So click on the first result to show the extension details in the main pane Then, click on “Install” to start the PlatformIO installation process (4).
Code will download and set up PlatformIO so we can use it.
PlatformIO needs the Python interpreter (it is a Python application). If Python is not installed on your computer, you will have to install it now before you continue with the remainder of the process.
Click on "Install Python" to do this now.
This will show the Python interpreter download page in a new browser window. The video (look at the top of this page) shows how I installed Python on Windows 10, so please consult this if needed. This part starts at 3 minutes and 32 seconds in the video.
When you have completed the installation of the Python interpreted, continue with PlatformIO.
Back in MS Code, click on "try again".
A few seconds later, the process will be complete.
Click on “Reload now” to restart Code and show the new PlatformIO tab.
Let's go ahead and test the new tool.
Notice the new PlatformIO icon in the left sidebar (1)? Click on it. This will take it to the PlatformIO page, or control panel (2).
Next, let's create a very simple new project, that will help us test PlatformIO as it's running in Visual Studio Code.
Click on the "new project" button, and give this new project a name.
Let's call it "ESP32_test" (1).
For the board name, search for "esp32" from Espressif. The one that best matches my actual hardware is "Espressiff ESP32 dev module" (2).
For the framework, there are two options. In ESP32 Unleashed, I have used the Arduino framework, so let’s choose it for this demo project (3).
Click on “finish” (5).
PlatformIO will fetch all the necessary files for the Arduino framework and install it in Visual Studio Code.
While that is happening plug your ESP32 to your computer.
When the project is ready, you’ll see the contents of the project directory in the middle pane.
Inside the project directory, are several sub-directories.
For example, there’s ".pioenvs", ".vscode", ".includes", and "libraries". You can find information about the role of each one in the documention. I also discuss them in detail in ESP32 Unleashed.
Go in the "src" directory (your project’s source code directory). There, you will find a single file. titled "main.cpp".
Double-click on that file to open it.
Let’s write a very simple program. All that this program does is to blink the built-in LED on the board and send some text to the serial monitor.
Copy this program in your main.cpp:
Save your changes.
Your project will look like this:
Connect the ESP32 dev kit to the computer via USB.
Compile it and upload it.
This button here with the right arrow will upload the firmware to the target (which is the ESP32 dev board). If the current version of the project is not compiled, then the upload button will compile it first, and then upload it.
The button that looks like a power plug will open up the serial monitor so we can see this text coming through.
Let's compile and verify the project first.
The compilation should succeed without errors.
Next, let's upload it to the board.
Click on the upload button. At the same time, I'm going to hold down the button on the left side of the power socket and place the ESP32 board into upload mode. Depending on the board you are using, you may not need to do this.
Sometimes, my ESP32 did not reboot automatically after an upload. In such cases, I press the button on the right side of the USB port to manually reset it.
Also, click on the power-plug button to bring up the serial monitor.
You should see the text: "on", "off", "on", "off" in the serial monitor.
In the next article in this series, I’ll show you how to set up the project that we’ll develop in ESP32 Unleashed.
"ESP32 Unleashed" series
Ready for some serious learning?
A new learning adventure awaits you.
Create an application that will stretch your existing knowledge and skills.
ESP32 Unleashed is a project course
This course is perfect for people familiar with the ESP32, especially graduates of ESP32 For Busy People.
It is a guided project, designed to teach you how to use modern tools to create modern embedded applications based on the ESP32.
Just click on the big red button to learn more.
Jump to another article in this series.