DEV Community

Cover image for How to Supercharge Your ESP32 Projects with Gemini CLI (Step-by-Step)
Pawinphat Charoenrat
Pawinphat Charoenrat

Posted on • Edited on

How to Supercharge Your ESP32 Projects with Gemini CLI (Step-by-Step)


👋Quick Introduction
Supercharge your ESP32 development with the power of AI!
In this guide, you’ll learn how to use Google Gemini CLI as your coding companion for ESP-IDF projects inside Visual Studio Code. Whether you're writing C code, debugging tricky logic, or generating helpful docs—Gemini CLI brings real-time AI assistance right into your workflow.

🔧 What You’ll Need
Here’s a quick checklist to get started:

  • An ESP32 board (e.g., Ai-Thinker or similar)
  • A USB cable for connection
  • A Windows PC
  • Visual Studio Code with the ESP-IDF extension
  • Basic familiarity with ESP-IDF
  • An active internet connection

đŸ§© Step 1 – Installing Node.js
Before using Gemini CLI, you’ll need to have Node.js installed. We recommend version 18 or higher.

To check if Node.js is already installed on your system,
open PowerShell and run:

node -v

Enter fullscreen mode Exit fullscreen mode

example check nodejs
Show command node-v

If you see a version number, you're good to go. If not, head over to nodejs.org and install the latest LTS version.

đŸ§© Step 2 – Installing Gemini CLI
Once Node.js is set up, it’s time to install the Gemini CLI.

Open PowerShell and run the following command:

npm install -g @google/gemini-cli
Enter fullscreen mode Exit fullscreen mode

example install gemini cli
command gemini cli for install

Once the installation finishes, the Gemini CLI is ready to go!

Gemini is installing

đŸ§© Step 3 – Running Gemini for the First Time
To launch Gemini CLI for the first time, simply run:

gemini
Enter fullscreen mode Exit fullscreen mode

example open gemini

command open gemini

On the first launch, the system will prompt you to choose a theme for the CLI interface.

🎹 Don’t worry—you can change the theme later if you want. This is just for customizing the look and feel of your terminal experience.

Gemini theme

After choosing your preferred theme, you’ll be prompted to sign in.

By default, Gemini CLI uses Google Sign-In, so just follow the instructions to log in with your Google account.

🔐 This step is required so Gemini CLI can access the Gemini API on your behalf.

gemini sign in

Once you're signed in, you're ready to start chatting with Gemini right from your terminal!

✅ And that’s it—Gemini CLI is now ready to use!

You can start using AI to help with your ESP32 development right inside your terminal. Ask it to write code, explain functions, fix bugs, or even translate text—it’s like having a coding assistant built into your workflow.

gemini ready

đŸ§©Step 4 – Running a Build: Command vs AI Prompt
Traditionally, you would build your ESP32 project using the terminal:

idf.py build
Enter fullscreen mode Exit fullscreen mode

But with Gemini CLI, you can simply type a natural language prompt like:

🧠 “Build my ESP-IDF project”

Gemini understands what you mean and helps generate or run the correct command—saving you time and minimizing context switching between docs and terminals.

You can go beyond just building. Try asking Gemini to:

“Flash this project to my ESP32 board.”
“Clean and rebuild my ESP-IDF project.”
“Why am I getting a CMake error when I build?”
“Suggest compiler flags for faster build.”

It’s like having a smart assistant who knows both ESP-IDF and your codebase—right there in your terminal.

Example ESP-IDF Build
Build in Vscode and ESP-IDF

đŸ§© Step 5 – Using Gemini CLI Inside the ESP-IDF Terminal in VS Code
Now let’s try using Gemini CLI directly inside the ESP-IDF environment within Visual Studio Code.

To do this, open the dedicated ESP-IDF terminal by pressing:

  1. Ctrl + Shift + P → then select
  2. ESP-IDF: Open ESP-IDF Terminal

Open Terminal

This gives you a pre-configured terminal with all the necessary environment variables set up—perfect for running ESP-IDF commands or interacting with Gemini CLI.

Once the ESP-IDF terminal is open, just type:

gemini
Enter fullscreen mode Exit fullscreen mode

Open gemini in vscode with ESP-IDF

This will launch the Gemini CLI right inside your dev environment—ready to take your prompts and help you out in real time.

gemini ready

I gave Gemini a simple prompt to try building my project.
Here’s an example of what I typed:

àžșàžșBuild ESP-IDF Project
Enter fullscreen mode Exit fullscreen mode

prompt for gemini

Gemini will then ask for confirmation to start the build.
Just press Enter to continue.

Gemini confirmation

✅ If everything goes smoothly, Gemini will confirm that the build finished successfully—no issues at all.

Gemini build success

🚀I Tried Using Gemini CLI to Catch Bugs in My ESP32 Code—Here’s What Happened

I deliberately wrote some incorrect code to test Gemini.

For example, I changed this line:

ESP_LOGI(TAG_Fade, "Initial state: LED is OFF.");

Enter fullscreen mode Exit fullscreen mode

to:

Ex(TAG_Fade, "Initial state: LED is OFF.");

Enter fullscreen mode Exit fullscreen mode

Next, I asked Gemini to build the project for me.

test gemini

Gemini notified me that the build failed and showed the error.
It then asked if I wanted it to fix the issue.

I just pressed Enter to let Gemini handle the fix.

gemini notified

Gemini showed me the lines it fixed and asked if I wanted to build the project again.

Gemini build again

When I built the project again after Gemini’s fixes, everything went through smoothly.

â˜ąïž A quick heads-up:
When Gemini asks if you want to fix an error, choose “yes, allow once”—especially if you’re not sure how many errors your project has.
Try to avoid selecting “yes, allow always”, because Gemini will then automatically fix issues without asking again. Sometimes, it might apply incorrect fixes since you didn’t have a chance to review them first. This can lead to unexpected problems or even cause your project to fail.

Top comments (0)