Visual Studio Code(简称"VS Code")是Microsoft向开发者们提供的一款真正的跨平台编辑器。
参考:
VS Code官网:Visual Studio Code - Code Editing. Redefined
乐鑫官网:
ESP-IDF 编程指南 - ESP32 VSCode ESP-ID Extension Install
一、前提条件
Visual Studio Code IDE安装ESP-IDF扩展,需要先完成如下两个步骤:
- 需要先完成ESP-IDF的安装,参考:Windows:ESP-IDF 开发环境配置【保姆级】
- 下载并安装Visual Studio Code。
下载并安装VS Code
去官网下载:Visual Studio Code - Code Editing. Redefined

我下载的版本是:code_1.83.1-1696982868_amd64.deb
Ubuntu下可以直接双击安装,或者使用如下命令安装:
sudo dpkg -i code_1.83.1-1696982868_amd64.deb
Ubuntu 上VS Code的安装非常简单

运行VSCode,并安装基础扩展插件
①:点击【Extensions】扩展图标
②:选择C/C++扩展插件,点击【Install】

二、VSCode IDE中安装ESP-IDF扩展
①:点击【Extensions】扩展图标
②:在Extensions中搜索关键字 espressif
, esp-idf
, esp32
, esp32s2等
③:点击【Install 】esp-idf extension

打开命令面板①点击【View】, ②选择【Command Palette】

或者按 F1快捷键打开命令面板,在命令面板输入 : ESP-IDF: Select where to save configuration settings

等待如下进度条完成

再在命令面板输入 :ESP-IDF: Configure ESP-IDF extension,并点击选中"ESP-IDF: Configure ESP-IDF extension"

进入之后,选中【EXPRESS】

如下界面
①选择类型乐鑫的服务器,这样下载会更快一些
②选择python工具路径: d:\Espressif\python_env\idf5.0_py3.11_env\
③然后点击【Install】开始安装

然后,就慢慢等待安装完成

看到这个界面,恭喜您,正确的安装完成了

三、开始使用VSCode ESP-IDF
现在您已经具备了使用 VSCode ESP-IDF 的所有条件,接下来将介绍如何开始您的第一个工程。
创建工程
F1快捷键打开命令面板,在命令面板输入 :ESP-IDF: New Project
①在命令面板输入 :ESP-IDF: New Project
②选中ESP-IDF: New Project


下面这步根据自己具体情况




到这一步,创建工程就完成了

配置工程
执行esp-idf 的menuconfig,第一次menuconfig的时间很长,耐心等待



编译工程
编译非常简单,直接点击下发的ESP-IDF Build project按键即可。

第一次编译时间会比较长,耐心等待就好,后面再次编译就很快了。
烧录到开发板
直接点击下发的ESP-IDF Flash device按键即可。


串口输出log
点击下发的ESP-IDF Monitor device,打开串口,check串口log输出。

到此,恭喜您已完成 VSCode 图形IDE 扩展 ESP-IDF开发环境的搭建,并可以开始ESP32的入门学习了!