Category: platform io

In the previous post we have seen the installation of PLATFORM IO on VS CODE.

While connecting the ESP32 to PC the PLATFORM IO detects AND ASSIGNS the COM port automatically.

To see the COM port click on DEVICES icon.

Refresh button can be pressed if new connection is made.


Image 36

If more than one COM port is listed , then you can select the COM port manually.

In this demo ,I ‘ve connected  another USB-TTL device with CP2102. To another USB port ESP32

is connected.

Image 37

Click the Refresh button under DEVICES  to view all the COM Ports.Here COM5 is allotted to ESP32 &

COM21 to USB-TTL device.

TO SELECT  COM port 5 Manually, open the platform.ino file.

Add this line at the end.


Save & upload code to see COM port 5 selected & used.


Image 40


Now let us see the solution for the error we encountered in previous post.

Under Arduino.h we received a Squiggle red line indicating error & Intellisense regarding Arduino core was not effective. Arduino.h file was not recognized.

Image 6



If you move the cursor over the Squiggles you see a balloon.Clicking on this shows some solution for the problem.But this was not successful.

Image 8

Finally I got the solution from Plaform IO forum.

Just DELETE the folder .vscode under Explorer.


Image 26

Right click .vscode folder & just DELETE it.





Now close the VS code & restart again .

The Squiggles are gone & new .vscode folder is automatically created.


Image 30

Now Intellisense regarding Arduino.h is working Fine

Image 35



Image 10



In previous posts we programmed ESP32 by Arduino IDE .This post is on a More powerful and advanced IDE

Platform IO installed over VISUAL STUDIO CODE .

VS CODE is a lightweight but powerful source code editor which is available for Windows, macOS and Linux.

VS Code is an advanced Text Editor on which we install PLATFORM IO EXTENSION and use it as IDE to program ESP32 .

The Platform IO is a Python based open source ecosystem for IoT development and a cross platform IDE with a unified debugger .

The PlatformIO supports many Platforms, Frameworks, Boards like Arduino, ESP32, ESP8266,STM32,NUCLEO and includes examples and libraries.

clip_image002         clip_image004          clip_image006

Instead of VS CODE , we can use ATOM Text editor .

But ATOM editor requires CLANG installation for Code completion facility.

Platform IO on VSCODE is the next generation IOT IDE which supports programming of a wide range of boards like Arduino, ESP32,STM32 & NUCLEO.



Visit this link for a detailed comparison between ATM & VS CODE Editors

VS CODE has advanced

Intelligent Code Completion , Smart Code Navigation & Code Formatting

Advanced Debugging tools like

Conditional Breakpoints , Expressions and Watchpoints

Memory Viewer , A hot restart of an active debugging session

As VS CODE offers key features, let us proceed with VS CODE installation.

Download the Windows installer suitable for your PC ( 32 or 64 bit).

Before starting the VSCODE installation, ensure that your PC has PYTHON.

Visit this link to download Python



Select the version 2.7.xx to install & not the 3.7.xx version.

2.7 version best supports Platform IO.







While installing Python , ensure that you enable ADD PYTHON.EXE to PATH & entire feature is installed on your local hard drive.





Finish the PYTHON installation & start with VS CODE installation.







clip_image008   clip_image010


Ensure to tick mark ADD TO PATH during installation.





clip_image014  clip_image016


Once the installation is over , click FINISH to launch VS CODE.

A dark IDE APPEARS  after a while.


TO the left side of IDE you see a list of control Icons.


Click on EXTENSIONS ICON  to visit the market place add on s.



A new search bar appears , where you type in PLATFORM IDE.

Select the PLATFORM IDE & click on the green INSTALL button.




Installation takes a while & finally the PLATFORM IO ICON appears.

The first initialization requires Internet connection and may take a while(need to install dependent toolchains, frameworks, SDKs).


At the bottom of IDE PLATFORM IO control Icons appear.







If you prefer a light skin , go to File –> Preferences & click on Color Theme.




From the list of Skins you can select a light skin .



You need to click on Platform IO Home button for the new skin to be effective.



At the center of IDE you can see some PLATFORM IO icons to add Libraries , Boards , Platforms& Devices

Under QUICK ACCESS list click on + New Project to create a new one.

You can also click on Project examples or Import Project to download one.


Provide a name to the project.

Against Board , search for ESP32 & select the correct board you’re using.Mine is DO IT ESP32 DEVKIT V1.

Against Framework select ARDUINO.

Click OK to create the Project.




Now under the left side Explorer window , the new Project (led_blink) appears


Locate the folder src , under which you find main.cpp file.

Click on it.



Here is where you write your code.

The code starts with #include <Arduino.h>

If you find a squiggle under line beneath it , then the path to header file is not defined.

The solution to this problem is explained in next post.

For now, proceed with the code.The squiggle indicates error & Intellisense regrading Arduino core will not show up.But you can complete typing the code & upload.Everything else works fine.



Let us blink the inbuilt LED on board ESP32 which is mapped to GPIO2.

While typing the code you can see the Code completion in action , which is handy while working on big projects.You need not remember the variables & functions declared.



Click on the tick mark at the bottom row of icons to Build or Compile the code.

Or you can directly click on ARROW button to upload the code.







While Upload is in progress PRESS & HOLD the BOOT button on ESP32 .



Once the code is uploaded , you can see the on board Blue LED blinking.

Now let us explore the Serial monitor capability of the IDE.

Under setup() add


The default baud rate is 9600.

Under loop() function Serial.println the message LED ON or LED off.

Upload the code & then click on the PLUG symbol seen at the bottom row of Icons.

Now the Serial monitor opens displaying the LED ON OFF message/


Image 25


To change the BAUD RATE , click on platformio.ini file under project files.

At the right side you see the platform,board & framework setting we selected while creating the project.


At the bottom add this line


where 115200 is the new Baud rate.



Now save the file & upload.

Open the Serial monitor (PLUG symbol) to see some garbage message printed.This is because the IDE Serial monitor baud rate has been changed to 115200, but in code we have initiated



Image 33


Click on main.cpp & replace 9600 with 115200.



Image 34



Save the file & upload again.

Open the Serial monitor to see the LED ON OFF message with new baud rate 115200..