Esp32 Visual Studio Code



  1. Programming Esp32 With Visual Studio
  2. Esp32 Visual Studio Codes
  3. Esp32 Visual Studio Code 2020

This tutorial shows how to develop and debug Arduino projects for the ESP32-based boards using Visual Studio and the Advanced Arduino Project Subsystem of VisualGDB. We will create a basic “Blinking LED” project for the SparkFun ESP32 Thing board and will show how to navigate the code and debug the project.

Before you begin, install VisualGDB 5.4 Preview 4 or later.

  1. Start Visual Studio and open the VisualGDB Arduino Project Wizard:
  2. Proceed with the default “Blinking LED” project:
  3. On the next page select your ESP32 board. If you don’t see your board in the list, select any other ESP32-based board and click “Install” to automatically get the ESP32 Arduino core along with an up-to-date board list:
  4. Once you selected your board, connect it to the USB port and pick the COM corresponding to it below:
  5. Debugging ESP32 boards requires a JTAG debugger (e.g. Olimex ARM-USB-OCD-H or Segger J-Link). You can find detailed board-specific wiring instructions in our ESP32 tutorials (see this tutorial for SparkFun ESP32 Thing instructions). Connect your debugger to the board and plug it into the USB port. Select it in the “USB Devices” view to automatically configure it for debugging:
  6. Press “Finish” to generate the project. VisualGDB will generate an Advanced Arduino Project including both a basic sketch and the ESP32 Arduino core. Build it via Ctrl-Shift-B:Note that the build is done using the Arduino builder tool, so the result will be the same as when using the Arduino IDE. VisualGDB also queries the detailed code model from the Arduino builder that allows displaying the precise list of source files used by the project and various libraries, and also configures IntelliSense to see the code exactly as the compiler does.
  7. Once the project is built, press F5 to start debugging it:VisualGDB will automatically program the FLASH memory and begin running the project. The on-board LED will start blinking as expected.
  8. Set a breakpoint inside the loop() function and wait for it to trigger:Once the breakpoint triggers, you will be able to debug the code as any other Visual Studio project.
  9. VisualGDB will automatically disable optimization when compiling the sketch (but not the platform or the libraries) when building the debug configuration, to ensure the best debugging experience. You can alter this behavior via the first page of VisualGDB Project Properties:
  10. As VisualGDB indexes all the source files used by the project, you can use commands like Go To Definition, Peek Definition, Code Map, etc. to easily explore the code of your sketches, the Arduino core and the related libraries:
  11. Now we will show how to use the Arduino API for the serial port. Include the <HardwareSerial.h> file from your sketch:Note how VisualGDB shows the header files of available libraries with a special package icon. Including those header files will automatically reference the corresponding libraries once you save the sketch file.
  12. Replace the contents of your sketch file with the following code: