In this tutorial, I am going to show you how to Build, Flash and Monitor an ESP32 using VSCode (without PlatformIO).
- ESP32 Based Development Boards
- Micro-USB to USB cable
Which development environment should I use?
The ESP32 module, from the same family as ESP8266 is a perfect device for IoT projects due to its ability to connect to the internet via WiFi or to other devices, via Bluetooth, already integrated into the board. The processing power of the ESP32 is fantastic, with two processors. All of this at a low cost!
At the time I tested the options mentioned above, I noticed that all of them lack at some point in the flexibility of their configurations. This tutorial covers the way I find it fits the best for my daily needs with these modules, which is more time-consuming at the initial setup stage but allows you to build the development environment according to your own needs.
When developing applications for these modules, the biggest problem I get at, was with the development environment setup. There are many options available, the simpler way is using Arduino IDE as I described in my previous tutorial “ESP8266 NodeMCU – Blinking a LED“, although, in my opinion, this option comes with some limitations. The other options available, including the use of VSCode with some kind of extensions installed. The “straightforward” options being the use of PlatformIO extension or the Espressif extension.
Install and Configure ESP-IDF and VSCode
1. Download and install the ESP-IDF tools installer from Espressif (use the default options suggested by the installer). Note these procedures were tested with the “esp-idf-tools-setup-2.4.exe” executable and using the ESP-IDF release version 4.2;
2. After the installation is completed, run the “ESP-IDF Command Prompt (cmd.exe)” file that should be available on your Desktop.
3. Download and install VSCode for Windows;
4. Open VSCode and install the following extensions:
--install-extension ms-vscode.cpptools --install-extension seunlanlege.action-buttons --install-extension webfreak.debug --install-extension vscode-icons-team.vscode-icons
5. Go to your Desktop and right-click the “ESP-IDF Command Prompt (cmd.exe)” file -> “Properties” and add … & “cmd /k code”” to the end of the “Target:” entry.
6. Using the esp-idf “hello_world” project as an example, copy all the files inside the directory “copy_to_proj_dir” and paste them inside the example directory “../Desktop/esp-idf/examples/get-started/hello_world”. Replace the folder and files that already exist on the destiny folder. Note: Depending on your installation version and settings, changes may be needed in the paths within “c_cpp_properties.json”, “launch.json” and “tasks.json” files.
7. Finally, double-click the “ESP-IDF Command Prompt (cmd.exe)” file available on your Desktop. The VSCode will also be launched, open the workspace pasted in the “hello_world” directory before (“File” -> “Open Workspace…”). From now on, when you want to develop your application with the ESP-IDF just double-click the file on the Desktop and select the workspace on VSCode.
Repeat the Step 6 and 7 to every new project you want to develop.