ESP32 - Getting Started with ESP-IDF using Visual Studio Code [Easiest Method]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi there in this video i will show you how to work with the esp32 idf using visual studio code let's get started [Music] my name is yuriya and this is my first video of my esp32 series i'll show how to set up your environment in a simple way and also three of my favorite visual studio code extensions the first thing that we are going to do is download and install the esp32 idf framework from the manufacturer's website just type esp32 idf on google and the first link should be the right one scroll down and download the environment for windows by selecting windows and download the esp idf tools open the file and while you go through the installation selecting here the latest release version also in this field we can change where the framework is going to be installed i prefer to keep it simple let's change this to esp for example and in this final step i suggest you to uncheck this last option sometimes it fails during the installation so just remove that to avoid problems and finally click install once the installation is done a link to a customized terminal should appear on your desktop this custom turn downloads everything that you need to build and run your project let's build and run an example type cd examples slash get started slash blink and now let's build it by typing idf.pi build and the compilation will start this process is going to take a while since it's compiling the whole framework the next time you type this command it will be way faster because it will only build what has changed after it finishes we can see that it generates a huge command line here this command is used to load your application into your microcontroller the next step is downloading installing visual studio code let's go ahead and download installer for windows after the download go through the norm installation and open visual studio code [Music] let's now open the example project that have compiled before click in file open folder and select a blink folder from the esp-idf examples here on the left side it will open a browser where you can see all files and folders inside of the blink project the most important things here are the main folder and the blink.c file if you are not familiar with idf this is your main function or in this case app underscore main depending on the esp32 board your led might be in a different pin and you need to change here in my case i'm using the esp32 dev kit v1 and the led is on pin 2. okay let's open the terminal and run the same command as before to build our project let's type idf.pipe and hit enter since we don't have this terminal configured for the idf compiler it doesn't work what we are going to do is copy the parameters from the idf terminal and use them inside the visual studio code to do this we are going to create a workspace which allows us to define custom arguments and parameters click on file and save workspace as just make sure you are in the blink folder and save a new workspace with the name blink for example after you have saved it will create a blink code workspace file where you can change your custom settings in our case you want to add the same idf terminal parameters to our project the first parameter is terminal.integrated.shell.windows which defines the terminal application file to be called in this case cmd.exe the second parameter is terminal.integrated.shellargs.windows which defines what argument you are going to pass to the terminal application the first argument that you need is slash k and the second one is the path to your idf export.bat file this file is responsible for loading and setting all the environment variables on the terminal in order to run and compile idf in our case c column esp slash esp idf export.bat ok that should be enough for now let's open the term login notice that a little window pops up asking for permission click allow and close the temp now by clicking on the little trashcan icon over here again open a new terminal and voila we have the idf terminal configured inside the visual studio code let's go ahead and build the blink example again by typing idf.pi build if you have an esp32 device connected you can program it and run the blink application by typing idf dot pi flash dash p and followed by your com port in my case my device is connected to my com port 1 and hit enter this command will compile and flash the firmware into your esp32 device the next thing that we can do is monitor the device while it's running just type idf dot by monitor dash b and your com port this will bring up the terminal and display all the output from your application allowing us to debug monitor and run the application inside the visor studio code now that we have the idf configured and running inside of the studio code i will show you three of my favorite extensions to customize your visual studio code to help us to debug and navigate through the code the first extension that i recommend is c c plus plus by microsoft this extension makes visual studio understand your c or c plus plus code and link all the files and variables in your project so you can easily navigate and find the finishes just by clicking on them after it finished installation some red squiggles will come up in your code saying that includes or definitions for some files are not found this happens because the extension is not aware of the idf libraries to fix this hover the mouse over the file and wait until the light bulb comes up click and select it did include path settings this will open a file called c c plus plus properties.json here you can add a new line inside the include path variable with the idea framework path also add a double star at the end it helps intelligence to find includes inside of any directories recursively jump back to the main file and notice that the red squiggles are still there hover it again and just click in visual studio suggestion to add a new include path automatically and that's it you should be able to navigate through the code without any problems now we can use ctrl click or f12 to go to the definitions easily this is very handy my second recommended extension is called shortcut menu bar by jerry goyal as the name says this extension creates a menu bar with some interesting functionalities like beautify to reformat your code and the terminal button to quickly open the terminal when you need it beautify will reformat your code nicely when you click on the brackets button the terminal shortcut you can click on it and that's going to open the terminal straight for you by the way i prefer to keep on the right side like this and finally my third recommended extension is called action buttons by suen langley this extension allows you to create custom actions here at the bottom which you can configure to run commands such as build or run the application to set this up for the idf click on this little gear extension settings and edit this json file i like to create two commands the first one build and the second one run with some extra parameters to also open the terminal and start monitoring in order to build just type this command idf.pi build for the run button i will put idf.pi flash which will build and load the application i will also add dashp to set the com port and dash b to set the baud rate and finally monitor to open the terminal when everything is done just remember to press ctrl right square bracket to close the terminal after you finish so that's it now have visual studio code configured building and running use the idea framework i hope you like this video if you don't want to miss my esp32 series consider subscribing and if you have any question just comment below see you in the next one you
Info
Channel: Yuri R
Views: 62,533
Rating: 4.9428244 out of 5
Keywords: esp32, visual studio code, esp-idf, firmware, getting started, tutorial, how-to, embedded, embedded systems, yuri r, programming, c++, embedded c, embedded c++, windows, vs code, visual studio, arduino, esp32 tutorial, ttgo, sparkfun, adafruit, esp32 project, esp32 datasheet, espressif, espressif idf, espressif esp32, espressif esp32 tutorial, esp32 visual studio code, esp32 mesh, esp32 mesh network, mesh network
Id: 5IuZ-E8Tmhg
Channel Id: undefined
Length: 9min 51sec (591 seconds)
Published: Sat Oct 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.