PlatformIO: All you need to know in 10 Minutes!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey yo you're still coding like this by now you should already know my opinion regarding the classic Arduino IDE to take that Arduino IDE and you how about something else with a bit more style Grace and usability briefly touched on in my last video this video is about platform IO an extension inside the software Visual Studio code which supports a multitude of boards not just Arduino it runs esps it runs stms and all sorts of other boards you could even think of and this video will cover everything you need to know in the least amount of time possible foreign now compared to other videos regarding platform IO I don't think you're stupid and I actually assume that you know how to install a program like Visual Studio code as soon as you've booted up visual studio code for the first time you can then head over to the extensions Tab and look for all sorts of neat little extensions like the aforementioned platform IO I of course already installed it for you it will have a little install button right here as soon as that is done you will see this little alien head here and that opens up the IDE platform i o within Visual Studio code you click that and head on over to open you basically open the front page where you configure and build your projects the first tab we're interested in is the Home tab here you can basically start a new project see some news see what you've done in the past you can see I've done a lot of things for you this might probably be empty the second tab is for your projects if you've done anything then they will appear here with the inspect tab you can select a project and take a closer look at it how much memory does it take up what kind of framework is it build upon and so on and so forth libraries is what you would actually use in the Arduino IDE with the same tab up on the top with libraries here you include stuff like the Adafruit jfx library for this place or you include the serial wire library for all sorts of different things clicking on boards will give you an overview over every kind of board that is available on platform IO as you can see there's a lot of them the platforms tab will show you every kind of available platform for your board and your coding don't get Bots and platforms confused the platform is basically something like admill AVR which is in turn used for all of the Arduino projects same for the Mega you can guess where expressive 32 is going that's for the esps and down here we even got the St stm32 the last tab is devices which is a neat little overview that automatically detects whether you've got a board connected to your computer it automatically opens up the serial port and looks hey where is this Arduino and tries to find a good name for it and even shows you the com port you need by the way you can access the same options over here and have some additional little options we will get to in a minute the first thing of course you'll want to do is open up a new project you can name that any way you want as always I call my stuff test because that doesn't get confusing never then you select the board in this case we actually start with an Arduino Uno and choose the Arduino framework be careful if you build this for the first time it may take some time and I mean it may take some time when it's finished loading you'll be greeted with your project on the left side called like you called it it contains a few different folders and a few files and we'll first go over these folders before we go over anything else the dot Pio folder is basically for any kind of libraries and binaries Pio itself needs to build your project you don't usually configure anything in here manually you do that with the Pio click and drag tools themselves the next folder is dot vs code which is basically another folder that you don't configure manually it stores all of the settings for vs code itself so you edit they include folders for any kind of header file you'd want to include in your main file if you want to know more there's even a little readme file in here that tells you how to use this folder next folder is the lib folder it also contains a readme and this would be for your little sub modules that you would create for example you could create a new folder that deals with an OLED display your own implementation it would create a little folder called OLED and in here you would put a little file called oled.cpp for your source code and to be able to access this from anywhere else in your project you would add another little file that would be called OLED dot h for the header file the next folder is called source and this actually contains your classic old man or TPP that should look familiar the only thing that's different is that we actually have to include the framework this is because on platform IO you could have different Frameworks apart from Arduino so it has to be specified at the top which one you actually want to use the last folder test also contains a readme and is for test driven development I won't go over this in this video but this is a really really interesting topic that you can check out in a future video next we see a file called dot git ignore which basically if you're familiar with Git this is a file that tells the archiving system git to ignore files that have these kind of shapes for example it tells you to ignore dot Pio because nothing of this will make any sense on the git repository if you don't know anything about git ignore this for now it doesn't matter just leave it there and the last and probably most important file is platformio.ini this is your configuration file in a code format in here you specify the environments which basically is the project around the platform you build for every kind of board you want to upload to in this case you can see it auto generated for us an environment called Uno because we wanted to use the Arduino Uno it's on the platform at Mill AVR it's a board Uno of course and it's a framework Arduino and in here you would include all sorts of other pre-built variables that configure how your project is treated for example if you'd want to set the monitor speed of your serial monitor for the UI terminal you could do that by typing monitor speed and 10 equals an amount you actually want default it's set to 9600 but you can also bump it up a little more I've included a full list of all of the possible commands you can put in this file in the description you can now connect your board and even double check if it has been registered for that head on back to your platform IO Tab and then we head to the aforementioned tab devices and if you hit that you can see on my PC com10 Arduino Uno nice I have now prepared the classical Blinky example because that shows how to get the deal done the easiest way how do we upload this well you can upload this by pressing this little button down here which says platform IO upload if you don't want to upload and want to compile first then you can hit build let's do that real quick it opens up a terminal and then builds your project you can see since it's a really small project it doesn't take up much memory or does not take much time to compile we can now upload this thing and check if it works and as you can see it's blinking away like it's supposed to be you now might notice additional little buttons down here like a trash can and some kind of laboratory equipment and a little plug let's go over them real quick the trash can is for cleaning this basically uncompiles your project and removes any kind of pre-compiled libraries and binaries the testing button is a part of the aforementioned test folder which is part of test driven development and now most importantly the serial monitor if you open up the serial monitor it will then connect to your com port at the specified speed you specified in your platform io.ini file and we'll try to read out the serial port in this case we don't print anything so there's not anything there so let's modify the sketch to actually print something now be sure to actually match the serial dot begin speed with the thing you've specified in your platform I ordered any otherwise you'll get all sorts of funny squiggly lines down here so let's re-upload and if you re-upload while having the serial terminal open it will automatically jump back to the serial terminal as soon as it's done Flash see now it's coming up and it's printing some okay that seems fine but imagine yourself to be a kind of average Arduino fan versus average esp32 enjoyer and you'd want to open a project with an ESP easily done back at the platform my own home we can open up a new project call it test ESP because you know how I am with my testing names and then we're gonna look for the easy delivery esp32 because that's the one I currently own here the same principle applies you can see that your project has been opened up below the project from before and it has its own separate completely equal folder structure but this time the platform IO which is conveniently open for us already has different parameters in it now the environment is easy delivery dev kit V4 and it has a different platform and of course a different port but the framework is the same which means if we navigate to source and Main we see the same stuff and we can even upload this same old Blinky sketch let's flash that project as well and from a terminal you can see that this one worked as well okay that's also fine but now let's say you actually hate your life and you want to program an ESP with the espressive IDF iot development framework by espressive easy you could do that as well open up a new project give it a name test ESP IDF select your board easy delivery and then for framework just use expressive iot development framework or even let's say you are an absolute Giga chat and you program on stm32 well easy let's build an stm32 project so test STM and let's even do it with their own abstraction layer not even the Arduino framework so we're going to use the qpal easily done it's all here and there you can start programming immediately additionally if you're actually interested in debugging these devices especially the Arduino then you can check out my last video which focuses on how you can debug an Arduino Nano or Uno completely without any additional Hardware no intended finally a video about platform IO wouldn't be complete without mentioning the great documentation they have and additionally even better than the documentation itself is the Forum where tons of people like you are trying to program find all sorts of problems but then also find all sorts of solutions especially the moderators and developers on this team are incredible they actually respond they are actually real people and you get an answer to your question maybe even within 10 minutes it's actually insane how much work these people put into this it's great so that's it for today ditch the old Arduino IDE and finally start coding like a real developer [Music]
Info
Channel: J's e-shack
Views: 130,224
Rating: undefined out of 5
Keywords:
Id: PYSy_PLjytQ
Channel Id: undefined
Length: 10min 56sec (656 seconds)
Published: Sat Jan 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.