ESP32CAM WiFi Enabled FTP Image Uploader

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys how you all doing hey welcome to another video today we're going to be checking out the esp32 camera module this one is the AI thinker module we're going to have a few videos on this one but today's video we're going to check out how to cause it to go to sleep and go into low power mode and then wake up take a picture of whatever's in front of it and then have it upload to an FTP if that sounds like something you'd be interested in stay tuned because it's coming up right here right now on Mi Sperry [Music] okay guys so here is the coding section of what we're going to be doing so what I've got here is I'm using vs code for this one you can use the Arduino platform that's totally fine I like vs code because I like being able to integrate uh VI Vim which is enhanced VI and all the other stuff because yeah I'm one of those people that uses VI but um I also uh it comes with platform IO that's what we're going to be utilizing you can just Google around how to install platform bio it's actually really simple you just go to your extensions and choose platform i o and it installs it so pretty simple but I'm going to have all of this code up on to my GitHub so link Down Below in the description so that way you guys can check it out but basically it's going to be a fairly simple uh code to get this all going so what we're going to do is in the beginning we'll have our includes like we normally do and here's our setup script so in our setup we're going to turn off the brown brown out detection because it can kind of get in the way of when the startup happens for this specific module go ahead and set our uh serial to begin and then the first thing we're going to do is initialize the SD card now on these little modules they do have a flash right a really really bright white LED right so now me personally I don't want to use the flash I'm we're probably going to be adding maybe some infrared uh LEDs to this or something like that in later videos but I don't want to use that flash I want that flash to stay quiet as well as also it is connected to pin D4 and pin D4 is also used as the enable uh pin I believe I believe it's enable for the SD cards so if we're going to be using the SD card we kind of need to tell it that that pin can't be just turned off permanently right so there is a software control that's with the driver package and that's what this is right here so when we do the MMC begin we just do this SD card true and that lets it know that uh that we're going to be using the SD card and to basically disable that flash which is great so that way it doesn't interfere otherwise you'll get failures you'll get errors that say it can't initialize the SD card so if you're getting that can initialize SD card make sure you're not playing around with a digital pin 4 or utilizing that in any way otherwise you you won't be able to use your SD card properly okay so there's that so we begin reading it so we're going to read our config file that's in there and once we read that I'll kind of go into this a little bit I do have this config file uh the function read file that's in here this was also a borrowed code from another uh platform I'll see if I can find the link and put the link down below of where I got all this from because this was so helpful I got one of the other links for the FTP code that we're going to be using that's down below as well so if you want to check out those packages individually so anyway we come in here but we've modified this a little bit it used to just it would just print it you know print it to the serial line but we want to save it into our variables and so we've got this source file called constant now I've modified this as well from its original uh use it originally had where you would just put in all of your your SSID your password your FTP server your username password remote all that stuff you put all that in here but I want it to be where you can put that onto a text file onto your SD card and put that in there so that way you don't have to touch the code once you get it up and running so so I took all of that out gave it some some size some some you know size to the arrays because I don't know how big people may make their ssids or whatever that's probably excessive but oh well so I went ahead and gave it some size came down in here and this is where oops not in here go back to the config file back in here where the read file is now what it's going to do is we're going to open a file for read as we're going to do um and pull open so that uses our FS open which is using the SD card uh file system to open that up so once we open that up then we're gonna we're gonna print out whether we were able to open it or not then we're going to actually start reading it so we're going to do our file and then dot available which dot available is basically if there is available characters it reads it one character at a time so know that so if you have something like a text file which I'll show you what the text file is going to look like and it's basically spaced out in a column the different things have a different carriage return remember it's going to read it all as one giant line so the carriage returns everything it's going to read all of it as just one big line because it's going to go character by character in that file so we're going to read that into a buffer array then we're going to come down here and change that array to string because there's a lot better string functions and and you know different string manipulation functions that's available in the string.h header file so I'm just going to convert that character array into a string called read config then what we're going to do is we're going to get down here and we're going to do our begin parsing out our field so we're going to start parsing it by the equal sign so now would be a good time to show you the config file so let me grab and just a notepad you can make this however you want it's going to be just like the variable definitions that are in the constants so let's see where let's see constants there we go so it's going to have the same names as these so what we're going to do is we'll have SSID equals let's say my network sure excuse me and then we're going to have pass equals no spaces equals let's say uh pass word one two three four five yeah the most secure password in the planet all right and then FTP server equals let's say it's 192 and 68.256.0 whatever it might be and then we have FTP uh user oops FTP underscore user and we're going to say that's equal to I don't know my user and then FTP user uh or FTP pass sorry pass and that equals again password one two three four let's say and then we have FTP remote directory and that's going to equal let's say files sure all right so that's our config file right so it's going to be reading all this information in when we do this so that's basically what we're doing so we're going to basically break it and parse it well if I can stop closing that file we're going to parse it at the equal signs okay so remember it looks like this and you've got uh all these equal signs so that's what we're going to do we're going to basically start splitting the array and reading what's after the equal signs that's what we're going to be doing and then we're going to store that in to another array called configs and that's going to be our configuration so that's what this basically Loop does is Loop through that and parse it then when we're done it's going to basically break everything apart um at the at the equal sign but there's going to be all these Carriage returns that are after this because since I'm doing it you know I'm not doing this all rammed together it's going to have Carriage returns in it so I want to get rid of those carriage returns and then any kind of new line feet well these are new line feeds uh and then there's actually some spare Carriage returns that are left after the Line Feed so we're just removing all of it so you're going through removing all that then once we're done then we can actually assign our array so what we're going to do is now since the let's see let me find it where is it at the the constants or whatever since these are basically chars and they have to be um you would have to do some other manipulation to get the string to the chart to get it into the different functions that call these variables but what I did is I just declared them all as Char here excuse me and then uh come in here and basically I just use the two Char array so that way it will convert the string which is this configs uh string it'll convert that into another Char array again and then it'll put it into these different uh Char arrays that I have for the different pieces and that's pretty much it that's pretty much all there is to uh doing that so that's how the read file works so we read the file set all of our settings once we've set all of our settings then we can initialize the Wi-Fi we can connect to the Wi-Fi and then we begin our Loop so how this is going to work is we want to check to see if our Wi-Fi is connected because obviously there's no point in doing anything if Wi-Fi is not connected and then if it is and the camera initialization went okay that was up here somewhere that was up here if the camera goes okay then we'll go ahead and we'll take a picture and so if we're going to take our picture oh up here sorry I'm scrolling back so um take a picture here and then we're going to put it to sleep so we're going to enter the ESP deep sleep which basically puts it into a very low powered mode it basically turns off the transmitter uh for the Wi-Fi and does other things to put it into a very slow a very deep sleep it puts the processors to sleep too so the only thing that's active is um timers can wake it external wakes could be configured if you wanted to external like maybe a PIR sensor or something and let me know in the comments if you want to see how to wake it with a PIR sensor or something like that that might be another addition to this that we might do later on but currently we just got it on a timer so it's going to deep sleep for 60 seconds and that's the 60 uh e to the six because it's actually in microseconds so I'm going to say it's 60 you know million microseconds would be 60 seconds so basically it's going to sleep for 60 seconds and then move on now if the Wi-Fi doesn't connect for some reason it will uh just immediately go to sleep and so it will and inside this Wi-Fi connect uh it will try up to I believe it's a five times which is why we give it a little bit of sleep here give it some time to do those trials and whatnot so it'll try about five times to connect so then it just enters deep sleeps and it'll try again in 60 Seconds so that's pretty much it for the camera so let's go ahead and compile our code and just like that we have success so there we are to upload it's very simple you just take a USB to serial uh connector of any kind make sure it's five volt it needs to be a five volt uh USB to stereo connector otherwise you will get the round out detection you'll get basically low voltage errors and things like that when you try to flash it uh it basically it just won't boot you do have to short a couple of pins and I'll go over that uh with you guys in the hardware setup we'll go to the bench now real quick and I'll show you how to connect it up so you can you can Flash it okay guys so here is our module so I got it all put together here so SD card now I just could find a 16 gig you probably should just do a smaller one than that but uh anyway that was what I had laying around so slides in the back presses in you can feel it make contact this is a pretty simple flat Flex cable you basically flip that up if you can see that and then you slide the camera module in nice thing about these boards is you can buy different camera modules I remember exactly which one this one is is the one that it comes with but anyway on the back here so there's the actual esp32 module so now I've got one of these USB to uh serial type cables here and that's what this this is so I've got uh this little ftdi USB to serial connector thing so the only pins we're going to need is power and ground receive and transmit okay so you'll configure this up and I can throw a uh a schematic up on the screen here real quick but you've got your uh you got your power and then ground is on the bottom here and then you've got receive and then transmit and that's it that's all you got to uh to connect it with there is that led I was talking about that's that really bright one if you've ever used these boards before this is really bright because it's kind of like a flash I have that disabled because it's on the same pin that controls the micro SD card so you want to disable that now for programming it you have to jumper a couple of pins so I'm just using a simple jumper here let me back up a little bit I'm just using a simple jumper wire is what I'm doing if you have this in a breadboard you can jumper it that way if you have one of those little short uh pin shorters you could use that but basically I'm just taking two of these putting them together like this and then it's basically you're going to Short the pins basically you're going to skip the first two pins let me let me Zoom back in and show you this so you're going to skip the first two pins and then it's the next two pins that you're going to short together and then there's a reset button on the back once you plug the other end of this in to your PC you just press that little button it'll go into program mode and then you can just program it up you'll hit build or upload in platform i o or your Arduino IDE and it should upload once it is finished uploading you have to remove this jumper and press the reset button one more time to get it to reboot itself and come up not in boot mode but actually to execute the code okay guys so I've got uh took me a little bit but I've got our USB km setup or at least our esp32 cam setup so down here in the corner so I'm going to go ahead and open a terminal I do have it plugged in so we may see it going I also have a terminal open to a Raspberry Pi that I have this thing Wi-Fi connected to and it's hosting my FTP server so uh I put it in the files directory and so there's a picture already in there so I'm going to remove it so that way we've got nothing in there and then I'm going to go ahead and turn this on so let's go ahead and check out how our device is going so the Wi-Fi did connect on if you can see that but the Wi-Fi did connect uh down there it's got an IP address and then it takes it a little bit and then it will capture a picture and it looks like it took the picture cabbage has your success upload via FTP no errors and then it went back to sleep so now we should be able to pull back up our terminal and there's our picture so now I'm gonna go grab this picture back off we'll see how fast I can do this okay so I got win SCP up here so I'm just going to log in to that Raspberry Pi that I've got going on here okay so we should be able to see our different directories here we're gonna back all the way up actually it is in home uh and then me it'll be in FTP files and then there's our image so I'm just gonna take and put that on my desktop real fast let's just throw that over there all right let me go grab it and of course without uh a whole lot of lighting there is our picture so you can see why we probably are going to need to do some lighting so you can actually see the camera that's looking over looking over the desk but there you have it there is an image taken so hopefully guys that was useful for you make sure to like subscribe share and all that jazz make sure and check me out on all the different socials I'm on Twitter and Facebook and Instagram and just and Reddit and pretty much everything so just check me out on all the socials I will put links in the description for all this stuff uh where you can download the code do the build uh this yourself or whatever but I have links for everything down in the comments below also coming up is maker faires coming up next month Maker Faire down here for uh Wichita Kansas I want to invite everyone out there because I'm going to be giving a giveaway out at Maker Faire so you can sign up for that and you will get some pretty cool uh prizes if not uh maybe one prize one big prize and maybe some little prizes but you will get some prizes uh so definitely come by but you can only get those prizes if you come by actual Maker Faire and say hi so I'll be there at Wichita Kansas it'll be an Exploration Place which is a museum in Wichita Kansas but if you want to come visit me come visit come check things out I'd love to see you in person and sign up for the contest and see if you can't win some things so with that that ought to do it I will see you in the next video foreign [Music]
Info
Channel: misperry
Views: 2,020
Rating: undefined out of 5
Keywords: arduino, esp32-cam, IoT (Internet of Things), DIY Electronics, Electronics Projects, ESP32 Projects, Arduino Projects, CAmera Projects, FTP Upload, Image Upload, Internet Conectivity, ESP32-Cam TutorialArduino Tutorial, WiFi Camera, Surveillance Camera, ESP32 FTP, Home Security, Image Transfer, Wireless Camera, Remote Monitoring, IoT Camera, ESP32 Camera Module, Arduino Camera Module, Home DIY, misperry
Id: 3X2iVJYSDJs
Channel Id: undefined
Length: 17min 17sec (1037 seconds)
Published: Tue Jul 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.