ESP32 Tutorial using MicroPython - Let's Get Started!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay normally when I show you a project it's it's semi finished like this so you've got your ESP thirty-two here it's connected up that's running it's drawing a little tree over here so it's kind of a kind of finished product but that's not the way that these modules that's not the way they come they actually comes like this okay so there's the module in there and then you've got some header pins and some cables so you have to assemble this thing and then once you get it assembled then you've got a load micro Python on there and you've got to get it going so in this video I'm gonna show you how to take this and you know get it ready to do something like this okay so we will we will get this out will solder it up and Willow Python on there and we'll get it all ready to go so from here to there and I'll be using my big my hands look huge with this new new camera that I showed you and a few videos ago I made a holder for it that looks like this and it it's kind of like a big heat sink because it was getting hot but now it stays nice and cool and it mounts up and I can put it on on my tripod so anyway so let's get going all right so we're starting out with this okay and what the other things we're going to need besides the development module and is a USB cable alright so this is a micro USB and how this goes into your computer that goes in right into the ESP 32 there's a there's a connector right there and that will power it I'll be using a USB 3 port which will handle 900 milliamp so I think a USB 2 port only handles 500 milliamps so we'll be powering powering the SP 32 and we'll also be powering some neopixels do it right off the USB now this has to be a data cable it can't be just a charging cable you got to be able to transfer data from the computer to get this thing set up okay so we've got to have that and we'll use this little breadboard just so we can put some stuff on there this was actually my first breadboard I got maybe in 1990-1991 from RadioShack see the archer logo I don't even know if Radio Shack's in business anymore but I used to get a lot of parts there okay you know this is way before the internet right but I didn't even know what this thing was for really when I saw it and I kind of thought I knew what it before but I actually had to peel the back off of it to see how the how the sockets connected at I really had no idea but anyway it's been abused you see that sauger burns it's been burned up I've overheated a lot I've burned up a lot of components but it still works so we use that now let's see I also have LED little blue LED remember long side is the anode that's the positive and the short lead is the negative of the cathode so we'll use that will blink it a little bit I've got some resistors these are quarter watt resistors this one is brown black red so that's 10 red is 2 zeros we add to it and then it's gold so this is a thousand ohm resistor and the gold means that it's a 5% tolerance so we'll use these with this LED so we don't over charge it or you know over amp it and then we also I'll show you what we'll do with the other ones later I've also got this which is just a strip of neopixels so we've gotten four neopixels these strips can be cut right here at that line and then you can solder them together and make them longer short ones in this one I just soldered a three pin header on it and that'll plug in right there so we can you know use that to do a little experimenting instance we're gonna do that I've got a couple of leads that we can plug into here whoa we can plug into there and connect a few things up and that's about all that we need I don't know if I have any other well I got this there's a big lens I got out of that projection TV I have no use for this right here so I'll put that over here and I got oh here's a coaster look at that else in space dust IPA this is a hop with space dust to me it looks like a barfing artichoke but that's not what it is anyway and then here's a my daughter gives me these here is a missus from Bozeman Montana so bozos join the fuzz oh okay anyway that's all we don't need anything else so that's what we need okay okay let's start out by opening this thing up now this is about a $6 ordered from our drums they're from eBay they cost about six or seven dollars you can order from China or Malaysia or different places like this so this is actually what they call a development board because it has all the stuff that you need already on there so to speak so it's got the ESP 32 is actually only this part right here so this part covered with the cap and then here's the antenna right here and then these are all the pant let me see if we can see these are all the pins coming off of it not the holes but down in their Co that's where all the pins come off of it okay and then you've got your USB connector you've got is this myself yeah okay so here's the USB connector and then here's a reset button it's already set on there that is I believe that that is the serial connector that converts the USB input to serial to talk to this so that's all right in there this is a where you can connect the lipo battery so it has actually has a charging circuit and there's a there's an LED right there that indicates whether it's charging or not and let's see it has a built-in LED right here which is connected to pin 13 and we'll use that in a little while to flash that LED and what else doesn't ask oh okay so you got five volts coming in here this thing runs on 3.3 so it has voltage converters to handle all that for you and you can get three volts out of that pin right there there's your ground pin you can get batter there's your battery connection and that USB connection right there which says USB that's where you get your five bolts off so you can get five bolts three volts and your ground I mean so this has all sorts of things built into it and and then you've got all your pin connectors so we won't be using this right now that this actually plugs down right there if you want to connect a lipo battery no maybe it goes this way nope okay now one problem that I have had is that you would think that these wires would be right but they're they're not I've had it where where these were reversed and I had to I'm not sure about this one but I had to swap these wires to get the red in the black the right way they just had inserted them so this works kind of like a DuPont connector you can push those little tabs or lift those little tabs and pull these out and swap them around so check that to see now here's your header pins this one fits on this side like that and this one that's over here like that now if you're going to be putting this in a breadboard like we're gonna do then you want to put them like this okay now if you were gonna mount this like on some projects I do I want to mount this to a board and then I want to plug let's say I want to plug DuPont connectors to this then I might want to solder them this way okay so think about that before you get soldered up because it's a real hassle to unsolder these things actually I wouldn't own solder it I would just buy a new one because they're only six bucks the bottom is nice it tells you you know how's the labels on all that kind of stuff you know okay so we're gonna solder it up this way okay and then we'll once we get this soldered up then we'll be ready to load Python onto it and our micro Python to it and get going okay of course you know that I am NOT going to do a project without some super glue so here's a little little trick just to get started I'm gonna take this and just put a the tiniest amount of super glue right there and right there no I mean just barely any and then I'm gonna take my pin header since I'll be soldering on the top I've got the super glue on the bottom and put my pin header in there and line it up make sure it's exactly the way that I want it don't let it rock and I'm gonna hold it here for a second and it will hold it in place and you'll see how easy it is to solder it up once I do that so let me hold this for a second until it dries up our sets and I'm gonna do the other side and we'll get ready to solder okay now we're all set up solder I got my solder right here and the yogurt cup comes out a hole in the top there this isn't a solder instruction video I'm just letting you know and then I have my very dirty Radio Shack I've obviously had this a long time I like to use a really dirty soldering iron and I'm just gonna set this into this breadboard to hold it in place and while I solder these things on there and I think I'll I'll put this up on here and we can get a close-up going so you can get a better view all right all right here's some down and dirty soldering so I'm gonna wet my tip a little bit and then I'm going to hit this one and make sure I got a good solder there and then I'm gonna come all the way down here and hit this one make sure it flows there all right got good joints and then I'm just gonna work my way down make sure I get a good hot joint all the way down on this side got a can over here that I tap off the excess as I go and one more there yep quick look at all those they all look like good joints maybe run down one more time yeah there I don't see any cold joints on there so we'll spin around and I'm gonna do the same thing here I'm going to get one on this end and then I'm gonna hit one on this and tap off my extras and then let's just write down here whoa float asana you know you remember the trick is you got to put the soldering on where it's hitting the pad and the pen they both have to be hot if you they're not both hot she's not gonna flow all right and then of course the second thing is get it done and get it done and move on cause you don't want to overheat things and don't worry about the extra solder you need the extra solder because you know that tap I'm just tapping it off on a can you need the extra solder because it gives you the extra rosin or flux that you need to make things stick well say so I'm getting a lot of extra solder then all that flux makes it stick all right that fast I can't see needs a little bit more for my liking now a lot of people will want to take this rosin off but I'm of the opinion of yeah why bother you doesn't hurt anything it protects the thing now I'm gonna inspect it right quick before I put my soldering iron away make sure I don't have any cold joints nope all the joints look good so let's go with that good to go we're done okay now we're all soldered up and if you're using lead solder then you need to go and wash your hands don't put your fingers in your mouth or anything like that okay and now what I'm gonna do is put this on to the breadboard now I'm line ended up cuz this is a tiny breadboard so we just have a little bit of space right here to experiment with but we need to have at least one row free over here and some roads free over here so we connect some things to it and then I'm just yep so we got one on top two down here so I'm just lining it up all the way over and then when you put it in you want to push it down on the pins don't push down over here because you can bend the circuit board and break break these things loose okay crack the soldering joints and that sort of stuff and you don't want to do that so you want to pin it down or push it down on the pins and get that thing seated in there okay now I'm a power sex oh we're all good here it's all everything's seated down in there the way that it should be and then here's the power now if you notice on where I put it up but a lot of my projects you'll see that I strap the strap this down because if these get damaged from the cable bending around so just be careful with that all right so I'm gonna plug it in and if you can see we've got a little LED blinking here on this particular module that is the charge indicator so it's trying to do some charging because it thinks that the battery is not charged because there is no battery so what I'm gonna do is take one of these thousand ohm resistors and I'm gonna connect it from see if you can see these things either okay that pan is the USB pen so that's five volts that is the battery positive pin so if I connect this from the USB pen to the battery positive pin it thinks that the battery has five volts on it the charging the charger shut off okay so we got nothing going on right there alright so we now we're powered up we're ready to go we're ready to load Python on here so the first thing we'll do we'll get micro Python loaded and once we get that loaded and run on the command line and all that sort of stuff then we're gonna blink that LED that'll be the first thing we do alright so let's move over to the computer and start working from there okay I am using Lubuntu which is a version of Ubuntu which is you know of Davian okay so I will be doing it that way getting this software and all that stuff but everything that I do here should work for other operating systems as well very similar okay now the first thing that you've got to do is get a program called ESP tool okay and that is actually made by the pro by the manufacturer of the SP 32 and it is what we use to load the operating system on to the SP 32 now the way that we get that is by using the Python installation application called pip okay and so you'll have to install pip so here was how I would install pepper sudo apt-get install Python 3 pip I happen to already have pip installed so I don't need to install pip but if you did and that would be how you do it okay and then once you have pip installed then you're going to install the ESP tool using pip so I'm using Python 3 of course so I'm using pep 3 so the command is just 3 install the SP tool and it tells me hey you've already got that stuff installed so why bother and the answer is yeah why bother ok so now you've got pip three installed and then you install yes the the installation of the ESP tool then the next thing that we've got to do is go and get the go get the bin file or you know the binary file that has the operating system so we go to micro Python ok just search for that there it is right there and we just go to the Downloads so here are the downloads your options go to the SP 32 and what we want is one of these standard things unless you know what you have don't worry about that other stuff so just just want one of these standard ones this was the first when they went to one point one that was a big change there so that's the one that we'll get so we'll save that file there and notice that they give us some some advice about how we need to install this so first we need to erase the flash and then when we install we use the SP tool and we need to start at address 1000 if you don't start address 1000 it won't work so just as simple as that so these are the exact commands that we'll use ok so now that we have that downloaded here it is right here then we'll pop back over here to the command line and we will do what they told us to do so let me put that command in there now one thing you have to do is tell it where where you are so in my case I'm at USB 0 but if I had multiple USB things in there I might be at USB 1 or something like that so on maybe on Windows you're gonna have to tell it which comport you're using so but figure out which port you're on and run the ESP tool and tell it to erase the flash and there it goes so it's a race thing with a flash once you even done this one time you don't have to erase the flash every time you update the operating system but it's not a bad idea just to clear everything out okay so now the flash is erased we are ready to put the operating system in there so here's our command the SP tool we're telling the SP 32 here's the pork again it's us it's for me it's USB zero right flash and then this Z command tells it which address to start at so we're putting in the 1000 and then this is the bin file that we want to run ok all right so it's connecting yeah there it goes so while that is doing that let's pop back over here and the micro Python you want to go and look at the docs because they just redid everything and you can go to this quick reference right here for the SP 32 and it will kind of go through all all the things you need to do to to get going ok there's even you know installation stuff and all that sort of thing so that's just in the docs answers there's tons of good stuff they just read on it and it is it's a lot better organized in that sort of thing ok 80% done bla bla bla bla bla bla and bingo ok so now we have micro Python installed on our ESB 32 and if we look at our ESB 32 oh it doesn't look any different ok so now that we got micro Python installed on there the next thing we've got to do is connect to this thing through the USB cable using a serial connection ok now if you are running Linux then you've got to add yourself to to the to the dial out group so yes I should add myself not my I was cutting and pasting from my notes okay hey I'm already a member of the dialogue group so dial out is what allows you to work with the column ports okay now on Linux if you first-time add yourself to the to the dialogue group you need to sign out and sign back in or reboot or something like that okay now just for good measure because we're going to be using it I'm going to show you how to use a tool that I use and it uses this so we'll use tip 3 to install PI serial and PI serial is just something that you can use to see really communicate with a lot of stuff so it's good it's good to have anyway now I've already installed it so it doesn't want to install it again and then finally a good there's all kinds of things that you can use to work with your serial work but I use and they recommend this they recommend this on the website is to use Pico column it's just a really tiny easy command-line thing to use okay of course I've already installed it so it's already there okay so now that Pico comes installed and I am a member of the dial out group are I have permissions to use the port's then we can now just connect so this is the baud rate that the repl or repple is the it's the connection that they use this is the baud rate that it uses and of course you have to tell it where look and I'm at USB 0 and I hit it and it's connected up it says that the turmoils ready okay now we have python right here so we're at the Python pom prompt we can you know three plus three and the answer is six we can import OS you know if you know anything about Python you know what that is we can get oh no I saw one there you go so we can see what's available so the only program that we that is written on their booth py okay so just all the regular things now if you need to reset you have a couple of options okay one is on this board almost all dev boards there's a there's a button right there okay that's that's your reset button so if we were looking here and I push the reset button you would see that it goes into a full hard reset okay the other option you have of course you know that controls seed breaks any commands and then if you do a control D it goes through what they call a soft so here this isn't it did a soft reboot okay so control D will cause it to reboot or the reset button will cause it to do a full hard reboot okay it does more stuff okay now what can we do all right how about we let's let's blink that pen like I said on on this particular board there's a pen right here or there's the LED you see that there's a tiny little LED right in there next to the USB port and that is connected to pin 13 over here and we can you can blink that thing alright so just as a first go around let's blink that so there module call machine and it has a sub module called pin so let's do from machine and port pan okay I okay import pin alright now we'll use the variable P and we'll say that equals pin and we know it's pin 13 and we wanted to be and output okay so P pin 13 and output and now we can assign a value to that p value 1 now when I hit that actually let's let's get this let's get this up where we can see it all right so we're looking at a little LED right there and when I say value 1 that's going to turn on and then we can do values 0 and it goes off we can do one again and it goes on and we can do zero and it goes off okay so very very exciting now that works all right let me well I'll just leave that like that for now okay now that's really nice but what we really want to do is is load some programs up right because we don't want to just sit there and do command line stuff on there we want to load some programs so here's a couple of programs that I have got this one called blinker and it's a real simple program it's just going to initiate our instantiate pin 13 as an output just like we did and then it's going to turn it on it's going to print that it turns it on and it's going to turn it off and it's going to turn on turn it off it's got a half second duty cycle right okay now we want to load this thing up well we could we could type this out and all that but I don't want to do that so what I've got is a program that is just it runs right over the it runs right over the serial line and it will just load these things up so I just have to tell it this is the little Python script it uses uses PI serial that's why we installed PI serial earlier okay so I just have to tell what Porto on it not don't want a file system don't want to go here and I just want to load up boot I'm gonna load up main I'll go ahead and load up blinker and go ahead and load up Pixlr and we will use those in men now the way that so I've got boot Maine Pixlr and there's blinker right there so those are our four scripts now the way that the reason we're going to load up boot and Maine is what the what happens on reset is that first it runs boot now I don't have anything in boot it's just notifying that boots been run but this is your low level stuff like setting up the network and that's sort of you know getting connected to Wi-Fi that is what boot does so if there's a boot program or you know a boot script it'll run it and then it'll look for the main script and again I don't have anything in here we'll put something in main it's just a little bit but I don't have anything here but after boot it runs the main script if it exists and then then you can import these other things and run them okay so now we're connected up using Pico calm and we want to get out of Pico calm so to do a command in a command feature and people calm you do control a and then to get out you do control X so I just did control a control x thanks for using Pico calm and we're out of there okay now I've already set up I told it what I wanted to do and so now I'm just going to use we use Python 3 wrong to run that script we just looked at and there it's loading main our boot main loaded blinker and the Pixlr so it's just assumed that sending that stuff right up there and and then now we're gonna use Pico call we're gonna connect director model is ready let's import OS and then we do LS this dear let's see what we got yep so now we've got boot we've got the main we've got blinker and we've got Pixlr that we can use okay now if we did control D it's gonna first run boot that it's gonna run main and then nothing else is gonna happen okay so that we just soft reboot here's where it tried to run boot there was nothing in there tried to run main there's nothing in there and now we're ready to go so let's import blinker okay blinker has loaded cuz we told it to write load when it loaded and then let's just do what was it it was blinker blink okay and let's pop the screen back up there and when I tell it to to to run it should go and there it goes okay so that's our first script that we've run we're running blinker okay so it's just saying pin 13 on off on off off and of course when we want to be done with that we do a ctrl C and I put a catch in there try except so that it doesn't throw an error okay so there we go now let's say that we wanted to do that at the start we could just open up main okay just write and port blink and blink your dog blink okay so as soon as as soon as boot boot will run and then main will run and when main runs that's what's gonna do it's gonna import blinker and then it's gonna run blinker blink until we hit the ctrl C okay so let's exit out of here ctrl a ctrl X that gets us on a Pico calm let's rerun replace and our rebel a sore replace or what anyway we're replacing all those scripts we didn't have to place all up we could have just replaced name okay and then we'll connect backed up and terminals ready let's do a soft reboot okay actually let's pop it back up we're gonna do it we'll do a soft reboot and when we do the soft reboot then it will run main what a run boot and run main and when it runs main it'll do the import that we want okay okay so there it goes there was our soft reboot ran boot ran main loaded blinker and there we go blinker blinker blinker and it's blinking away okay simple enough okay and then when I hit control C there's nothing left for it to do it interrupts there's nothing left for it to do and we're done okay now let's make this bigger and let's add a little electronics to it okay now what we'll do is let's say we'll come look at these pins and this is our ground so what we'll do is we'll run this ground over to the bus so this is your a bus right here so we'll run the ground there and then let's I'm gonna take this resistor off for now we're gonna run the usb since we only have one set of pins over here let's run the USB to the bus as well and so that's given us negative you know negative here and we got five bolts here okay and then we can take the battery and fake out those charged by putting that wrong pin okay so we got that we got that blinker to shut up okay so let's say we want it to blink this baby right here this little blue blue LED okay well we can stick it right here now remember I didn't I was doing it backwards short pen is the negative the Catholic long pins the anode positive so we will blanket on the positive so will we can put it right here and then we need a resistor we don't want to put 5 volts to that LED it'll burn it up right so let's put a thousand ohm resistor we could go lower than that but because most of the time it's a little LED like that we'll handle 20 milliamps but this will only allow 5 milliamps to go through there thousand you know using let's go and then since we are coming out of pin 13 right there we'll run that over to here okay now we don't need to go back to the terminal to do this thing we can just hit the reset button all right and there we go we got these things blinking together all right so this just happens to be hooked up the same way as that all right but that's how you would blink a pin if you didn't have that so you would just come from the pin that you're using pen 13 here to your LED through your LED make sure you got your a node and cathode set up right got it gotta use a resistor use Ohm's law to figure out what then that goes to negative and now you're blinking away okay so there's that now let's set up the needle pixels all right so you'll undo that take this out and we are gonna move to 1012 okay we'll just let let that continue to blink no need to worry about that so pent well I've got the program the neopixel test program this is on pin 12 okay so that's the signal out now we could run this through a resistor because but I I think you need about a 470 or something like that don't worry about that okay so here we've got ground pin signal in and the five volt pen all right so let's stick this baby right here right there alright so this is our input here let's use a different color in 13 here's 12 I'm gonna run that to the center that's the input all right and the reason I wanna use a different color it's because I've got to put the five bollocks here and I use the same color so I'm rather than that let's go back to the bus and then we gotta get some negative to it right there back to the bus okay and we have a little signal run in there don't worry about that right now all right now what I'm gonna do just to make it easier to film and put this little piece of paper over here because it can get really difficult to see film and see these things but this will kind of mute it out actually let me move this pin back to kind of hold it in place there we go that allows us to see something I'm gonna turn that light out okay okay so we got that going let me make this small again up there and then I'll tell you what why don't we why don't we just edit our our main okay so we'll leave the blinker on so the first thing that will happen is it'll blink and then once we cancel that out oh you can't see this hold on okay so we'll leave the blinker in there and then we'll we'll import Pixlr and we will run Pixlr drummer and that's that and we're gonna run it on pen 12 and we've got four pixels on there so so that should do it so let me save that okay and then let's get this thing going and we'll do a ctrl C oh let's let's hope we need to hook back up and then we'll run that again and there we go we're loading everything up and let's connect back up so you can see what's going on terminals ready let's do a control D to do a soft reboot and get get this up where we can see it okay so there's our flashing light now when we do control C it's going to kill that routine and it's gonna then go over to the pixel routine routine that we wanted to run okay so here we go control C's gonna kill that and now we're running and it's just gonna go through a series of colors and run those neopixels that we had there okay now that's it we got this thing loaded or we got it we got it open we got a soldered we got the program programs we need loaded to our computer that we've loaded the operating system we went through how you can run a command line and that we uploaded these programs and our scripts and we run the scripts and you know that's that's it that's how you get started on this thing okay I will put a package together of all this stuff all this all the things so I will put I'll put a package together of all of these blinker well so boot main blinker Pixlr and the replace program and then you can download the latest version of the Bend file from from the website when you go up there so look for the link down below and good luck with this thing okay it's good okay so we're just flashing those see if I take this off you can see it you just can't see the colors as well okay now you can look do that Pixlr script and and see more what up how that thing's running but there you go there you have it cooking with gas ESP 32 [Music]
Info
Channel: Clayton Darwin
Views: 65,930
Rating: undefined out of 5
Keywords: DIY, Homemade, esp32, micropython, python, python3, esp8622, tutorial, how-to, learn, course, student, education, ws2812b, neopixels, fairy lights, electronics, led, leds, esp, cnc, arduino, lubuntu, ubuntu, debian, soldering, solder, breadboard, circuit, circuit board, pcb, development, dev, development board, soc, programming, picocom, esptool, dialout, linux, raspi, raspberry, raspberry pi
Id: QopRAwUP5ds
Channel Id: undefined
Length: 47min 35sec (2855 seconds)
Published: Sun Jun 23 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.