Easy to use than Arduino | Getting Started with Micropython on ESP32 | Micropython series EP1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone to the first episode of micro python series where i'll make sure that you all get comfortable on using esp32 board in micro python for any of your projects so in this first episode i'll be guiding you with downloading the firmware file of micro python downloading tony which is an id for micropython installing or rather flashing firmware onto esp32 board using tony and in the end we'll be making two very basic projects just to get started with micro python out of them one is like blinking led on the esp32 board and second is reading the button status of esp32 and turning on and off the led according to the button pressed so this is a very basic video so if you're not at all aware about micropython don't worry after watching this video you will be comfortable in programming your first project in micropython and let's get started this video is sponsored by ltm which is a pcb designer based software company now let me tell you one very interesting very unique feature about this software which i bet you haven't seen in any other pcb designing software and that feature is called as follow me mode now this is truly very useful feature which i can't explain it in simple words let me show you the actual video of this particular feature have you seen that the path automatically adapts the curve quite seamlessly and how i can imagine making this kind of path in any other pcb designing software would be really a tedious task for sure now you can also try this and many other features of this pcb designing software by just clicking on the link mentioned in the description yes by clicking on that link you'll be getting a free trial version of ltm designer software so go ahead try it out and you find it interesting you can purchase the software later on so now the first step is we need to download the firmware file of micropython particularly for the esp32 board and for that you need to go to micropython.org website and here just go inside the download section now here you need to select the board on which you want to flash the firmware file so in my case it is esp32 board and if i talk about which esp32 board i'm using then i'm using this do it david v1 module and if you want to get the exact same module well you can get it from our website where we are selling it at the cheapest price on internet just click the link mentioned in the description and you'll get on this page and you can buy the esp32 module it will be delivered at your doorstep so now select the esp32 board here and here just download the latest firmware file so i'll uh click on this link which will automatically start downloading the firmware file so yeah that was all about downloading the firmware file now the second step is to download the thorny which is a python ide for beginners at the tagline says now you can consider it as a kind of arduino ide so arduino has a plus point which is uh it has its own language it has its own ide it has its own hardware so everything is developed by arduino but in python it's not like that python is an open source language so the firmware file is different the id will be different there are so many different kind of ids available on internet but this is the easiest and quite interactive or we can say ide and somewhat feels like arduino so if you are coming from the arduino a programming language then this will be best suited for you and this is also for best suited for beginners as well so now you just need to download it according to your operating system i already downloaded uh the mac version of this software so i'll just start that tony uh ide okay so here is the thorny ide now before we get started with programming this board we first need to flash the firmware onto the esp32 board and the firmware file is still downloading and no problem uh but now to flash the firmware we will require one tool called as esp tool okay and you don't need to download it externally like you can also download the plugin of that inside this thorny and let me guide you for that you just need to go to tools go into manage plugins and here the search for esp tool here is that esp tool plug-in just click on that and here you will get one install button in my case that is as it is already installed i'm not getting that install button but you just need to click on the install button that's it click on the close button and with this we have successfully installed the esp tool and now we can you know erase the firmware of the esp32 board and uh you know flash our own micro python firmware and let me guide you with that as well like how to do that for that you just need to go to run into select interpreter now here in the interpreter you have to select the micro python for esp3 to just select that after that select the right com put on which this esp32 board is connected with okay after that click on install or update firmware here again select the port so this is the port now for the firmware file we'll be you know selecting the file that we have just downloaded in my case this one okay the version 1.17 i'll click on the open button make sure you have check mark this box called as it is flash before installing another will erase all the previously flashed data and then it will start installing the firmware okay after that just click on the install button and it will start all these steps required okay make sure you press and hold the boot button until it says writing okay as you can see the writing appears here and now i can release the boot button so now it will erase the flash and you know flash the micro python firmware on it two very boring minutes later okay so the micropython firmware is successfully flashed now you just need to click on the close button click on ok now to crosscheck whether the micropython firmware is successfully flashed onto our esp32 board or not well you just need to press the reset button on the board and here as you can see it says micro python version 1.17 uh esp32 model with csp that means the micropython like this esp32 board is running on micropython as of now and here as you can see this three arrow appears here which is also termed as ripple repl whose full form is read evaluate print and loop so this is kind of a feature provided by python in which like we can interact with the python uh you know powered devices like this esp32 without uploading any single line of code in it for example as of now we haven't uploaded any code on it but still i can interact with this device via python let me show you the example so here uh first of all i'll type the command as print which is used to print data into the bracket i'll type the first thing which all the programmers type while learning new languages is the hello world and when i press enter as you can see this hello world printed here and all this is running inside the esp32 board okay so without uploading any single line of code we can interact with this device and we can also interact with the uh gpio pins of it and for that uh we first need to import one module called as machine before that let me show you or what is machine okay so when i type help here all the important uh we can say commands appear here regarding esp32 for like micro python on esp32 for example here as you can see it says input machine now this is uh similar to including a library inside an rd no ide so here we are including the library called as machine which is responsible for all the gpio pins attached to this esp32 board okay so after importing that machine module we can now interact with the pin number for example so here you can see the pin 12 is defined as output by this machine command and after that we are sending the data one let's just try out this thing so first of all here i will import the machine okay i'll press enter so your machine module is successfully important you can say the library is included okay after that i will define one variable which is led and it will be nothing but machine dot pin into the bracket pin number two because i want to turn on the built-in led of the csp32 board which is attached onto the gpi2 after that i'll type comma and here i will type again machine dot pin dot out output so this is the simple command to define pin number two as output and it will be stored inside the led variable okay i'll press enter here we successfully did it now we can turn on the led on the esp324 by just typing the command led dot value in the bracket one and let's just press enter finger crossed okay so inbuilt led of the esp32 turned on let me just turn on my smartphone's camera to let you show the results as well okay so yeah here is the ide i will again type the command as zero to turn off the led and i'll press enter okay the led turned off if i turn on again and turn off so as you can see like without uploading any single line of code we are still able to access the micro python device which is the esp82 that's the power of python that's the power of rebel you can see so that was the steps to flash the former on the esp32 board now let me guide you on how to upload actual python code onto this board and for that uh this id will be super useful so here inside this particular window you can write your python code okay so let us start writing our first ever python code to blink the led on the board at an interval of one second okay let's start so first and foremost thing is we need to include the modules or you can say include the library and for that we'll be including the model called as machine module so machine module is responsible for all the pin numbers and we'll include another module which will be time which will is responsible for you know delays kind of thing okay we want to provide a delay of one second before that we need to use the time module as well so these two libraries of these two models will require after that let just define the led as a variable which will be responsible for turning on and off the led like the built-in led of this esp32 board so i'll type the same command led is equal to machine dot pin into the bracket pin number two again comma machine dot pin dot out okay so with the single command we have made the pin number two as output and it is stored inside the variable led okay now i will type while true now this is same as using a void loop okay so here we don't have a void loop kind of thing so we have defined here while true that means it's an infinite loop so code will be staying here forever okay after that we have to provide the colon that means now we will be writing the code inside the while loop and when we press enter as you can see it has some space uh here okay this is called as indentation in python okay so python don't have those curly braces as we have in c language rather it has the indentation so if we put the indentation the id uh you know what you can say interpret that the code is written inside the particular function for this example inside the while loop so let's start writing the code so first of all we need to turn on the led so it will uh the simple command is led dot value into the bracket one after they will provide the delay and for the delay we will type the command as time dot sleep into the bracket one now here we need to provide the delay in number of seconds so earlier in the arduino we'll be providing the delay in microseconds but here we have to provide delay in seconds so one means one second if i write 0.5 here that means 500 millisecond okay so let's keep it one as of now after that again we'll turn off the led by typing the command led dot value zero and time dot sleep into the bracket one so yeah that's the simple code of blinking led onto the esp32 board at the interval of one second let's try and test this particular example so i'll click on the play button here and i'll select the micropython device now here there is one very important thing to keep in mind we have to save the code which we want to run onto the esp32 board or in a micropython device where to save it with the name main dot pi okay because the firmware is written in such a way that astronaut just boots up it will first run the boot.pi file and after that it will run the main.pi file so you have to write this particular name only click on ok and okay the firmware is successfully flashed if i turn on my camera on the smartphone you'll be able to see that the led is now blinking at the interval of one second so with the simple line of code we are able to uh blink the led interval of one second that's that's this how easy to use micro python uh thanks to tony id as well okay so yeah that's the first project the first code that we have written ever for micro python let us move one step ahead so this was all about uh making a gpio pin as an output but now let's try to make a gpio pin as an input and read the data of it and act accordingly okay for that i'll again include one more variable called as but which is which stands for button is equal to machine dot pin into the bracket now the button is attached to gpi zero so i'll type zero here comma machine dot pin dot in that means it is an input device okay so now what i'll do i'll delete all these things here inside the while loop and here in the value i'll create another variable called as button status which will be equal to but dot value okay so whatever the value of the button is will be stored inside the butt status so here i will type the if condition now so if but underscore status is equal to is equal to true or it's a reverse logic so let's just type false okay so if it is false i'll press colon here and again press enter as you can see there's one more indentation appear here which reveals that now the code will be writing which will it will be going inside the if condition okay so if the button status is false that means the button is pressed we are turning on the led i will type led dot value for bracket one else i'll turn off the led led dot value into bracket zero okay no semicolon led dot value okay great so yeah that's the simple line of code to turn on and off with the led according to the button press let's just try and test it out the code i'll click on the play button okay first of all we need to stop this okay so now we can press the play button and i think it's done okay so let's turn on the smartphone's camera so yeah here's the sp3 board and if i press the boot button as you can see they already turned on if i release that led turns off on on off on off on off on off on yeah so yeah our second project of you know interacting with the button and turning on off the led according to button press is also successfully working by just like writing very simple line of code so yeah it's that easy to start like getting started with micro python it's that easy to you know write code in micropython as well well there are some of the tricks here uh to you know reduce the number of commands for example if i type here as from machine import pin what it will do it will just import the pin related functions from the machine module okay so now we no longer need to type this machine here and we can just type directly pin here okay we don't need to type the machine dot pin and this will again make our code way more simple but typing this command now we don't need to write machine dot pin and if i like upload this code like we stop it again and re-upload this okay same that's the code will work in the similar manner only okay let's start the screen this camera as you can see it's turning on and off the led it's working similarly like it was working before okay so but yeah what we did we just type this command and the rest of the command becomes way more shorter okay so there are more such tips and tricks of python which i have been guiding you all like within every episode so yeah that was all about the first episode i hope you got to know about how to use micropython on esp32 board it's really very simple very straightforward okay now the reason of me shifting towards micro python is basically i want to you know make next level projects in uh ai ml and computer vision stuff like that so when i search for these kind of projects i found out that for computer vision we need to use opencv that requires python for machine learning we need to have a tensorflow lite which requires python so these are the things that requires python to interact to make projects in that particular domain so i thought why not to shift onto micro python and start making some new next level projects and as i thought of shifting onto micropython i thought why not to share this knowledge with you all guys let's start learning together sharing together and let's just reach to that peak point together okay so that's the main reason for me shifting onto the micro python and yeah that was the first episode so in the upcoming episodes i will be you know making way more cool stuff maybe the iot project maybe the the websocket based projects maybe the bluetooth based projects as well do let me know in the comment section like what uh you want to learn about this especially board like what do you want to make using micro python particularly on our especially what do drop your suggestion to the comment of the video also share this video with your friends and let them know that sachin sony like techies have started this whole new series of using micropython on esp32 this will be super fun super useful super easy to understand super interesting ad as well and that being said i'm just ending this video here and now just wait for my next video explode and share with me techy sms you
Info
Channel: techiesms
Views: 13,471
Rating: undefined out of 5
Keywords: techiesms, electronics, electronics projects, Micropython on ESP32, Esp32 Micropython, Thonny, micropython esp32 tutorial, esp32 micropython thonny, micropython esp32, micropython vs arduino, micropython tutorial
Id: 1efsWgK_QaU
Channel Id: undefined
Length: 17min 26sec (1046 seconds)
Published: Sat Nov 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.