đ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
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
Once the installation finishes, the Gemini CLI is ready to go!
đ§© Step 3 â Running Gemini for the First Time
To launch Gemini CLI for the first time, simply run:
gemini
example 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.
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.
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.
đ§©Step 4 â Running a Build: Command vs AI Prompt
Traditionally, you would build your ESP32 project using the terminal:
idf.py build
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.
đ§© 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:
- Ctrl + Shift + P â then select
- ESP-IDF: Open ESP-IDF 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
This will launch the Gemini CLI right inside your dev environmentâready to take your prompts and help you out in real time.
I gave Gemini a simple prompt to try building my project.
Hereâs an example of what I typed:
àžșàžșBuild ESP-IDF Project
Gemini will then ask for confirmation to start the build.
Just press Enter to continue.
â If everything goes smoothly, Gemini will confirm that the build finished successfullyâno issues at all.
đ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.");
to:
Ex(TAG_Fade, "Initial state: LED is OFF.");
Next, I asked Gemini to build the project for me.
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 showed me the lines it fixed and asked if I wanted to build the project 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)