Getting Started: Coding Your ESP32 Firmware with Cursor + PlatformIO
If you want to prototype hardware (like ESP32) using Gen AI and LLMs, this guide will help you set up your environment and print your first âHello Worldâ to the Serial Monitor.
An ESP32 board (e.g., ESP32 DevKit V1 or ESP32 Dev Module)
USB cable to connect the board
Step-by-Step Setup
Install PlatformIO Extension
In Cursor or VSCode:
Open the Extensions panel (Ctrl+Shift+X)
Search for PlatformIO IDE
Click Install
PlatformIO is a full toolchain to compile, upload, and monitor firmware for various boards, including the ESP32.
Connect Your ESP32
Plug your ESP32 board into your computer via USB. Make sure itâs detected by your system. On Windows, you might need drivers like CP210x or CH340 depending on your ESP32 model.
Open PlatformIO Home
Press Ctrl+Shift+P (Command Palette)
Type PlatformIO Home
Select it and wait for the UI to load
Create a New Project
In PlatformIO Home:
Click New Project
Name your project (avoid spaces or special characters)
Select your board: e.g., Espressif ESP32 Dev Module
Choose Arduino as the Framework (recommended for community support)
Click Finish and wait for dependencies to download (~30 seconds)
Modify Project Files
Write Firmware in src/main.cpp
Replace the contents of src/main.cpp with the following:
#include <Arduino.h>
// Optional: declare any custom functions here
int myFunction(int, int);
void setup() {
Serial.begin(115200); // Start serial communication
Serial.println("Hello world from setup!");
int result = myFunction(2, 3); // example call
}
void loop() {
Serial.println("Hello world from ESP32 loop!");
delay(1000); // wait 1 second
}
int myFunction(int x, int y) {
return x + y;
}
Edit platformio.ini
In the root of your project, open platformio.ini and add this line:
monitor_speed = 115200
This ensures your serial monitor communicates at the correct baud rate for debugging.
Build, Upload, and Monitor
At the bottom of the Cursor/VSCode window, youâll find three buttons provided by PlatformIO:
Check mark: Compiles your code (build)
Arrow: Uploads the firmware to your ESP32
Plug icon: Opens the Serial Monitor
After uploading, open the serial monitor. You should see:
Hello world from setup!
Hello world from ESP32 loop!
Hello world from ESP32 loop!
...
Same here, canât find platformIO among extensions. But if I installed VS code and platformio in there, I could get it installed in cursor via the dialog box import all extensions from VS code.
File / Preferences / Cursor Settings / General and then âImport Settings from VS Codeâ
Workaround with importing from VS Code settings is working but installing then PlatformIO on WSL is returning error. So there is some kind compatibility or configuration bug disallowing to normally install PlatformIO on Cursor 1.0+
Assuming you also have VSCode with PlatformIO installed, you can export the .visx file from it.
Then in cursor, use the command pallete to âExtensions: Install from VISXâ and select the plaformio .visx you exported.
You will also have to do the same for the ms-vscode.cpptools extension, because PlatfomIO depends on it.
That cpptools extension throws warnings, as itâs not supposed to run in cursor.
However, it appears that just having it installed is enough to satisfy platformIO, and it does run.
Iâve successfully built and flashed a device so not very concrete testing, but things seem to work.
Interesting idea but ended up struggling exporting .visx as VSCE got me errors while trying to export. Ive reinstalled both on WSL and Windows PlatformIO, updated packages in WSL but didnât help⌠amazing.
Confirming on MacOS this is not available. I am still getting started with Arduino dev on the mac so the problem could be deeper than cursor. Weâll see if M chips are a problem the old-fashioned way.
Guys, I think the root problem is that Cursor has moved away from VS Code Marketplace as a source of extensions. It now uses Open-VSIX which may not have all extensions available. That said, I think installing it from the offline .vsix should work as well as importing it from VS Code.
I definitely have it working in Cursor (I imported it from VS Code when Cursor version was 0.4x, and it survived many version upgrades). I didnât install PlatformIO files in WSL, though â it installed Python environment and packages as regular Windows versions.
Your errors related to ms-vscode.cpptools extension are caused by Microsoft prohibiting the extension to work in VS Code forks. The last known working version is 1.23.6.