Coding Your ESP32 Firmware with Cursor (or VSCode) + PlatformIO

:hammer_and_wrench: 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.


:toolbox: Prerequisites

  • A computer with macOS, Linux, or Windows
  • Cursor
  • PlatformIO IDE extension
  • An ESP32 board (e.g., ESP32 DevKit V1 or ESP32 Dev Module)
  • USB cable to connect the board

:puzzle_piece: Step-by-Step Setup

:one: 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.


:two: 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.


:three: Open PlatformIO Home

  • Press Ctrl+Shift+P (Command Palette)
  • Type PlatformIO Home
  • Select it and wait for the UI to load

:four: 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)

:memo: Modify Project Files

:five: 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;
}

:six: 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.


:white_check_mark: Build, Upload, and Monitor

At the bottom of the Cursor/VSCode window, you’ll find three buttons provided by PlatformIO:

  • :white_check_mark: Check mark: Compiles your code (build)
  • :rocket: Arrow: Uploads the firmware to your ESP32
  • :electric_plug: 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!
...

Congratulations — your firmware is running! :tada:

3 Likes

great, thanks. As it happens my ESP32 is arriving in a few days!

1 Like

After last update (Cursor 1.0) not working make ++ and serial monitor (on Platformio and ESP32)

@cxemnet
Got it working.

Intellisense Engine is disabled by default. Edit /home/{username}/.config/Cursor/User/settings.json & enable C_Cpp.intelliSenseEngine.

I can’t install it. Anyone know why cursor doesn’t show anything in the extensions marketplace for platformio? Also can’t install from the CLI

2 Likes

Same as rob3, Im unable to find PlatformIO IDF in the Extensions pane. any update on this?

Same, platform IO not showing up in the list of extensions

Install works on windows, but not on macos

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”

1 Like

Yup that worked, lol

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+

I think I may have got a workaround for this.

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.

yeah, platformio extension is nowhere to be found in cursor. i’ll try installing iv vs code do the VISX workaround. hope this will help

So what’s the way to install PlatformIO IDE without VS Code?

More problems are starting to arise. Other programs are not launching, and there are problems with operation, e.g., go to definition stops working.

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.

wow,Your method works. Thank you very much indeed.