Instead of moving the whole function plus its content to the top of the sketch, you can also only move the declaration (`void showLED(int pin, int delayPeriod, bool ledStatus);` (line 17 + semicolon)) to the top of the sketch and leave the function with its content below in the sketch. This can by handy if you have functions calling each other and it is hard to get the order of the functions right. Just declare them all at the top and implement them later.
@@AndreasSpiess You are right, moving out from Arduino IDE is already a huge step for beginners learning programming. Forward declarations and header libraries creations are a separate topic related to c++ learning.
Sidenote: for VSCode with PlatformIO you don't need to have arduino IDE installed. Finally a big RUclipsr suggests PlatformIO with VSCode to the beginners, now they can start with a real and powerful IDE. Thanks!
Sidenote2: the forced declaration of functions and variables before use is intended as it behaves like with "real" programs. It's just that ArduinoIDE was more forgivable. To avoid writing whole function before the loop.. just declare the function like you do with variables without the content. Simple " void showled(int pin, int displayperiod, bool ledstatus); " before loop. That's enough for the compiler to know. Then you can as usual put the whole function after the loop section.
@@crckdns For added credit, reduce the clutter in main.cpp by moving your functions into separate .cpp files, place function declarations in separate .h files, include those in main.cpp, and you're well on your way to becoming a real C/C++ programmer. :) (And by "you", I mean whoever this is news to. I assume you know all this already.)
@@kluzz pretty good point about the seperatation of code! But that's a thing most arduino coders never will touch sadly :( This would yet be a good topic to mention for Andreas next video 😸
I'm a little bit confused: Andreas installed a newer version of Arduino (1.8.9) over the older 1.8.5. BEFORE continuing with VSC and PlatformIO Why should he do this, if it is not needed?? Do PlatfomIO + VSC not work, if a the older Arduino 1.8.5 is already installed?
When I first started working with the Arduino IDE, it felt like I was being transported back to the early 90s. Once PlatformIO appeared for VS Code (which I had been using for other things for years already), I was finally brought back to the present. There really hasn't been a good reason to use the Arduino IDE for quite some time.
The error messages of arduino IDE a absolutely nonsense. I spent days debugging with arduino ide finally finding out that that i had a Japanese blank character between the lines:-(
@@ChristianDeutinger In fairness, that's probably the compiler and not the IDE. I've been programming C/C++ for nigh on 25 years, and I still manage to get flummoxed by incomprehensible error messages from the various compilers.
Instead of moving all functions to the head of the file, you can declare function prototypes, just add the function name declaration somewhere near the top of the file. void showLED(int pin, int delayPeriod, bool ledStatus); // function prototype This tells the compiler to expect the function declaration later, and keeps the flow of the code neater.
I wanted to learn more about PlatformIO and saw your video first, and I knew instantly that it was going to contain everything I neede do to know. Your videos really are informative, concise, and cover everything needed. You are like the teacher I wish I had during my computer science degree.
Your teaching skills are something I wish more teachers would have. Your explanations are logical and this does come from you being passionate about it. I hope you'll continue doing what you like and share it with us!
Thank you Andreas. I moved to PlatformIO on VS Code after watching this video. I had wasted several days working (and failing) to get Eclipse fully operational on ESP8266. This is sooooo easy now and all in the one IDE, I can start to code the projects rather than fighting the IDE.
Platformio is great. Especially because it is completely usable from the command line. That way, you are not bound by a specific IDE and can do developing and building with any editor you want (for example, I use Emacs). For larger projects, you can even build and test on a central server without a GUI. You hinted at it at the end, but I think it's worth to emphasise: With pio, you can have the same project run on many different boards (AVR-based, ESP8266, ESP32, ARM,...) and have all the settings for the different boards in the platformio.ini, so that a user only has to select the board and everything else is done automatically. The whole system is a true productivity booster. And best of all, it's open source.
I also like the fact you can do all from the command line. That makes integration with editors or IDEs very smooth. I got very good experience using SublimeText (you can replace with the editor of your choice). Also using IntelliJ, you can use the provided Ant script or map them to Gradle tasks. The main benefit of that is intégration with CI systems such as the Gitlab pipelines that now can rebuild Everytime you push a change.
Thanks Andreas, the beauty of platform io is also the way you can write one piece of code, then, in the .ini file, create different "profiles" that allow you to compile the same code for several different boards..... It's a joy to use along with tons of community supported add ons.... Brilliant....
Very powerful tool that I did not know. I will play with it by migrating some of my simple projects first to learn it. As always, thanks for your excellent reviews!
An other of the "Classic Andreas Spiess" series of tutorials which shape and change the way people do things in this space. Well done Andreas and thank you once again!
IMPORTANT note here: installer comes with a non-open source license. Actually, this has been criticized as everywhere users see "open-source", where they finally lead to a package, which doesn't have open-source license. It also turns out to be by default MS collects telemetry data! Therefore, I suggest to use Atom, if you care about privacy and open-source. Another and not so easy option is to build vscode from source (it is on GitHub).
@@ristomatti Still, doesn't change the license issue and considering the distrust against Microsoft, it is in my opinion better to compile the source code or go for VS Codium.
@@tin2001 It re-enables after each update even though its done in the config file? If so, that sounds like a bug that should be reported. Personally I haven't bothered setting it. I'll be able to use their great product for free, they can get my usage data as an exchange. I doubt I'll be seeing a lot of targeted ads based on my code.
Amazing, Andreas. I've recently moved to VSC for ASP Classic programming and had no idea that by installing this IO plugin, I'd be able to do Arduino Sketches. Thanks from Brazil, my far far away Swedish Accent friend! I kiss!!
This is not the best or recommended way to do it but if you want to keep it simple, it should be enough to create a new project in PlatformIO, copy the old Ino files into "src" folder and then copy the needed library folders from your Arduino libraries folder into "lib" folder under your PIO project. Another hacky way is to add your old Arduino libraries folder as an exrra library folder to your platformio.ino like this: lib_extra_dirs = /path/to/Arduino libraries I'm not sure how Windows paths should be defined though but I'm guessing it would be either lib_extra_dirs = c:\path\to\Arduino libraries ; or lib_extra_dirs = c:/path/to/Arduino libraries But if you do it like this you'll be missing the ability easily upgrade the libraries.
@@AndersJackson I would like to hear how easy it would be to use libraries downloaded by PlatformIO directly in Arduino IDE. The video pretty much already had an answer to OP's question but I suggested an alternative way which might be simpler than hunting down some possibly obscure libraries again.
Just got done installing Platformio for RaspberryPi 4 board, and setting it up was not easy to do from scratch without this guide (originally I followed this guide to VSC/PlatformIO in Windows10) and rewatching this guide and following for setup in RaspberryPi was just perfect. I wish I could give this another LIKE. So useful. Thank you again.
ArduinoIDE text editor (some simple basic java swing text view without any native functions like touch scrolling, dpi scaling, ...) was always a joke if you ever used a Jetbrains IDE or something similar modern. Heck, even your basic linux terminal editor with syntax highlihting was more comfortable. Also I love how platformIO can be integrated in automated CI systems.
This video motivated me to switch from Arduino IDE to PlatformIO. And really it works well and brings me back to what I am used to as a "retired" software developer. I had some problems with the IDE and strange messages about libraries. Again your video helped me to find the right places in an instant. Thank you Andreas
A wonderfully useful video which saved me many hours of frustration. The first time I looked at VSC & PlatformIO I didn't think I think the time it would take to find my way around it would be worthwhile. You showed me everything I need to know to get started in less than 20 minutes -- thank you.
You didn’t mention that by using vsc you can use the ide for many other languages like python, html, JavaScript and even openHAB Xtend. Just take a look in the extension library. If you get familiar with vsc you will have a “swiss army knife” for most coding tasks. As usual MS came late and took many good features from other projects do build their product but this time they made it open source (partly). Do you remember Bill saying “open source will kill the software industry”? BTW the github Integration is great and you can easily compare files and solve conflicts within the IDE.
Visual Studio Code is great, and big community has growing around it. Pycom from Eindhoven has created a plugin for VS Code called pymakr that allow you to use it with MicroPython. Using it one can do most of the tasks you demo in the video with MicroPython. In that case the terminal is the interactive REPL where code can also be entered / executed line by line. Nice!
I’m using ESP 01S board and I have used board = Espressif 8266 512 .. you have to unplug / plugin the Com port to make it work .... AND IT DOES WORK .... thanks for the brilliant video .
It looks like a great alternative and seems to have a lot of advantages. But I don't like functions have to be defined before the setup and main loop, especially in longer projects. Can't you initialize the function in the header (like a variable) and define it later?
Yes, you just have to write the function prototype before using the function. This prototype could be define in an external file (header) or before the 1st function (setup in Andreas example). The function prototype would be something like that : void my_function (int) ;
i tried arduino IDE 1 night only one, and i yeled at it because i was back in the beginning on 90's next day i foudn platformIO and now i do arduino stuff with a REAL editor with REAL programming rules, not crappy rules that could be even be designed for javascript. so electronics guy will have to code more correctly now :D
Really excellent outline/summary. I stopped playing with Arduino because of its many problems and am now thinking of getting back into it with platformio. Another difference between platformio and arduino ide is that platformio is more strict about proper C code, for example it won't let you get away with not having a return on a char or similar function.
I've been using the Arduino IDE for quite some time. I think it's now time I "grew up" and use a more advanced tool. Thank you for this vid. You and several other embedded electronics RUclipsrs have been a boon to my learning journey
This video has been an emotional train wreck for me, more than once I found myself with a lump in my throat and close to tears...……..To read so many comments by so many people giving the Arduino IDE a venomous Kicking like this......Have people no sense of shame ? that IDE gave so much and asked for NOTHING back !...……..poor little thing, I for one am gonna update my IDE every time one is available...…..whether I use it again or not.
The Arduino IDE has benefits: It's really easy for people to get started with and it's very uncomplicated and bureaucratic - I still think it is an excellent "on-ramp" for people which simplifies away a lot of the trouble that comes with what is fundamentally a tough task. If you do serious things with it, eventually you will reach the limits for code maintainability, and at this point it's great to have an alternative.
@@MatSmithLondon Quite normal if technology is your thing. Nikola Tesla was emotionally (romantically) connected to a pigeon, so it's not unusual for people in this forum to have these kind of feelings.
Last I looked into PlatformIO it was very early days, and the generally preferred option was to do everything on the command line and use your own editor. I tried this for a while, but it was just more cumbersome and using the "shitty" Arduino IDE was still more efficient for me. Thanks for making this video and getting me to try PlatformIO again, now with VSCode integration, i'm loving it!
As good as PlatformIO & VCS may be, I personally wouldn't recommend it to a beginner, sorry: - Installation is much bigger and fatter and more complicated. - The mutual dependencies can increase. - The possibilities (of VCS) may be overwhelming or confusing for a beginner. - Most support and help sites (> 99% ?) assume that the Arduino IDE is used or do refer to it. - The Arduino IDE is small, light-wight and very easy. And it's even portable, if desired. I suggest that small and simple sketches, as they are normally done by beginners, are faster and easier to implement with the Arduino IDE. PlatformIO and VCS can come later ...
Roman Kuechler totally agree with you. Moreover on Arduino ide is possible to see binary code and make ota update of firmware and data files i.e. on Esp8266.
Did you ever try to manage your code at github? I had many times mixed up my code by automatic file name changes from arduino IDE. I don't think this is beginner friendly!
When people are just starting out, yes they want the quick reward of being able to hit upload and seeing a light blink, knowing that they did that. But at that time they're willing to learn new things and put in at least a little effort to getting everything working - they're already EXPECTING it to be difficult, and IMO PlatformIO is still very much easy enough to get started with and leave them pleasantly surprised at how easy the process can be. In the longer term, the Arduino IDE very often becomes a crutch. I've seen many users (including myself) stick with the Arduino IDE for far too long, just because 'It Works'. Sure they could put in the time & effort to learn the "proper" development tools for each platform (Atmel Studio, SW4STM32, etc), but this requires them to re-learn a whole lot for each platform's vendor specific way of doing things, have a much harder time finding ready to run code or importing libraries, and in the end doesn't actually gain them anything except a nicer editor. For most users, since they can already achieve all the same things with the Arduino IDE, the motivation to learn and use something new is much harder to come by, so its very common to see them give it a go, realise it's a lot of work for little to no gain, and jump straight back to the Arduino IDE. And thats without diving into the stuff the Arduino IDE actually makes MUCH harder. For example it's a very common issue for beginners to have a problem uploading a sketch to a non-Arduino board, have it fail, and have no idea why. Walking them through finding the preferences.txt file on their system and manually editing it to enable verbose build / upload so they can get an error message that makes any kind of sense is FAR more hassle than it should be. PlatformIO with VSCode I think strikes the perfect balance. It was a total breeze to install, The IDE is faster to open than the Arduino IDE, it still supports all the different platforms I may use (ATMega328, ATMega32u4, STM32F103, ESP8266, ESP32, etc) without even having to add extra board support URLs, the editor is a massive step up from the barely-better-than-notepad.exe offered by the Arduino IDE, it supports a wider array of upload methods meaning its much easier for beginners to start dabbling in using "real" hardware programmers instead of a serial bootloader, and the native dependency management / resolution is just brilliant. The last time I looked into PlatformIO it wasn't nearly as polished, i'm hugely thankful to Andreas for this video prompting me to take another look at it, and I will be recommending VSC+PlatformIO to beginners from now on. PS, it's VSC, VCS is something else entirely :P
Dear Mr. Spiess, continued your tradition, this is a very informative video too. I am not sure if I will go with PIO at least not yet, but it is good to know that this nice environment exists. Thumbs up !
Well, Atom (which I'm using myself) is essentially a Microsoft program as well. Atom is based on Electron (as is Visiual Studio Code). Atom and Electron are developed by github, which belongs to Microsoft. I doubt Atom will be axed, but I don't expect many resources to go into it compared to VSC in the future.
QUITE POSSIBLY YOUR MOST USEFUL VIDEO TO DATE Especially with slightly bigger projects, it really helps if you can "Go definition" and "Go declaration" and check the types of variables etc etc. Working with class variables is so much more intuitive. Trouble shooting and moving code around is so much easier. I have been using PlatformIO for about 3 months now, and every time i want to slightly modify some previous sketch, i move it to PlatformIO first and then modify it. It also works great to check out what goes on behind the curtain of third party libraries, because you can open the library .h and .cpp files right inside your project window. If you decide use make a library as a local library, you can easily modify the library to suit your own personal preference, without breaking any of your other code that uses the original version of that same library. The color schemes really give you insight into what you are doing. The only thing missing from the Arduino experience really, is a decent debugger. (even a very basic debugger in fact) THANK YOU SO MUCH FOR INTRODUCING THIS!!!
@@AndreasSpiess You sir, are too kind. I have watched it, but at the time was not convinced it wasn't complicated. I remember there were some hardware options. (Banggood doesn't ship to my country recently) Maybe i will watch it again after a cup of coffee so my attention span is a bit better :-) Thank you again, you are a true resource of fresh ideas.
To be fair - it might not be the thing for a seasoned C/C++ developer but PlatformIO makes a great job in simplifying it's setup. It is also not the only feature you get from the paid subscription. You can for example compile and debug devices hooked to another computer. These are features normally used only by professional developers and for a professional developer it's really not a lot. For non-commercial use it's third the price.
@@ristomatti , it is only $36 PER YEAR for non-commercial use. That's extremely cheap if you live in a so-called "developed country" (i.e., you earn at least a couple thousand dollars a month...).
@@michaels3003 Yep noticed after posting its actually 1/3 of the price you initially see. Its a bargain if you need it. Not to mention the countless of hours it could take setting up all the tools by hand.
@Mai Mariarti You got all those things in Emacs, and you have Org-babel-mode and magit-mode. :-) And you can add your own functionality to a mode, if you want something different. Or a different key-binding etc.
8:13 - Make sure to click the correct plug icon (the one that has PlatformIO in the tooltip). I had another plug icon (with 'serial monitor' next to it) but that didn't work and opened a terminal which gave the error "'platformio' is not recognized as an internal or external command, operable program or batch file." Using the correct button worked. I couldn't get the ESP mode to work with any of my ESP-based devices; it gives the error "A fatal error occurred: Timed out waiting for packet header" on upload. If you have this problem, you'll need to change the target board (make sure to set this correctly in the project-wizard because changing it later is a real pain; the button in the toolbar at bottom-right won't work unless you have the Arduino IDE installed and set VSCode to point to it, which defeats the point of using VSCode instead of the Arduino IDE). Be aware that PlatformIO will install the entire toolchain in its own separate folder in the the user's folder, so if you are already using the Arduino IDE, you'll end up with a couple of gigabytes in the _%localappdata%\Arduino_ and a couple more in _%userprofile%\.platformio_ . I haven't tried it yet, but apparently PlatformIO also supports STM devices.
Thank you for the tip. Board selection is also important in the Arduino IDE because it decides which programming procedure the board uses. No difference here.
I have two large projects, one for Arduino Mega2560 the other for ESP8266, I have no problem with the Arduino IDE, I use alot of tabs, and use .h file to contain my structs and classes, they too are loaded into tabs, I do run out of tab space & have to scroll down, I have problems, when installing Arduino IDE onto other PC's / laptops, you have to remember which libraries you have used, but for me, I like the simplicity of the Arduino IDE, for programming micro controllers, it matches the simplicity of the 8 bit micro's, I don't like convoluted ways to set up the IDE, like visual micro, had problems with libraries & tabs, so went back to Arduino IDE, long story stort, stick with the Arduino IDE & maybe ask for additions, you all have a lot to thank Arduino for, I will stick with it, the original idea of simplicity, after all was what resurrected my interest in electronic after abandoning the PIC microchip in late 90's due to lack of available libraries, so I am greatfull to the Arduino & Massimo, check out my youtube channel if you want to see what can be acheived with Arduino IDE & Mega2560. >>> ruclips.net/user/davepauljones
davepauljones the editor is primitive, try atom with plaformIO you'll change your mind. I have large projects multi tabs etc, as well having a real editor makes life so much easier, it's not BREIF which was the best IMO but it's infinitely superior to the Arduino IDE editor.
I guess it might be time to revisit PIO for my projects. I gave it a try about a year ago and was turned off by the "magic" happening in the background, I like to know exactly why my programs are working or not and I felt like PIO was obfuscating that from me. How does PIO handle SPIFFS on ESP devices? Can you easily select partition sizes like you can in arduino?
I have just installed platformio in VSC, and it works like a charm. I also had the pleasure of seeing #include being automaticly added at the beginning of the file. This was on W10, will later check if this is also the case on Linux and Mac. I think using VSC this way is a big step forward. Again, many thanks Andreas!
THANK YOU so much Andreas. I have tried several alternative IDE's in the past. This one is the easiest to set up and works quite intuitively. It REALLY helps write code faster and better, more organized. So much easier also to split your code into separate units (.h and .cop) Thank you.
I was working a long time with IDE and haven't changed until now to VSCode. Thanks to your video I was able to change more quickly as having had to read all the documents.
Thanks very much Andreas! This was just what I needed to get started. You present things very clearly and with a lot of good will. And I love PlatformIO. As a professional developer, I have used Eclipse for C, C++ and Java development. Now I have a strong tool, in PlatformIO, to do efficient development life-cycles with my Arduino projects. Much appreciated!
Another great video, as usual! I've been using PlatformIO for some time and love it. A video on local git integration as well as github for VSC/PlatformIO would be a good future topic.
We will see. Maybe I include it in another video. I cannot do videos with too special content as it is only interesting for a few viewers and I disappoint the rest :-(
I've subscribed and watched a lot! of your videos and enjoy them.. This one is excellent.. It took me a week to figure out how to get Eclipse to work with the ESP8266 and not mess things up.. What a pain... I got my project working in this within an hour and cleaned things up.. More to learn.. but this is the way to go.. Thanks
Maybe the time is right now. It was more complicated last year...
5 лет назад+1
Pretty cool for you to promote PlatformIO and VSCode together. One thing that I always disliked about ArduinoIDE is that it hides a LOT of C standards at a point that makes hard for one to leave it. Kudos to you for trying and sharing more "complex" but powerful tools.
Excellent brief presentation. A shortcoming of PlatformIO is the lack of a serial plotter. I 've read about a couple of alternative plotter applications that are compatible with PlatformIO and hope that you will make a video on this subject and explain some of the choices.
Thanks for the video! Minor corrections: 1. I'm pretty sure you don't need to install Arduino IDE before installing the rest. In fact, you don't need Arduino IDE at all. When you specify that you're using the Arduino library in your platformio project, it downloads the necessary files (Arduino.h etc) automatically. 2. I'm also pretty sure that it's not a great idea to commit external libraries to git. If you've specified them in your platformio.ini, the rest (downloading, etc.) will be handled by platformio. If you're worried about changing versions, which you should be, you can specify the exact version you want for each dependency in the .ini. This not only helps reduce the size of your repository, but also avoids potentially complex license issues. 3. I think it's supposed to be pronounced 'platform-ee-o', but so many people pronounce it as platform-i-o, that I think that ship has sailed. :)
A potential deal-killer for me is that automatic selection of serial ports. I have an Uno connected to my PC as a peripheral, and sometimes have a couple of other Arduino projects connected simultaneously. I've had problems with the Arduino IDE automatically selecting the wrong serial port, so it's essential that I still have the option of *easily* selecting it manually (i.e., not having to hard-code it in the .ini file, and needing to remember to edit the file every time I plug or unplug a target). I've tried VSC for a couple of other things, and strongly agree with your comment about code completion, especially when you're learning a new language or library: the fact that it knows all the members of a class, and can suggest their name and tell you what the function parameters are, is a *big* time-saver. Good job pointing that out.
Happy Sunday Mornings🏴 loaded mine yesterday and all up and running. Your instructions are very clear and a great help with the installation. After an evening of testing, I like it. The .ini is interesting as I have a largish project with multiple libraries. Your instructions on local libraries was particularly helpful. I very much enjoyed how you sold it too me in under 5 mins. You sir are an artist. I would very much like to see you build on this initial video with debugging , Git etc. Thank you Andreas 🏴🏴🏴🏴🏴🏴🏴🏴🏴
Thank you! Maybe I will do a video about debugging. But I have to learn it first myself ;-) Git is another topic. I think this is too special for this channel.
I came by "accident" to Platform IO in a tutorial showing how to flash tasmota on different ESP home Automation devices. So you gave me inspiration to take a closer look on it and not only remove the Chinese spy's from my Sonoff devices :)
Great video, and nice to see an introduction to PlatformIO, I hope a lot of others also think that this development environment is superior to the text editor called Arduino IDE. I hope that you will follow up with some more stuff on how to write programs for the micro controllers splitting up the program in more files ".c" and ".h". The next thing could also be to get rid of c++ object oriented for Arduino, the standard Atmel(microchip) CPU's does not support it correct anyway, actually you can make your programs both smaller and faster with regular C. By the way I have also used PlatformIO with ESP32 IDF libraries, and it work like a charm, including their Freertos. This could also be a subject to a new video.
Unfortunately, I am not a programmer, only an engineer, and so I am not the right guy for the "details". But you will see debugging on this channel ;-)
Excellent tutorial sir. I've done my share of programming for the sake of programming, this looks like a big step to creating programs that do useful things.
If you want to be more specific about the errors, you can check the "problems" tab bellow the editor. Also I strongly suggest using a linter for Cpp as VSCode can auto-fix and auto-format based upon its configurations.
Andreas, did you use V.S. with the Visual Micro pugin? I am programming ESP32's using Visual Studio at the moment, but you need the Visual Micro plugin. The free version of Visual Micro works fine. Visual Micro seems to work on most boards ( except the Particle range), I have used it on all the Ardunio clones plus Teensy and ESP32, I do see ESP8266 in the list but have never tried it. Thanks for the video above showing how easy it is to get started, I immediately installed PlatformIO and look forward to testing it.
Hello, you explain very well, I was very excited to learn your language. Congratulations on your commitment, I was so excited that now I want to learn more about the use of this platform, even if I do not understand English its explanation was very clear. Congratulations again for the beautiful work.
Interesting video ! I've always been very enthousiatic about Visual Studio products. This takes it to the next level and in an environment that is familiar. Great job !
Super interesting. The number of choices now available is near over whelming for me. So many ways to do things that I often don't know what to choose & often each has subtle capabilities that only use & familiarity makes one aware of. Currently I am trying to stick to one processor (Arduino) & make the most of it, which is limiting in some ways, but also less distracting. It is remarkable that we live in such extraordinary times of abundance in so many things. Thanks for sharing!
You are right about the times. I think, your strategy of going step by step is good. But extending your choice to an ESP8266 or ESP32 is also not very complicated if you need Wi-Fi.
I'm new to arduino and I hope that one day any of what you said actually makes sense Edit As usual I gave a thumbs up as I usually love your videos and my Mrs loves your accent so I get away with watching " nerdy " videos without her moaning , I don't want you thinking that I don't like your videos
I strongly regret that I have only today discovered this video. IT IS WUNDERBAR ! Especially since indeed my preferred processor platforms are Arduino (nano) and ESP32. And yes...I have an STM32 in my drawer that I’m planning to have a decent look at soon.
This is sweet! Im using VSC editor because its free and fast compare to other IDE out there. The fact that the Platform IO is supported in VSC, this will make programming enjoyable and easy to debug. thank you for this very helpful video!
this is an excellent intro video - can't wait to see more advanced ones pls as the move from ArduinoIDE env to PlatformIO is a big one I have found but worth it I feel. Love to see how debugging can be of aid in PlatformIO for standard ESP32 and ESP8266 env
Andreas Spiess very much look forward to it. Hopefully it will be applicable to both esp32 and esp8266. Your videos are excellent and continue to support you via patreon.
Bundling all libraries as part of your project is actually considered bad practice in other areas of software development. This just bloats up your repository with code that you didn't write. Instead, what you should do is this: * Add the libraries folder to your .gitignore file so it won't get committed to you git repo * Manage all dependencies in the platformio.ini file, as you've shown * Once someone downloads your project, all they need to do is run the command "pio lib install" in the terminal (there's also a UI version of it through the VSCode command palette), and all the libs would get automatically installed Other than that - great video!
By the way, with version 2.0 they took away the option you show at 14:30 to install libraries globally. You can only install them to your projects now, from the GUI. It's still available in the CLI with “pio lib -g install ”.
I made the switch to MS Visual Studio Code when I bought a new laptop 8 months ago. It's a good IDE and works well under Linux, which is what I develop on. Also has good support for multiple languages I use. Discovered Platform IO at that time :)
At 11:50 that error is a correct error for the language C and C++ which arduino is using. So it seems like arduino using the c++ language is not following the specs on the compiler and is ignoring that or secretly making a new file with the declarations at the top before compiling. In my opinion the error is in arduino ide since if I wanted to write the same program for my computer(communicating between two computers using a serial port) I would get that error in the compiler.
Having a hell of a time with my wifi radio projects, they moved to Project IO which, perhaps cause I was screwing with it? no longer compiles the code. Yesterday I was building a radio for mom, who is 96 in the local nursing home, to listen to her old favorite radio programs from the 40's and 50's which are readily available on wifi broadcast. Mom could not have any idea how to run a PC or tablet and her failing eyesight would not allow it even if she could see. So this radio was planned to have push buttons for 5 radio stations, our local AM/FM and 4 of her old time favorites. I had a programed ESP32 for it and everything was working fine till I decided she should have a 16X2 display to light up what channel it was on. While changing the Preference files, the write failed and knocked out the esp32's programing. I have been working all morning trying to get it to reprogram but since I have upgraded to 2022 version of MS nothing seems to work even going back to the old version has not fixed things. Ah well more work, more play perhaps I will get it set up before my next trip to see her after my visit with my MD in a couple days.
Love your videos and credit/blame you for my obsession with LoRa!! This video is just in time for my recent discovery of PlatformIO and trying to use some of the Github repositories on my LoRa projects with this IDE. Although I have discovered it is not necessarily as easy as copy/paste. Further demos of using/modifying Github repositories would be appreciated, by me at least. Thanks again for your great videos and sharing your knowledge.
I've often tried it and then switched back to Arduino IDE ( + sometimes an external editor) again. One thing i don't like about platform.io are the missing settings / fuses for the microcontrollers (BOD, ClockSpeed, Voltage Reference and all that nice settings). It's possible to change them with the preferences on platformIO i guess, but it's so much more convenient to see all available options in a menu and be able to change them with a click rather than having to look up everything in the documentation. Also i stumbled a few times on compatibility issues. The new great Atmel processors for example like the ATtiny412, ATtiny1612 and so on. Spence Konde did a nice job with supporting them on the Arduino IDE (megaTinyCore), but there doesn't seem to be a solution for PlatformIO. And working in two different IDEs and switching forth and back between them isn't so convenient, especially because they handle a few things different. So i stayed with Arduinoe IDE and use sometimes an external editor and look forward to the progress of the Arduino Pro IDE.
Thanks Andreas. I've been looking for a better IDE than the Arduino one and Platform IO/VSC looks very promising. Easy to get my head round and fast. in fact about twice as fast to compile a simple fastLED test project with PlatformIO/VSC as the Arduino IDE (1.8.9) on my old 1.8Ghz Core2 laptop. Love the concept of putting the Library dependencies in the platformio.ini file. No more broken projects because something has changed in one of the libraries.
Thanks for this introduction. I was hoping for one additional chapter - importing an existing Arduino IDE project into PlatformIO. I play the videos at 75% or sonetimes 50% speed and can follow along on my open PlatformIO. Sometimes it's hard to catch where you click a button.
@@AndreasSpiess "start from scratch.". Sure for simple projects. what i wanted to know is if Platformio can open complex Arduino IDE projects having multiple pages/modules.
Thank you for this excellent tutorial. I once tried to migrate from Arduino IDE to PlatformIO (+Atom) before but found out it was not better than Arduino IDE. I enjoy very much your explanation and start migrating from Arduino IDE. But I have one problem: In my projects, I have developed many Atmega based controller (Atmega328, 128, 162 etc) with no boot-loader and upload program from Arduino IDE using ISP programming. I wonder if the PlatformIO-VSC can do ISP programming from within the application or I should other application? Please help, Regards, Benawi Santosa from Bandung, Indonesia Thank you.
Instead of moving the whole function plus its content to the top of the sketch, you can also only move the declaration (`void showLED(int pin, int delayPeriod, bool ledStatus);` (line 17 + semicolon)) to the top of the sketch and leave the function with its content below in the sketch. This can by handy if you have functions calling each other and it is hard to get the order of the functions right. Just declare them all at the top and implement them later.
You are right. I did not want to make it too complicated.
@@AndreasSpiess or the good way you put all the prototypes in a .h and include it after the include arduino.
@@AndreasSpiess You are right, moving out from Arduino IDE is already a huge step for beginners learning programming. Forward declarations and header libraries creations are a separate topic related to c++ learning.
Having programmed C++ since 1988 I find it odd behavior that calling functions before declaring them is allowed in the arduino IDE.
@@AndreasSpiess This is not complicated this has been true for C/Cpp from the beginning.
Sidenote: for VSCode with PlatformIO you don't need to have arduino IDE installed.
Finally a big RUclipsr suggests PlatformIO with VSCode to the beginners, now they can start with a real and powerful IDE.
Thanks!
Sidenote2: the forced declaration of functions and variables before use is intended as it behaves like with "real" programs. It's just that ArduinoIDE was more forgivable.
To avoid writing whole function before the loop.. just declare the function like you do with variables without the content.
Simple " void showled(int pin, int displayperiod, bool ledstatus); " before loop. That's enough for the compiler to know. Then you can as usual put the whole function after the loop section.
@@crckdns For added credit, reduce the clutter in main.cpp by moving your functions into separate .cpp files, place function declarations in separate .h files, include those in main.cpp, and you're well on your way to becoming a real C/C++ programmer. :) (And by "you", I mean whoever this is news to. I assume you know all this already.)
@@kluzz pretty good point about the seperatation of code! But that's a thing most arduino coders never will touch sadly :(
This would yet be a good topic to mention for Andreas next video 😸
crckdns I agree, please Andreas show us🤭👀👀👀👀👀👀👀👀😉😉❣️
I'm a little bit confused: Andreas installed a newer version of Arduino (1.8.9) over the older 1.8.5. BEFORE continuing with VSC and PlatformIO Why should he do this, if it is not needed?? Do PlatfomIO + VSC not work, if a the older Arduino 1.8.5 is already installed?
Concise, precise, comprehensive, logical and entertaining too. Your videos really are in a league of their own.
Thank you. You are too nice!
@@AndreasSpiess no, he is precise, comprehensive and logical, like you. :-D
yes, you are right!!!. thanks Andrea!! a hug from Argentina!!
When I first started working with the Arduino IDE, it felt like I was being transported back to the early 90s. Once PlatformIO appeared for VS Code (which I had been using for other things for years already), I was finally brought back to the present. There really hasn't been a good reason to use the Arduino IDE for quite some time.
Still the Arduino IDE did a great job of simplifying programming for many beginners...
Yeah, Arduino made micro controllers accessible to beginners. And huge kudos for that!
@@AndreasSpiess Well, yes, but I would argue that having decent IDE and being beginner friendly are not two mutually exclusive goals.
The error messages of arduino IDE a absolutely nonsense. I spent days debugging with arduino ide finally finding out that that i had a Japanese blank character between the lines:-(
@@ChristianDeutinger In fairness, that's probably the compiler and not the IDE. I've been programming C/C++ for nigh on 25 years, and I still manage to get flummoxed by incomprehensible error messages from the various compilers.
Instead of moving all functions to the head of the file, you can declare function prototypes,
just add the function name declaration somewhere near the top of the file.
void showLED(int pin, int delayPeriod, bool ledStatus); // function prototype
This tells the compiler to expect the function declaration later,
and keeps the flow of the code neater.
You beat me to it. A Thumbs up from me
You are right. I did not want to make it too complicated.
@@AndreasSpiess Small price to pay for complication.
I wanted to learn more about PlatformIO and saw your video first, and I knew instantly that it was going to contain everything I neede do to know. Your videos really are informative, concise, and cover everything needed. You are like the teacher I wish I had during my computer science degree.
Thank you for your nice words! Welcome aboard the channel.
Thanks for sparing your precious time in creating all your valuable videos Mr. Spiess. How do you manage to take time off? Isn't it hectic for you?
This is my hobby. So there is no "must" ;-)
Your teaching skills are something I wish more teachers would have. Your explanations are logical and this does come from you being passionate about it. I hope you'll continue doing what you like and share it with us!
Thank you Andreas. I moved to PlatformIO on VS Code after watching this video. I had wasted several days working (and failing) to get Eclipse fully operational on ESP8266. This is sooooo easy now and all in the one IDE, I can start to code the projects rather than fighting the IDE.
Glad it helped! I also tried and abandoned Eclipse a few years ago :-(
Platformio is great. Especially because it is completely usable from the command line. That way, you are not bound by a specific IDE and can do developing and building with any editor you want (for example, I use Emacs). For larger projects, you can even build and test on a central server without a GUI.
You hinted at it at the end, but I think it's worth to emphasise: With pio, you can have the same project run on many different boards (AVR-based, ESP8266, ESP32, ARM,...) and have all the settings for the different boards in the platformio.ini, so that a user only has to select the board and everything else is done automatically. The whole system is a true productivity booster. And best of all, it's open source.
You are right. These separated environments for me are maybe the biggest advantage.
I also like the fact you can do all from the command line. That makes integration with editors or IDEs very smooth. I got very good experience using SublimeText (you can replace with the editor of your choice). Also using IntelliJ, you can use the provided Ant script or map them to Gradle tasks. The main benefit of that is intégration with CI systems such as the Gitlab pipelines that now can rebuild Everytime you push a change.
Thanks Andreas, the beauty of platform io is also the way you can write one piece of code, then, in the .ini file, create different "profiles" that allow you to compile the same code for several different boards..... It's a joy to use along with tons of community supported add ons.... Brilliant....
Thank you!
Very powerful tool that I did not know. I will play with it by migrating some of my simple projects first to learn it. As always, thanks for your excellent reviews!
Maybe it is easier to start the new ones with it. That is what I will do.
An other of the "Classic Andreas Spiess" series of tutorials which shape and change the way people do things in this space. Well done Andreas and thank you once again!
Thank you for your nice words!
IMPORTANT note here: installer comes with a non-open source license. Actually, this has been criticized as everywhere users see "open-source", where they finally lead to a package, which doesn't have open-source license. It also turns out to be by default MS collects telemetry data! Therefore, I suggest to use Atom, if you care about privacy and open-source. Another and not so easy option is to build vscode from source (it is on GitHub).
@nearcz It might be easier to just disable sending it: code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting
@nearcz Yes, thanks for reminding it. I forgot to mention VS Codium.
@@ristomatti Still, doesn't change the license issue and considering the distrust against Microsoft, it is in my opinion better to compile the source code or go for VS Codium.
@@ristomatti
Disable now... And have it automatically re-enable later with an update? I'll give that a hard pass.
@@tin2001 It re-enables after each update even though its done in the config file? If so, that sounds like a bug that should be reported. Personally I haven't bothered setting it. I'll be able to use their great product for free, they can get my usage data as an exchange. I doubt I'll be seeing a lot of targeted ads based on my code.
Amazing, Andreas. I've recently moved to VSC for ASP Classic programming and had no idea that by installing this IO plugin, I'd be able to do Arduino Sketches.
Thanks from Brazil, my far far away Swedish Accent friend! I kiss!!
It is a swiss accent 👌🏽👌🏽
@@stealthblade1 Ok, yes, sorry, I know the difference! Thanks for the answer. I have relatives in Solothurn. I've been there 12 years ago. Take care.
No problem. Many people mix Switzerland with Sweden ;-)
Can you demonstrate importing an existing ino project, with dependent libraries?
This is not the best or recommended way to do it but if you want to keep it simple, it should be enough to create a new project in PlatformIO, copy the old Ino files into "src" folder and then copy the needed library folders from your Arduino libraries folder into "lib" folder under your PIO project.
Another hacky way is to add your old Arduino libraries folder as an exrra library folder to your platformio.ino like this:
lib_extra_dirs = /path/to/Arduino libraries
I'm not sure how Windows paths should be defined though but I'm guessing it would be either
lib_extra_dirs = c:\path\to\Arduino libraries ; or
lib_extra_dirs = c:/path/to/Arduino libraries
But if you do it like this you'll be missing the ability easily upgrade the libraries.
@@ristomatti so, Arduino IDE still have something it is better at? Why you still should have Arduino IDE. ;-)
I will not port my projects. I will only start new ones. Too much effort.
@@AndersJackson I would like to hear how easy it would be to use libraries downloaded by PlatformIO directly in Arduino IDE. The video pretty much already had an answer to OP's question but I suggested an alternative way which might be simpler than hunting down some possibly obscure libraries again.
Just got done installing Platformio for RaspberryPi 4 board, and setting it up was not easy to do from scratch without this guide (originally I followed this guide to VSC/PlatformIO in Windows10) and rewatching this guide and following for setup in RaspberryPi was just perfect. I wish I could give this another LIKE. So useful. Thank you again.
Glad it helped!
ArduinoIDE text editor (some simple basic java swing text view without any native functions like touch scrolling, dpi scaling, ...) was always a joke if you ever used a Jetbrains IDE or something similar modern. Heck, even your basic linux terminal editor with syntax highlihting was more comfortable. Also I love how platformIO can be integrated in automated CI systems.
Vincent Fischer, agreed. I prefer using Vim rather than Arduino IDE.
@@akj7 If you don't ever plan to exit your editor thats a fine choice :P
@@akj7 vsc has a vim extension. yay!
This video motivated me to switch from Arduino IDE to PlatformIO. And really it works well and brings me back to what I am used to as a "retired" software developer. I had some problems with the IDE and strange messages about libraries. Again your video helped me to find the right places in an instant. Thank you Andreas
Glad it helped!
I use visual studio (the normal one) with visual micro addon (this allows you to program arduino boards).
It even allows to put in breakpoints
Same here, it is a more professional tool than other solutions.
Can you write web address to "visual micro addon"
@@drinski6720 just search it in the add-on page in visual studio
Same. I had tried PlatformIO in Atom before, but had multiple issues with it.
Visual micro works great.
@@Basement-Science Same here. Issues I could not solve. I love Visual Micro.
A wonderfully useful video which saved me many hours of frustration. The first time I looked at VSC & PlatformIO I didn't think I think the time it would take to find my way around it would be worthwhile. You showed me everything I need to know to get started in less than 20 minutes -- thank you.
Glad it helped!
You didn’t mention that by using vsc you can use the ide for many other languages like python, html, JavaScript and even openHAB Xtend. Just take a look in the extension library.
If you get familiar with vsc you will have a “swiss army knife” for most coding tasks.
As usual MS came late and took many good features from other projects do build their product but this time they made it open source (partly). Do you remember Bill saying “open source will kill the software industry”?
BTW the github Integration is great and you can easily compare files and solve conflicts within the IDE.
Visual Studio Code is great, and big community has growing around it.
Pycom from Eindhoven has created a plugin for VS Code called pymakr that allow you to use it with MicroPython. Using it one can do most of the tasks you demo in the video with MicroPython. In that case the terminal is the interactive REPL where code can also be entered / executed line by line.
Nice!
VSCode also has a deal-making Vim extension.
@@johnnielake no Emacs bindings, no no deal... :-)
I’m using ESP 01S board and I have used board = Espressif 8266 512 .. you have to unplug / plugin the Com port to make it work .... AND IT DOES WORK .... thanks for the brilliant video .
It looks like a great alternative and seems to have a lot of advantages.
But I don't like functions have to be defined before the setup and main loop, especially in longer projects.
Can't you initialize the function in the header (like a variable) and define it later?
Yes, you just have to write the function prototype before using the function. This prototype could be define in an external file (header) or before the 1st function (setup in Andreas example).
The function prototype would be something like that :
void my_function (int) ;
@@steff3140 OK, great, time to give it a try then.
What you get with platformio is essentially standard C++ behaviour. It is the Arduino IDE that hides that from you.
Thank you for going through the failures too and not just how to get it working. Those were much more informative.
You are right. We only learn from mistakes. No need to learn if you do no mistakes. Then either you are lazy or already a master ;-)
i tried arduino IDE 1 night only one, and i yeled at it because i was back in the beginning on 90's
next day i foudn platformIO and now i do arduino stuff with a REAL editor with REAL programming rules, not crappy rules that could be even be designed for javascript.
so electronics guy will have to code more correctly now :D
Emacs and Make. That's the way to go.
Really excellent outline/summary. I stopped playing with Arduino because of its many problems and am now thinking of getting back into it with platformio. Another difference between platformio and arduino ide is that platformio is more strict about proper C code, for example it won't let you get away with not having a return on a char or similar function.
Cool that you try to get back into the "Arduino world" without the Arduino IDE!
PlatformIO is interesting. I hope you'll do a video on the debugger!
I plan to do so.
I've been using the Arduino IDE for quite some time. I think it's now time I "grew up" and use a more advanced tool. Thank you for this vid. You and several other embedded electronics RUclipsrs have been a boon to my learning journey
You're welcome!
A lot of compelling arguments for platform.io, for me dependency management and board selection being the main ones. Will definitely try out next time
You still can return. Not a lot is lost...
Andreas, you have no ideia of how much you helped me with your tutorial, thank you very much.
Kind regards from Brazil.
Glad I could help!
This video has been an emotional train wreck for me, more than once I found myself with a lump in my throat and close to tears...……..To read so many comments by so many people giving the Arduino IDE a venomous Kicking like this......Have people no sense of shame ? that IDE gave so much and asked for NOTHING back !...……..poor little thing, I for one am gonna update my IDE every time one is available...…..whether I use it again or not.
The Arduino IDE has benefits: It's really easy for people to get started with and it's very uncomplicated and bureaucratic - I still think it is an excellent "on-ramp" for people which simplifies away a lot of the trouble that comes with what is fundamentally a tough task. If you do serious things with it, eventually you will reach the limits for code maintainability, and at this point it's great to have an alternative.
Seems strange to be emotionally connected to an IDE!
@@MatSmithLondon Quite normal if technology is your thing. Nikola Tesla was emotionally (romantically) connected to a pigeon, so it's not unusual for people in this forum to have these kind of feelings.
Last I looked into PlatformIO it was very early days, and the generally preferred option was to do everything on the command line and use your own editor. I tried this for a while, but it was just more cumbersome and using the "shitty" Arduino IDE was still more efficient for me. Thanks for making this video and getting me to try PlatformIO again, now with VSCode integration, i'm loving it!
I tried it also a while ago and was disappointed. Now it seems to be more straightforward
As good as PlatformIO & VCS may be, I personally wouldn't recommend it to a beginner, sorry:
- Installation is much bigger and fatter and more complicated.
- The mutual dependencies can increase.
- The possibilities (of VCS) may be overwhelming or confusing for a beginner.
- Most support and help sites (> 99% ?) assume that the Arduino IDE is used or do refer to it.
- The Arduino IDE is small, light-wight and very easy. And it's even portable, if desired.
I suggest that small and simple sketches, as they are normally done by beginners, are faster and easier to implement with the Arduino IDE. PlatformIO and VCS can come later ...
Roman Kuechler totally agree with you. Moreover on Arduino ide is possible to see binary code and make ota update of firmware and data files i.e. on Esp8266.
Fully agree
@@tanux66 OTA updates in PlatformIO are seamless: just need to set upload_port in platformio.ini to IP or FQDN.
Did you ever try to manage your code at github? I had many times mixed up my code by automatic file name changes from arduino IDE. I don't think this is beginner friendly!
When people are just starting out, yes they want the quick reward of being able to hit upload and seeing a light blink, knowing that they did that. But at that time they're willing to learn new things and put in at least a little effort to getting everything working - they're already EXPECTING it to be difficult, and IMO PlatformIO is still very much easy enough to get started with and leave them pleasantly surprised at how easy the process can be.
In the longer term, the Arduino IDE very often becomes a crutch. I've seen many users (including myself) stick with the Arduino IDE for far too long, just because 'It Works'. Sure they could put in the time & effort to learn the "proper" development tools for each platform (Atmel Studio, SW4STM32, etc), but this requires them to re-learn a whole lot for each platform's vendor specific way of doing things, have a much harder time finding ready to run code or importing libraries, and in the end doesn't actually gain them anything except a nicer editor. For most users, since they can already achieve all the same things with the Arduino IDE, the motivation to learn and use something new is much harder to come by, so its very common to see them give it a go, realise it's a lot of work for little to no gain, and jump straight back to the Arduino IDE.
And thats without diving into the stuff the Arduino IDE actually makes MUCH harder. For example it's a very common issue for beginners to have a problem uploading a sketch to a non-Arduino board, have it fail, and have no idea why. Walking them through finding the preferences.txt file on their system and manually editing it to enable verbose build / upload so they can get an error message that makes any kind of sense is FAR more hassle than it should be.
PlatformIO with VSCode I think strikes the perfect balance. It was a total breeze to install, The IDE is faster to open than the Arduino IDE, it still supports all the different platforms I may use (ATMega328, ATMega32u4, STM32F103, ESP8266, ESP32, etc) without even having to add extra board support URLs, the editor is a massive step up from the barely-better-than-notepad.exe offered by the Arduino IDE, it supports a wider array of upload methods meaning its much easier for beginners to start dabbling in using "real" hardware programmers instead of a serial bootloader, and the native dependency management / resolution is just brilliant.
The last time I looked into PlatformIO it wasn't nearly as polished, i'm hugely thankful to Andreas for this video prompting me to take another look at it, and I will be recommending VSC+PlatformIO to beginners from now on.
PS, it's VSC, VCS is something else entirely :P
Thanks!
You are welcome!
I just saw your Super Thanks on my PC (it is not displayed on the IPad). Thank you for your support!
online debugging is the holy grail-- please review
Yes, please!
We will see. I need some HW first...
Here try my Repo as an example for low level CI testing with PlatformIO emulation and TravisCI
github.com/photodude/G2MotorDriver
I love PlatformIO. It has definitely made programming the Arduino family microcontrollers much easier. Thank you for introducing this IDE to makers.
You are welcome! Not everybody feels PIO is easier, but for sure more powerful!
IMHO Visual Studio Code with platform IO is 100% better than Arduino IDE. It's more comfortable.
VSC looks pretty nice. I still prefer Atmel Studio because of ICD.
It is definitively more comfortable.
Dear Mr. Spiess, continued your tradition, this is a very informative video too. I am not sure if I will go with PIO at least not yet, but it is good to know that this nice environment exists. Thumbs up !
Thank you for your nice words!
Atom editor and PlatformIO works great and it stays opensource :-)
Well, Atom (which I'm using myself) is essentially a Microsoft program as well. Atom is based on Electron (as is Visiual Studio Code). Atom and Electron are developed by github, which belongs to Microsoft. I doubt Atom will be axed, but I don't expect many resources to go into it compared to VSC in the future.
VScode is open source too.
But Atom is a little slow for me. :-(
@@sourekpetr Slow LOL
@@pnrootWhen you start app and the app is able to function after 2 minutes after you lanuch it, that is slow. Sorry...
QUITE POSSIBLY YOUR MOST USEFUL VIDEO TO DATE
Especially with slightly bigger projects, it really helps if you can "Go definition" and "Go declaration" and check the types of variables etc etc.
Working with class variables is so much more intuitive. Trouble shooting and moving code around is so much easier.
I have been using PlatformIO for about 3 months now, and every time i want to slightly modify some previous sketch, i move it to PlatformIO first and then modify it.
It also works great to check out what goes on behind the curtain of third party libraries, because you can open the library .h and .cpp files right inside your project window.
If you decide use make a library as a local library, you can easily modify the library to suit your own personal preference, without breaking any of your other code that uses the original version of that same library.
The color schemes really give you insight into what you are doing.
The only thing missing from the Arduino experience really, is a decent debugger. (even a very basic debugger in fact)
THANK YOU SO MUCH FOR INTRODUCING THIS!!!
Maybe you watch ma video about inline debugging and platformIO?
@@AndreasSpiess You sir, are too kind.
I have watched it, but at the time was not convinced it wasn't complicated.
I remember there were some hardware options. (Banggood doesn't ship to my country recently)
Maybe i will watch it again after a cup of coffee so my attention span is a bit better :-)
Thank you again, you are a true resource of fresh ideas.
paying for a debugger, yeah, no thanks
To be fair - it might not be the thing for a seasoned C/C++ developer but PlatformIO makes a great job in simplifying it's setup. It is also not the only feature you get from the paid subscription. You can for example compile and debug devices hooked to another computer. These are features normally used only by professional developers and for a professional developer it's really not a lot. For non-commercial use it's third the price.
@@ristomatti , it is only $36 PER YEAR for non-commercial use. That's extremely cheap if you live in a so-called "developed country" (i.e., you earn at least a couple thousand dollars a month...).
@@michaels3003 Yep noticed after posting its actually 1/3 of the price you initially see. Its a bargain if you need it. Not to mention the countless of hours it could take setting up all the tools by hand.
@@ristomatti , thanks, but you can (and should) edit your post. There is so much confusion on this planet...
@Mai Mariarti You got all those things in Emacs, and you have Org-babel-mode and magit-mode. :-)
And you can add your own functionality to a mode, if you want something different. Or a different key-binding etc.
8:13 - Make sure to click the correct plug icon (the one that has PlatformIO in the tooltip). I had another plug icon (with 'serial monitor' next to it) but that didn't work and opened a terminal which gave the error "'platformio' is not recognized as an internal or external command, operable program or batch file." Using the correct button worked.
I couldn't get the ESP mode to work with any of my ESP-based devices; it gives the error "A fatal error occurred: Timed out waiting for packet header" on upload. If you have this problem, you'll need to change the target board (make sure to set this correctly in the project-wizard because changing it later is a real pain; the button in the toolbar at bottom-right won't work unless you have the Arduino IDE installed and set VSCode to point to it, which defeats the point of using VSCode instead of the Arduino IDE).
Be aware that PlatformIO will install the entire toolchain in its own separate folder in the the user's folder, so if you are already using the Arduino IDE, you'll end up with a couple of gigabytes in the _%localappdata%\Arduino_ and a couple more in _%userprofile%\.platformio_ .
I haven't tried it yet, but apparently PlatformIO also supports STM devices.
Thank you for the tip. Board selection is also important in the Arduino IDE because it decides which programming procedure the board uses. No difference here.
Thanks
Thank you for your support!
I have two large projects, one for Arduino Mega2560 the other for ESP8266, I have no problem with the Arduino IDE, I use alot of tabs, and use .h file to contain my structs and classes, they too are loaded into tabs, I do run out of tab space & have to scroll down, I have problems, when installing Arduino IDE onto other PC's / laptops, you have to remember which libraries you have used, but for me, I like the simplicity of the Arduino IDE, for programming micro controllers, it matches the simplicity of the 8 bit micro's, I don't like convoluted ways to set up the IDE, like visual micro, had problems with libraries & tabs, so went back to Arduino IDE, long story stort, stick with the Arduino IDE & maybe ask for additions, you all have a lot to thank Arduino for, I will stick with it, the original idea of simplicity, after all was what resurrected my interest in electronic after abandoning the PIC microchip in late 90's due to lack of available libraries, so I am greatfull to the Arduino & Massimo, check out my youtube channel if you want to see what can be acheived with Arduino IDE & Mega2560. >>> ruclips.net/user/davepauljones
davepauljones the editor is primitive, try atom with plaformIO you'll change your mind. I have large projects multi tabs etc, as well having a real editor makes life so much easier, it's not BREIF which was the best IMO but it's infinitely superior to the Arduino IDE editor.
Thanks Carl, I will try it, maybe I will need it, when working with ESP32 projects, thanks for reply.
It cant be done better. Thank you very much Mr. SPIESS.
Das Werk eines absoluten Könners.
Retired Dipl.-Ing., Germany
You are welcome! From a not-yet-retired Swiss engineer ;-) But in a few years...
@@AndreasSpiess freut mich von ihnen ein Lebenszeichen zu erhalten. Sehr nett.
Ich versuche, alle Kommentare zu beantworten.
What a coincidence, I just look last week about another ways to program the ESP and have seen PlatformIO.
Excellent video as always.
Thank you!
Hi Andreas,
as usual a top video. Since I have problems with the libraries of Bosch BME680, I switched to Platformio last week. -> no more problems.
Good to know!
I guess it might be time to revisit PIO for my projects. I gave it a try about a year ago and was turned off by the "magic" happening in the background, I like to know exactly why my programs are working or not and I felt like PIO was obfuscating that from me. How does PIO handle SPIFFS on ESP devices? Can you easily select partition sizes like you can in arduino?
I also tried it some time ago and was not amused ;-)
Concerning partitioning etc: I did not try. Maybe somebody else knows.
I have just installed platformio in VSC, and it works like a charm. I also had the pleasure of seeing #include being automaticly added at the beginning of the file. This was on W10, will later check if this is also the case on Linux and Mac. I think using VSC this way is a big step forward. Again, many thanks Andreas!
I read somewhere, that, if you use the .ino ending, the line is automatically inserted. But I am not sure.
Greutzi Andreas, you have become my go-to expert on all things micro-controller. I adore your work. Vielen Dank! -Frank
Bitte, gern geschehen!
THANK YOU so much Andreas.
I have tried several alternative IDE's in the past. This one is the easiest to set up and works quite intuitively.
It REALLY helps write code faster and better, more organized.
So much easier also to split your code into separate units (.h and .cop)
Thank you.
You are welcome!
I was using both PlatformIO and Arduino IDEs, but you have totally convinced me to make a full switch to PlatformIO.
:-)
I was working a long time with IDE and haven't changed until now to VSCode.
Thanks to your video I was able to change more quickly as having had to read all the documents.
Good to read!
Thanks very much Andreas! This was just what I needed to get started. You present things very clearly and with a lot of good will. And I love PlatformIO. As a professional developer, I have used Eclipse for C, C++ and Java development. Now I have a strong tool, in PlatformIO, to do efficient development life-cycles with my Arduino projects. Much appreciated!
I also think that PlatformIO is a good combination of a good development tool with the simplicity of the Arduino IDE.
Another great video, as usual! I've been using PlatformIO for some time and love it. A video on local git integration as well as github for VSC/PlatformIO would be a good future topic.
We will see. Maybe I include it in another video. I cannot do videos with too special content as it is only interesting for a few viewers and I disappoint the rest :-(
Happy I found this as I’m about to start some Arduino programming. Like your style to show issues and then how to solve them 👍🏼
Glad you liked the content of the video!
I was skeptical and even delayed the watching of this video. Now I will be downloading the platformio tomorrow. Thanks!
I assume you already did so and I hope you enjoyed it.
I've subscribed and watched a lot! of your videos and enjoy them.. This one is excellent.. It took me a week to figure out how to get Eclipse to work with the ESP8266 and not mess things up.. What a pain... I got my project working in this within an hour and cleaned things up.. More to learn.. but this is the way to go.. Thanks
Welcome to the channel!
Can't believe I still used to use the Arduino IDE... thank you for finally pushing me over the edge.
Maybe the time is right now. It was more complicated last year...
Pretty cool for you to promote PlatformIO and VSCode together.
One thing that I always disliked about ArduinoIDE is that it hides a LOT of C standards at a point that makes hard for one to leave it.
Kudos to you for trying and sharing more "complex" but powerful tools.
Most of the Arduino users do not want to be perfect. They want to have the job done and take the best tool for the purpose ;-)
Excellent brief presentation. A shortcoming of PlatformIO is the lack of a serial plotter. I 've read about a couple of alternative plotter applications that are compatible with PlatformIO and hope that you will make a video on this subject and explain some of the choices.
You still can use the serial plotter of the Arduino IDE if you need it...
omg 7 minutes of pure gold, thank you sir!
Glad you liked the video!
Thanks for the video!
Minor corrections:
1. I'm pretty sure you don't need to install Arduino IDE before installing the rest. In fact, you don't need Arduino IDE at all. When you specify that you're using the Arduino library in your platformio project, it downloads the necessary files (Arduino.h etc) automatically.
2. I'm also pretty sure that it's not a great idea to commit external libraries to git. If you've specified them in your platformio.ini, the rest (downloading, etc.) will be handled by platformio. If you're worried about changing versions, which you should be, you can specify the exact version you want for each dependency in the .ini. This not only helps reduce the size of your repository, but also avoids potentially complex license issues.
3. I think it's supposed to be pronounced 'platform-ee-o', but so many people pronounce it as platform-i-o, that I think that ship has sailed. :)
I'm gonna go with you bud....platformeeoo!
Good to know that it would work without the IDE installation, even if most of us still have such an installation and will keep it.
Thanks for making. This video helped me understand Platform.IO for the first time.
Glad it helped!
A potential deal-killer for me is that automatic selection of serial ports. I have an Uno connected to my PC as a peripheral, and sometimes have a couple of other Arduino projects connected simultaneously. I've had problems with the Arduino IDE automatically selecting the wrong serial port, so it's essential that I still have the option of *easily* selecting it manually (i.e., not having to hard-code it in the .ini file, and needing to remember to edit the file every time I plug or unplug a target).
I've tried VSC for a couple of other things, and strongly agree with your comment about code completion, especially when you're learning a new language or library: the fact that it knows all the members of a class, and can suggest their name and tell you what the function parameters are, is a *big* time-saver. Good job pointing that out.
As you wrote, you can hard-code your Com port in the .ini file if you want. AFAIK you can also exclude some ports from being selected.
Happy Sunday Mornings🏴 loaded mine yesterday and all up and running. Your instructions are very clear and a great help with the installation. After an evening of testing, I like it. The .ini is interesting as I have a largish project with multiple libraries. Your instructions on local libraries was particularly helpful.
I very much enjoyed how you sold it too me in under 5 mins.
You sir are an artist. I would very much like to see you build on this initial video with debugging , Git etc.
Thank you Andreas 🏴🏴🏴🏴🏴🏴🏴🏴🏴
Thank you! Maybe I will do a video about debugging. But I have to learn it first myself ;-) Git is another topic. I think this is too special for this channel.
Extremely glad to see maker community showing interest in excellent tools that we programmers use like vscode 🙂
We do not live behind the moon ;-)
I came by "accident" to Platform IO in a tutorial showing how to flash tasmota on different ESP home Automation devices. So you gave me inspiration to take a closer look on it and not only remove the Chinese spy's from my Sonoff devices :)
Similar here. I had an RFID project in PIO ;-)
Thank you! I had not heard of PlatformIO before. I have used the Arduino plug-in for VSCode, but PlatformIO makes the experience much better.
You are welcome!
Great video, and nice to see an introduction to PlatformIO, I hope a lot of others also think that this development environment is superior to the text editor called Arduino IDE.
I hope that you will follow up with some more stuff on how to write programs for the micro controllers splitting up the program in more files ".c" and ".h".
The next thing could also be to get rid of c++ object oriented for Arduino, the standard Atmel(microchip) CPU's does not support it correct anyway, actually you can make your programs both smaller and faster with regular C.
By the way I have also used PlatformIO with ESP32 IDF libraries, and it work like a charm, including their Freertos. This could also be a subject to a new video.
Unfortunately, I am not a programmer, only an engineer, and so I am not the right guy for the "details". But you will see debugging on this channel ;-)
Excellent tutorial sir. I've done my share of programming for the sake of programming, this looks like a big step to creating programs that do useful things.
Let's hope!
I’ll definitely have to give platformIO a try. Being able to see errors in real time will definitely save a lot of time
Have fun!
If you want to be more specific about the errors, you can check the "problems" tab bellow the editor.
Also I strongly suggest using a linter for Cpp as VSCode can auto-fix and auto-format based upon its configurations.
A few other viewers also suggested it. I will give it a try. Thanks.
finally, a contender for full Visual Studio and Visual Micro which has been doing the same thing for the past 5 years.
I used visual studio a few years ago, but they lost me when the ESP8266 came :-(
Andreas, did you use V.S. with the Visual Micro pugin? I am programming ESP32's using Visual Studio at the moment, but you need the Visual Micro plugin. The free version of Visual Micro works fine. Visual Micro seems to work on most boards ( except the Particle range), I have used it on all the Ardunio clones plus Teensy and ESP32, I do see ESP8266 in the list but have never tried it. Thanks for the video above showing how easy it is to get started, I immediately installed PlatformIO and look forward to testing it.
Visual Micro always used Visual Studio. I did not try it since then
Hello, you explain very well, I was very excited to learn your language. Congratulations on your commitment, I was so excited that now I want to learn more about the use of this platform, even if I do not understand English its explanation was very clear. Congratulations again for the beautiful work.
You are welcome! And maybe this channel helps you a little to learn English. It is very important for Electronics...
Interesting video ! I've always been very enthousiatic about Visual Studio products. This takes it to the next level and in an environment that is familiar. Great job !
Thank you!
I've been playing around with platformio for my Tessel 2 mainly finally someone puts video up how to use it lol thank you Mr spiess
You are welcome!
Super interesting. The number of choices now available is near over whelming for me. So many ways to do things that I often don't know what to choose & often each has subtle capabilities that only use & familiarity makes one aware of. Currently I am trying to stick to one processor (Arduino) & make the most of it, which is limiting in some ways, but also less distracting. It is remarkable that we live in such extraordinary times of abundance in so many things. Thanks for sharing!
You are right about the times. I think, your strategy of going step by step is good. But extending your choice to an ESP8266 or ESP32 is also not very complicated if you need Wi-Fi.
+1 Well said.
I'm new to arduino and I hope that one day any of what you said actually makes sense
Edit
As usual I gave a thumbs up as I usually love your videos and my Mrs loves your accent so I get away with watching " nerdy " videos without her moaning ,
I don't want you thinking that I don't like your videos
Greetings also to your Mrs. I am glad she likes my accent!
Andrew, when you try to learn something, don't limit yourself to watch a video of this type only once or twice.
I strongly regret that I have only today discovered this video. IT IS WUNDERBAR ! Especially since indeed my preferred processor platforms are Arduino (nano) and ESP32. And yes...I have an STM32 in my drawer that I’m planning to have a decent look at soon.
Maybe you subscribe that this does not happen anymore ;-) You find also a video about debugging ESP32s with platformIO, if you want.
I am subscribed Andreas. Maybe you see me as Jan Huygh but I log in as Atelier Vilvoorde (the company name of my maker space)
This is sweet! Im using VSC editor because its free and fast compare to other IDE out there. The fact that the Platform IO is supported in VSC, this will make programming enjoyable and easy to debug. thank you for this very helpful video!
Glad you like it!
this is an excellent intro video - can't wait to see more advanced ones pls as the move from ArduinoIDE env to PlatformIO is a big one I have found but worth it I feel. Love to see how debugging can be of aid in PlatformIO for standard ESP32 and ESP8266 env
I plan a video about debugging. The device is already ordered.
Andreas Spiess very much look forward to it. Hopefully it will be applicable to both esp32 and esp8266. Your videos are excellent and continue to support you via patreon.
Excellent intro to PlatformIO -- thank you! English tip: "gibberish" is pronounced with a soft "g" sound, like "jibberish."
Thanks for the correction.
Bundling all libraries as part of your project is actually considered bad practice in other areas of software development. This just bloats up your repository with code that you didn't write.
Instead, what you should do is this:
* Add the libraries folder to your .gitignore file so it won't get committed to you git repo
* Manage all dependencies in the platformio.ini file, as you've shown
* Once someone downloads your project, all they need to do is run the command "pio lib install" in the terminal (there's also a UI version of it through the VSCode command palette), and all the libs would get automatically installed
Other than that - great video!
You are right. For the moment I will not use platformIO for my RUclips project as most of my viewers still use the Arduino IDE...
By the way, with version 2.0 they took away the option you show at 14:30 to install libraries globally. You can only install them to your projects now, from the GUI. It's still available in the CLI with “pio lib -g install ”.
Thank you for the update.
Hi Andreas. As an interesting note for a Swiss guy: The brain behind Visual Studio Code is a Swiss guy too: Microsoft Technical Fellow Erich Gamma.
I think the whole VSCode team resides there actually. Well at least the lead developer Benjamin Pasero works at a Zurich office.
Good to know. I did not know Microsoft has developers in Zurich. I only knew of Google. So my Alma Mater brings good work to the city;-)
I made the switch to MS Visual Studio Code when I bought a new laptop 8 months ago. It's a good IDE and works well under Linux, which is what I develop on. Also has good support for multiple languages I use. Discovered Platform IO at that time :)
Thank you for sharing your experience!
This is one of those videos that I wish I could "Like" every time I watch it.
Thank you!
At 11:50 that error is a correct error for the language C and C++ which arduino is using. So it seems like arduino using the c++ language is not following the specs on the compiler and is ignoring that or secretly making a new file with the declarations at the top before compiling. In my opinion the error is in arduino ide since if I wanted to write the same program for my computer(communicating between two computers using a serial port) I would get that error in the compiler.
Arduino does some simplifications. You are right.
Having a hell of a time with my wifi radio projects, they moved to Project IO which, perhaps cause I was screwing with it? no longer compiles the code. Yesterday I was building a radio for mom, who is 96 in the local nursing home, to listen to her old favorite radio programs from the 40's and 50's which are readily available on wifi broadcast. Mom could not have any idea how to run a PC or tablet and her failing eyesight would not allow it even if she could see. So this radio was planned to have push buttons for 5 radio stations, our local AM/FM and 4 of her old time favorites. I had a programed ESP32 for it and everything was working fine till I decided she should have a 16X2 display to light up what channel it was on. While changing the Preference files, the write failed and knocked out the esp32's programing. I have been working all morning trying to get it to reprogram but since I have upgraded to 2022 version of MS nothing seems to work even going back to the old version has not fixed things. Ah well more work, more play perhaps I will get it set up before my next trip to see her after my visit with my MD in a couple days.
Good luck. I know. PlatformIO is not easy to start with.
Awesome.. finally a nice program with auto complete! I have missed that in Arduino IDE from the beginning
Very nice Andreas! Thanks a lot!
You are welcome!
Love your videos and credit/blame you for my obsession with LoRa!! This video is just in time for my recent discovery of PlatformIO and trying to use some of the Github repositories on my LoRa projects with this IDE. Although I have discovered it is not necessarily as easy as copy/paste. Further demos of using/modifying Github repositories would be appreciated, by me at least.
Thanks again for your great videos and sharing your knowledge.
I am not sure if I will cover Github in detail. Too special knowledge for this channel, I think.
Not sure if others have mentioned...but, on Linux the pretty print is Ctrl + Shift + i
Thank you. I did not know.
I've often tried it and then switched back to Arduino IDE ( + sometimes an external editor) again. One thing i don't like about platform.io are the missing settings / fuses for the microcontrollers (BOD, ClockSpeed, Voltage Reference and all that nice settings). It's possible to change them with the preferences on platformIO i guess, but it's so much more convenient to see all available options in a menu and be able to change them with a click rather than having to look up everything in the documentation.
Also i stumbled a few times on compatibility issues. The new great Atmel processors for example like the ATtiny412, ATtiny1612 and so on. Spence Konde did a nice job with supporting them on the Arduino IDE (megaTinyCore), but there doesn't seem to be a solution for PlatformIO.
And working in two different IDEs and switching forth and back between them isn't so convenient, especially because they handle a few things different. So i stayed with Arduinoe IDE and use sometimes an external editor and look forward to the progress of the Arduino Pro IDE.
It is up to each individual to chose what is best. I use the Arduino IDE for RUclips because most of my viewers use it.
Thanks Andreas. I've been looking for a better IDE than the Arduino one and Platform IO/VSC looks very promising. Easy to get my head round and fast. in fact about twice as fast to compile a simple fastLED test project with PlatformIO/VSC as the Arduino IDE (1.8.9) on my old 1.8Ghz Core2 laptop.
Love the concept of putting the Library dependencies in the platformio.ini file. No more broken projects because something has changed in one of the libraries.
Thank you for sharing your feedback!
Thanks for this introduction. I was hoping for one additional chapter - importing an existing Arduino IDE project into PlatformIO. I play the videos at 75% or sonetimes 50% speed and can follow along on my open PlatformIO. Sometimes it's hard to catch where you click a button.
I never imported an Arduino project. I usually start from scratch and copy the code into the main file.
@@AndreasSpiess "start from scratch.". Sure for simple projects. what i wanted to know is if Platformio can open complex Arduino IDE projects having multiple pages/modules.
@@DooCue They offer an import functionality for Arduino projects.
Thanks for an excellent introduction to PIO Andreas!
You are welcome!
Andreas, wirklich super erklärt und schmackhaft gemacht!! 👌🏽👌🏽
Danke!
Thank you for this excellent tutorial.
I once tried to migrate from Arduino IDE to PlatformIO (+Atom) before but found out it was not better than Arduino IDE.
I enjoy very much your explanation and start migrating from Arduino IDE.
But I have one problem:
In my projects, I have developed many Atmega based controller (Atmega328, 128, 162 etc) with no boot-loader and upload program from Arduino IDE using ISP programming.
I wonder if the PlatformIO-VSC can do ISP programming from within the application or I should other application?
Please help,
Regards,
Benawi Santosa
from Bandung, Indonesia
Thank you.
still need help on this?
caranya ganti upload_method di platformio.ini env nya