Hi guys, welcome to the first session of the ESP32 series. In this video, I will be demonstrating how simple it is to use PlatformIO, to develop and run simple IoT projects with ESP-IDF framework for the ESP32 board. So before moving on, please subscribe to our channel so that you don't miss out any of our upcoming videos. AbIoTs music So let's begin with the first chapter of this session "Installing the PlatformIO in vscode". If you have already installed the PlatfromIO, hmm fell free to skip this chapter. So, ahhh in order to install the PlatformIO right, first we need to locate the package manager. So, in the vscode on your left hand side you may find the activity bar. So, the activity bar so this is the activity bar and in this is the package manager and in this search for "PlatformIO". Ya this is the PlatformIO. So this PlatformIO is basically an extension ahhhhh. So this can be installed hmmm in vscode, atom or any other editors. So I prefer vscode. So let's install this. Ya so once the PlatformIO is successfully installed right You could you will find the PlatformIO ant icon on the left hand side of the activity bar For those of who are using the PlatformIO for the first time ahhh here is an small ahh introduction on PlatformIO. So first, let's open the official website of the PlatformIO. ahhhh "PlatformIO.org" ya. So this is the official webpage of the PlatformIO. and the PlatformIO is basically an next generation integrated development environment for IoT So, ahh we can see here that this has a support for very huge number of boards around 1000+ boards and support for over 26 frameworks. So, some of the most commonly used frameworks are arduino, and then we have ESP-IDF and FreeRTOS. And then we have this platforms. So it has around 48 platforms. So, what are these platforms? Platforms basically it comes with pre-built toolchains, debuggers, uploaders and frameworks. So, lets take a peek into ahh the Platfrom which we shall be using in our upcoming videos. which is Espressif 32. So, if we just look into the packages right, so we can see ya it has many ahh toolchains it has toolninja, toolcmake and few frameworks. these toolninja and toolcmake those are basically build tools. Ok, so those are used to build the application for the ESP32. And then we this toolchain-xtensa32, so this toolchains are basically used to compile the code for the ESP32. And then this framework. We have this we shall be using the ESP-IDF framework, which is the official IoT development framework for the ESP32 board. So, this frameworks basically consists of ahh certain essential API's for the ESP32 and ahh certain scripts to operate this toolchains. So, this is about the Espressif32. So lets go back. Ya now let's look into some of the features of the PlatformIO. So as we can see here it has an integrated debugger and it has unit testing and the next feature which i liked the most is "Static Code Analysis" So, like as shown in this image right, it will just let us know, how much memory was consumed and what are the potential defects in our code. So, using this we can find certain potential defects and we can fix those So, this feature is liked the most in PlatformIO And finally PlatformIO also has remote development feature. So, this is the end for this chapter and the next chapter will be "Getting started with ESP-IDF" AbIoTs music OK, so first let's install the espressif 32 platform. So, in order to install the any of the platform's right So, just click on this PlatformIO ant icon In this Activity bar on the left hand side And in there you could see something called as "Platforms" So, here right there are two things. We have an embedded platform and we have a desktop platform. Since our's is an embedded platform, lets select the embedded tab on the top. And lets search for "Espressif". Yup so we have this espressif So, as we can see here that the latest version is 3.3 and maybe by the time you guys are watching this video, this version would have increased. Don't confuse this version with Esp-Idf version.So this is the version of the this Platform and not the Esp-Idf version. So, if you could go to the change log right. Ya, so as we can see here So, this is using the latest Esp-Idf version, which is 4.3 OK, and it was released four days ago. So, ya don't confuse this PlatformIO version with Esp-Idf version. So, now lets install this. ya So, now we have successfully installed the Espressif 32 platform. So, now lets head to the PIO home. So, before actually starting with the Hello world project ahhh, let me give a quick intro on Esp-Idf So, this is the official web page for the Esp-Idf. So, as per the web page, this is the official IoT development framework for the ESP32 series and as we see here, so Esp-Idf is open source project. So, Esp-Idf is freely available on GitHub and the interesting thing is that its under Apache 2.0 licence. So, you guys can find the link to the official Esp-Idf GitHub repo in the description. Esp-Idf is production ready. So, Esp-Idf has a well defined release process and a support policy. So, each stable release undergoes a rigorous QA process that ensures production readiness. And then we have a feature rich software components. So, Esp-Idf supports a large number of software components. such as RTOS, peripheral drivers , networking stack, etc. So I guess , we have an image...ya.... So, as shown in this image right, we have many software components such as network provisioning, OTA upgrade library, network security, crypto library and many more ok... So, guys stay tuned to our channel as we shall be explaining all the components mentioned here in detail in our upcoming videos in the ESP32 series. and then we have documents. This is one of the main key point of Esp_Idf is that it has very well written documentation. So, guys I have attached a link to the Esp-Idf programming guide in the description as well. Ahh.... so this is the end of this chapter and the next chapter will be "Hello world" project. AbIoTs music So, lets first open the PIO home and in that we have to click on new project So, let me give the name of the project as Esp series one hello world So, I am using NodeMCU-32S board, so select which ever ESP32 board you guys are using and then we have to select the framework as Espressif IoT development framework and not the Arduino. So, let me just provide my custom path for the project and once everything is done, click on finish. So, we click on finish basically the PIO initialises the project for us. So, it may take some time, so be patient and let the initialisation complete. So, now the PlatformIO has successfully initialised the project for us. So, now the first thing what we are going to do is, we are going to change the extension of the main file from .c to .cpp. The reason being we shall be using the C++ for developing all our projects. So, once this is done we need to add an extern block over here. So, let me ahh...... just paste it over here Ya, so actually there is a reason why we need this extern block over here. So, now if we actually do not add this extern block right, we may end up getting error something like this. So undefined reference to app main. So, why do you think we are getting this error? So, basically what happens is We know C++ supports method overloading. and C does not. OK, so what happens is in order to distinguish between the various functions so when the C++ compiler, it generates the object code right, so what it does it changes the names of this functions by adding certain information about the arguments So this technique is called as Name Mangling. There is no standard way to do this, each compiler does in its own way. OK, but C does not support method overloading So, the error which we saw earlier it was like because, When we build the code, it was looking for, basically Esp-Idf was looking for the main method. OK, app_main, but it could not find it because that function name has been mangled and changed to something else. So, in order to solve this what we do is we add this extern block. Ok, now what happens is, so what ever functions are defined in this block the function names are not mangled with, meaning mangling is not done here. OK, so let me build this. So, as we see here the build was successful. Now, lets add the esp logging library So, hash include esp log.h So, I will be explaining this library in detail in our upcoming videos Now, when we log right there are two basic minimum arguments which are to be passed. one is tag and other is the message. So, now lets define the TAG. Ok, so now we have defined the TAG and basically there are various log levels. So, we have debug, we have error, we have information, verbose and warn. I will be using the debug level. and add the tag and the message will be "Hello world". So, actually if we see here right , so I have defined the TAG using const qualifier and not macros. So we could also use hash define TAG and main . The reason why i am not doing this is, basically what happens is macros have a limitation. So , it does not have a scope. So, because of which it can be accessed every where and its a waste of memory. but, all the variables defined using the const qualifier have a scope. So, it will be accessible only within that scope. OK So, now let me build this.. Ya, the build was success.So, now since there are no errors let's upload this code into our node mcu module. AbIoTs music So, we have this upload option over here, so let's select upload. So, lets expand this terminal OK, now the code was successfully uploaded. So now lets monitor and see weather hello world is getting logged or not Ya, so we can see here Hello world is getting logged over here. But, if you just plainly follow this steps right So, you wouldn't see this Hello world getting logged over here. The reason being we can see here that I have used the debug log level. OK But by default, when we create a project right. So, I will show you in the menu config. So here right we have something called as run menu config So, I will explain in detail about this menu config in the upcoming videos. So, for now Let's open this menu config. Ya, here we have to get inside the component config. and then we need to find something as log, ya log output So, we can see here the default verbosity is set to verbose.OK So, default log level is set to verbose But, this change was done by me, but by default what happens is it will be in info level So, what happens is for all logging statements of verbosity higher than the one mentioned in this menu config will be removed by the pre-processor. So, basically what happens is right so, we have various log levels.OK First is Error then we have warning, we have info, debug and verbose verbose is the highest.OK, so what happens is for example I have defined the log level in the menu config as info, all the log levels or log statements greater than this which is debug and verbose will be removed by the pre-processor. This is what happens at the beginning. So, what happens is when we first create the project the default log level will be set to info. So, make sure you change that from info to either verbose or debug. So, I will choose verbose and then save it. So, guys this is the end of the first session of the ESP32 series. and I will be uploading new videos every week. So guys do like share and subscribe to our channel.