Getting Started with ESP32-S2, PlatformIO, and Arduino Framework

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone i'm thomas and welcome to my web development cloud and iot education channel today i'm going to show you the simplest method to get started with the new esp32 s2 microcontroller using saola1 development board visual studio code and platform io and by the way i would like to thank you for all the positive feedback i received on my previous esp32 video especially for the first comment that was an inspiration for this video and now let's get started first of all just quickly let me go through this to do a list so it starts from me pointing out the main differences between esp32 s2 and esp32 then i'm gonna talk about the development board that i'm using that is ola one the way we're going to deploy the code from the computer to the microcontroller and required usb to uart driver after that i'm gonna create and configure a project with visual studio code and platform io the project is gonna be arduino framework based and finally i'm gonna show you how to blink led diode that is built in on sahola one board and how to change the colors of the light and that's gonna be it as today i'm just gonna focus on the basics right okay so let's move to the differences and on the differences we have one processor core instead of two lower power consumption that is between 20 and 30 percent on a wi-fi transmission we don't have bluetooth ethernet and can bus but we get lcd and camera interfaces instead we also have usb 1.1 otg which is quite interesting featured by the way otg means on the go and what this allows us is to either connect an external usb device to esp32 s2 like a mouse keyboard flash drive or web camera but also instead we can turn esp32 s2 into an actual usb device that when connected to the computer can be discovered as something that we actually have a control over so essentially with this feature we can turn esp32 s2 based device into a smart mouse keyboard joystick gamepad again web camera flash drive and many many other options if you are interested in the details about this feature have a look at the description of the video i left a link there right and finally the last item on the list that is wi-fi connection can stay active while in a light sleep mode in my opinion this might be a game changer in terms of power management however there is one thing i would like to note which is the fact that you cannot really transmit any data when the device is in a light sleep mode so you can only keep the connection alive and where you save the power is on the fact that you don't have to reconnect to wi-fi when the device exits light sleep mode so yeah something that i'm definitely gonna investigate a further and make a video about as well as usb otg and by the way if you don't want to miss these videos make sure you subscribe to my channel so you'll be fast to get notified when these videos come out okay and now let's move to the development board that i'm using and that is esp32 s2 sa hola one and here i'm just gonna talk about how we're going to deploy the code because that's gonna happen in a sort of old way like it happens with esp32 and that's over the micro usb port that is connected to usb to uart bridge and for this one to make it work with visual studio code and platform io you need to install an external driver the name of the driver is cp210x usb to uart bridge driver you can find the link to the website with the driver in the description of the video but also i covered the installation of this driver in my previous video so you can check this out as well you can also find the link in the description and the last thing to point out here is the usb otg interface that is on p90 and 20 and it's separate to this micro usb port so if you want to make use of that feature you can either connect a usb cable straight away on the d minus and d plus or you can use the usb a breakout board and also connect it to this pins okay and i think this is it in terms of the overview let's move to the visual studio code to create a new project so here is my visual studio code already opened with a platform io extension installed in my visual studio code and by the way if you haven't got this yet on your machine check my previous video about esp32 i covered this installation step by step there you can find the link in the description again right and now what i'm gonna do here is to click on this icon and then in the menu here open i can actually click on the platform i icon again to close it and here in this tab i'm going to click on a new project for the project name i'm going to pick something like esp32 s2 maybe led blink and then for the board normally what we would do is to try to find the saula one board right however at the moment as for december 2021 you cannot really choose different framework than express if iot development framework so i cannot really pick arduino framework here um there is a workaround i'm going to show you however one thing to say is by the time you watching this video you might actually be able to pick arduino framework here and then you just want to do that you just want to select arduino framework and click on finish and you can skip the work around part of the video that i'm actually gonna present now okay and now to work around so for the workaround we need to choose a different board what we are interested in is esp32 and there should be a def module especially esp32 dev module and for this one we can pick arduino i'm gonna click on finish now and the new project is created now this is very important we need to open platform io.ini the platform io configuration file and here i'm going to paste in a following configuration and i'm going to remove this one right so that's the configuration for the saola1 board using arduino framework it uses a feature branch on platform io that supports basically arduino framework for that board one important thing there is additional option here a monitor speed this is going to be useful for the serial monitor that i'm just going to initialize by going to src main.cpp file right so like a standard arduino and in here in the setup i'm going to type in serial begin i'm going to copy and paste this value right so once i've done this i'm just going to simply send some uh send a message over the serial right so we'll be able to test if we can deploy the code to the board and if we can see a text in the serial monitor so basically if this configuration works well with the ola one that i've got so yeah so let's maybe do something again like hello from a setup something like i've done with my previous in my previous video and serial println hello from loop and we're gonna do a delay here right so once that is once this message is sent there's gonna be a sleep right there the the ball is gonna sleep for one second and then gonna continue right so yeah so that's ready uh maybe before i deploy i remind you how these two functions work with the arduino framework so setup is executed only once so we should see this information in a serial monitor only once and then the loop is going to just you know keep printing out this message and wait for one second and do it again again right in the loop as this is executed continuously right okay so now i want to make sure my device is connected to my computer using usb cable it is connected okay so now i'm going to compile the code so what we want to do is to click on the check mark button also before you deploy the code make sure you have the cp2102x usb2uart driver installed right because with without the driver it's not really possible to send any code over this micro usb port on the saula board right and now the code is compiled so i can click on this arrow button right which which is upload platform io upload and that should automatically detect the board and upload the code right okay that was quick so now we want to connect to the serial monitor so this button over here a serial monitor i'm going to click on it and once you click normally you should be connected to the serial monitor automatically but sometimes on some machines you may see something like i've got over here and i need to pick an option right so essentially anything that has this cp2102 usb to uart bridge controller right so in my case it's option three or five so either of those i go for the serial monitor is just going to work so i'm going to go for three and now i see hello from loop if i press the reset button on my saola board we can see now hello from setup right so this is where it started the setup function has been executed once and now we see hello from loop okay right so now i'm gonna exit this so let me just press here and maybe i just closed the terminal as well and now having everything working right we can deploy the code execute it i can show you how to blink the led diode and how to change colors for this one we actually need to install an external library first because it's a different type of diode it's not as simple a diode that we have on esp32 and we can just use digital write on this one we need a specific library let me show you so what we're going to do is to go to platform io menu again then open from the quick access menu then we want to go to libraries and then in here in a search libraries text box we want to type ws2812 and then press enter right bunch of results show up maybe i close this platform io menu right and we can see a few libraries here the one we interested in is this one ws 2 8 1 2 f x um basically you could go for any of these libraries to light up this diode i did a small research myself and i find this one quite simple to to use so i'm gonna go for this one so i'm gonna click on it and here let me just scroll up and here i'm going to click on add to project and then select project and my project esp32 s2 led blink i'm gonna click on add button and that's been added to my project okay how to use this library uh for that i'm gonna go to the github page so i'm gonna click here on this link and that should open browser with the github page and here is a piece of code we are interested in so i'm actually going to copy this and paste into main.cpp right so let's just paste it here and now we're gonna match this code with with what i've got right so i'm gonna move these two lines to the beginning of the setup and i'm going to move this to the loop right okay nice okay but that's not everything there is some extra steps we have to do to make it work so first of all what we are interested in is um the led pin right because led pin is not 12 we need to actually find the pin that this led diode is connected to on our board and that pin is gpio18 according to specification so what we could do to find the number that's assigned to this pin is to include gpio.h file and then for the led pin i can use the constant gpio num underscore 18 right so that's gonna set ledp into gpio num18 right that's the one actually this this is 18 so we could we could be fine with just 18 but yeah that's fine okay led count we have just one diode so there's gonna be one and then um what we want to look at is the mode of this ws2812 fx we want to change this to fx mode maybe blink rainbow right not just big but also rainbow so it's gonna be blinking and slowly changing the color for setting the speed we have 200 milliseconds um let's maybe make it um 2 000 milliseconds so we should have the diode blinking every two seconds um and we can keep the brightness for 100 and yeah that should be fine it was a little bit different to digital vright and and pin mode with the standard diodes as you can see here we have a service method that needs to be called on every single loop call in arduino framework and then start actually initializes it right so that's a little bit different right you set the mode of the of the diode here in the setup you you you make all the decisions right on the brightness on the speed and then you just use the service method in the loop so this works a little bit different yeah but yeah let's let's test it out let's see how it looks like so now i'm just going to press on the arrow button here straight away it should send the code like compile and send the code to the microcontroller okay that's it finished and we have a success because we can see the diode is blinking and it's slowly changing the color right it was red and now it's going towards orange it's yellowish now and let me just speed it up and we can see it's changing colors right so it all works well i can now connect to the serial monitor as well here to see if we get the messages so let me go for let's go to three let's let's let's go with three right and then we get hello from loop right we can see the diode is blinking okay cool so now i encourage you to experiment with this library you can set the different modes speed and brightness and see what happens um and yeah that's gonna be it in terms of the features i covered today as i said at the beginning um i i was focusing on the basics right to getting this to work i hope you enjoyed it and if you find my content useful don't forget to subscribe to my channel if there is a subject you would like me to cover in the next video let me know in the comments cheers bye
Info
Channel: Tomasz Tarnowski
Views: 232
Rating: undefined out of 5
Keywords: esp32-s2 tutorial, esp32-s2 project, esp32-s2 board, esp32-s2 dev board, esp32-s2, arduino, arduino project, beginners, diy, do-it-yourself, eevblog, electronics, esp32, esp32 datasheet, esp32 project, esp32 tutorial, esp32 weather station, project, guide, hack, hobby, how to, iot, lorawan, nodemcu, simple, smart home, wemos, wifi, arduino tutorial, getting started with esp32-s2, esp32-s2 usb, arduino usb, esp32 blinking led, esp32-s2-saola-1, esp32-s2 diode, esp32-s2-saola-1r, esp32-s2-wrover
Id: fVcru1pq9TY
Channel Id: undefined
Length: 17min 53sec (1073 seconds)
Published: Thu Dec 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.