ESP32 “Hello World” with PlatformIO in Visual Studio Code

Siddhant Satote
3 min readOct 15, 2023

--

The ESP32 is a powerful microcontroller that’s gained popularity in the world of IoT and embedded systems. In this guide, we’ll take you through the process of running a “Hello World” program on the ESP32 using the PlatformIO IDE in Visual Studio Code. This is a fantastic starting point for anyone new to ESP32 development.

Part 1: Setting Up Your Development Environment

1. Install Visual Studio Code:

  • Visual Studio Code is a versatile and popular code editor. If you haven’t already, download and install it from here.

2. Install PlatformIO Extension:

  • PlatformIO is a robust platform for embedded development. Add the PlatformIO extension to Visual Studio Code by following these steps:
  • Open Visual Studio Code.
  • Go to the Extensions view (you can do this by clicking the Extensions icon in the sidebar).
  • Search for “PlatformIO” and click “Install.”

Part 2: Hardware Setup

1. Gather the Necessary Hardware:

  • To get started, you’ll need the following:
  • An ESP32 development board.
  • A USB cable.
  • A computer running Visual Studio Code with the PlatformIO extension.

2. Connect the ESP32 to Your Computer:

  • Connect your ESP32 to your computer using a USB cable. Make sure it’s securely plugged in.

Part 3: Writing and Uploading the “Hello World” Code

1. Create a New Project:

  • In Visual Studio Code, create a new PlatformIO project by following these steps:
  • Click on the PlatformIO icon in the Activity Bar.
  • Click “New Project” and follow the prompts.
  • Select “ESP32” as the board.
  • Choose the “Arduino” framework.

2. Write the “Hello World” Code:

  • Replace the default code in the src/main.cpp file with the following "Hello World" code:
#include <Arduino.h>

void setup() {
Serial.begin(115200); // Initialize serial communication
}
void loop() {
Serial.println("Hello, World!"); // Print "Hello, World!" to the Serial Monitor
delay(1000); // Wait for 1 second
}

3. Build and Upload the Code:

  • Save the file, and then click the PlatformIO icon in the Activity Bar.
  • Click the “Upload” button to build and upload the code to your ESP32.
  • Select the correct COM port and board type for your ESP32.

Part 4: Verify and Run Your “Hello World” Program

1. Open the Serial Monitor:

  • In Visual Studio Code, click the PlatformIO icon.
  • Click “Monitor” to open the Serial Monitor.

2. Upload and Run:

  • Click the “Upload” button again to upload the code to your ESP32.
  • In the Serial Monitor, you’ll see the “Hello, World!” message being printed every second.

Conclusion:

  • Congratulations! You’ve successfully run your first “Hello World” program on the ESP32 using the PlatformIO IDE in Visual Studio Code. This is just the beginning of your ESP32 journey, and there are countless possibilities waiting for you in the world of IoT and embedded systems.

Additional Resources:

Feel free to experiment with this “Hello World” program and explore the capabilities of the ESP32. Happy coding! 🚀🌐💡

--

--

Siddhant Satote

I am Siddhant Satote, Passionate coder and business enthusiast, sharing insights on the intersection of technology and entrepreneurship.