ESP32-Cam Complete Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this new DIY Engineers video in this video I'll be covering the esp32 cam I'll be covering Basics how to program an Arduino IDE how to wire it for programming and general use and we'll go over several examples including sending data from the esp32 cam for accessing pictures and video via web browser taking a picture when triggered by a sensor and saving that picture into the SD card and will even do an awesome computer vision example in which we'll process live video from the esp32 cam and use it to analyze objects in this example shown here detect the book and a sports ball for example so let's go ahead and get started so this is the esp32 cam this is a small camera module that runs on the esp32s chip and uses the OV 2640 camera this guy right here the esp32 cam can also be used with the OB 767 camera but the oov 2640 is better it has a high resolution and built-in jpeg encode which removes the processing task for the esp32 the esp32 cam comes with the esp32 so it is Wi-Fi capable is Bluetooth capable with 4.2 Bluetooth low energy it has a built-in LED flash it has nine i o Port supports UA RT SPI i2c and pwm it has a built-in SD card reader this guy right here and allows for input power between either 3.3 or 5 volts it's actually reported that power with 5 volts is more stable than 3.3 now you said here's the camera this guy it's a 2 megapixel camera again the ov2640 has an array size that can go up to uxga so 1600 by 1200 it's a lens size of quarter of an inch or 6.35 millimeters and it has a maximum transfer rate of 15 frames per second so at a variable affordable price it's a really really good overall system with a built-in camera so now let's talk about the pins now here are the esp32 cam pins so first we have the power in you can put 5 volts or 3.3 volts but 5 volts is recommended we have ground we have VCC which outputs 3.3 volts you know I O pin 16 which can be used without issues for all general purpose IO then you have i o pins number one and number three which are used as the uart interface now since the ESP cam 32 doesn't have any USB support they are used to push the code into it these cannot be used for anything else other IO pins are also used for other purposes as well as general i o but this includes micro SD card and Wi-Fi driver so it is likely you'll have issues using them for other stuff especially during boot so be careful when using the other ones another thing to consider is that whenever you're pushing a new program via Arduino into your esp32 cam you must connect IO 0 with ground I'll show this in future diagrams but it's just something that you have to keep in mind now let's look at the components on our esp32 cam on front we have a micro SD card socket where you can insert a Micro SD card and use it for example to save the pictures taken from your esp32 cam right into the SD card I will actually be looking at an example of this you also have the camera connector and we have the LED flash on the back we have a built-in antenna you also have an external antenna connector and we have the reset button we'll be using the reset button for some of our examples today now as you may have noticed the esp32 cam does not have a built-in USB port which obviously helps to keep the size small but as a result you have to use an ftdi programmer to program our esp32 cam all you have to do is wire your esp22 cam as shown in this image with your ftdi device and connect it to your computer via USB to push the code now as I said before you have to connect io0 with ground within your esp32 cam to allow it to program this is basically means I O pin number zero has to be low during flashing also make sure to set the ftdi jumper to the correct setting basically let's set it to 5 volts now once you complete the programming and are ready to test your program within your esp32 cam all you have to do is disconnect this and repower now before we proceed let me show you how to set up the camera on your esp32 cam because it's very likely that when you received it it was not set up already or not connected all you need to do is lift that tab that I just lifted and carefully insert the connector of the camera into the slot you can see I'm trying to be careful and then we bring it down and snap it once you do that you'll be all set do a little talk not too hard to make sure that it's in place and we're good to go now we also want to make sure that we hold that camera down so that it's laying flat and want to make sure we remove this little piece of paper so that we can see clearly now in order to use the esp32 cam with Arduino it will require that we add the appropriate Json file within Arduino ad so this is done in Arduino IDE by going to file preferences and then within the settings tab which I already have open you will go towards the bottom and you'll see this section that says additional boards managers URLs let me expand this and you can see that now I have have the two after I already added this is the original one I had and we had to have now a second one for using with the esp32 cam so you need to add this one and if you go to my website on diyengineers.com I have the link in the description you can easily go there and copy the link to the Json file which I'll show briefly so you can see but here's my blog post if you scroll down enough you'll see the section says Json file just copy and paste this link into Arduino ID so once you have pasted it make sure to click OK and put it in a separate line and then click OK as well again now you also need to add esp32 board to your Arduino IDE so once the correct Json file has been added you need to select the appropriate board so we go to board manager so we go to tools go to boards and then we'll go to board manager and then you search for esp32 and I already have installed but you would select this one and click install once it's installed you'll want to go to tools board esp32 Arduino and then you want to scroll down you have to be patient to find the one called a I think or esp32 Cam right here if you have trouble finding it is between this frog board and this ttgot watch so like that now let's go ahead and start our first example as talked before before we send any programs into our esp32 cam we need to make sure to set up our wiring and connections properly with an ftdi programmer so let's do that right now now as you can see you need to set up your ftdi with your esp32cam as shown in the image here I'll give you some time to take a look at it and pause the video if needed all right so set it up like this and then let's go back to Arduino IDE so once you set it up as we talked all you need to do is go to file examples esp32 camera web server in this example we need now as you can see in this first section you have to select your camera model let's go ahead and comment these and uncomment these let's say Define camera model AI thinker okay so you can also see if you keep scrolling down there's a section that says enter your Wi-Fi credentials what you need to do is here put the name of the your Wi-Fi network that you're going to use so you're the one that your computer is currently connected to the one for your home and then enter here the password for that Wi-Fi so now we go ahead and click the upload button note that before hitting the upload button I went ahead and entered my Wi-Fi info as well as the password so now that the code is uploaded remember that before you do anything else you need to unplug or disconnect this pin io0 would ground then reset your esp32 cam and proceed from there so once you have disconnected like we talked let's open this URL monitor and reset your esp32 cam and you will see a message then we'll say Wi-Fi connected and you will see the IP address to use to connect copy that IP address and then paste it on your web browser and we'll go from there so I went to my web browser and I copied and pasted the IP address hit enter and this opens so you have multiple settings here to pick your resolution um quality brightness contract saturation Etc if you hit this button you can start getting live video from your esp32 cam so I'm going to do that and you can see what I'm getting now one thing you'll notice is I'm getting this like horizontal lines that kind of like pop up and make the video not look as great that is happening because I'm powering my esp32 cam directly from the ftdi if I use some other more stable power source all that goes away go ahead and give it a try as you can see here we have the output video I could go ahead and change this to something else either less resolution or more resolution so you have multiple options to test for what works best for you all right this completes example number one now let's go ahead and move into example number two in this example we'll be taking a picture with a esp32 cam and saving it to a Micro SD card as you saw earlier in the embedded SD card note that the esp32 cam is ready to work with SD cards up to four gigabytes in capacity this has been reported actually to be able to be used with up to 16 gigabytes but four gigabytes is the spec now the program will have the esp32cam rest in sleep mode then we will wake it up via the reset button that I showed you earlier on the back then a picture will be taken and this picture will be saved on our micro SD card now step one in this example is to take our micro SD card and format it to FAT32 to do so connect the SD card to your computer then go to this PC or my PC right click on the specific SD card and click on format and make sure you have FAT32 picked make sure quick format is selected and click Start and once it's complete click ok close and you're done once you have done that go to diyengineers.com specifically follow the link in the description to this video and scroll through the example where I have take this picture and save on SD card scroll down and you'll see an Arduino code make sure to copy and paste that into our do a new IDE and we'll go from there now as a reminder I'll shoot the images here this is the setup for programming and this is the setup for normal operation so once you have copied and pasted the code into Arduino IDE and have your esp32 cam wired with ground and io0 connected go ahead and click the upload button all right so then remember unplug your esp32 cam unplug io0 from ground and then now anytime you restart it it's going to take a picture all right so as soon as I turn on our module it will turn on the flash and then anytime after that I wish I push this push button reset button and the back of our esp32 cam it will go ahead and turn the flash again so let's first turn it on you can see the Flash and I'll push this push button right here in the back you'll see let's do it again as you can see anytime we reset the esp32 cam module it resets and it goes through the sequence that we showed in Arduino IDE it flashes takes the picture sends it on the SD card all right let's go look at another example now in this new example it will be basically the same as when we just completed except now the picture will be taken whenever a PIR sensor detects motion if you want to learn more about PR sensors check my previous video so basically you can substitute this sequence that I'm showing here the second step with any other sensor that basically when it provides a high signal the picture will be taken it could be even an external switch and actually before we go into the PIR I'll show you how to do it with a push button so from here we'll use a par sensor so now we need to figure out how to wire system so before we jump into it there's something critical to take into account and that is that the esp32 cam already uses a bunch of i o pins for the camera and for the SD card so things get tough when we have to choose to add another i o into the mix additionally from the previous code remember that we're basically taking a picture and sending the esp32 cam into a deep sleep so we then have to wake it up to take another picture and then back to sleep supposedly we're using the reset button to wake it up but now we're going to use an external signal so what pin can we use when the esp32 cameras in deep Sleep only the low power portion of the system is running which is great for power saving but as a result we can only use pins 2 4 12 13 and 14 as well as 15. additionally I mentioned that the camera and the SD card are using mini Pins so which airplane we select needs to be free when we're not trying to reset the esp32 cam to do this we will add a 2 N 22 22 transistor which you can learn more about in another previous video as well and the goal is to Simply link our IOP into ground when we want to reset the esp32 cam and then isolate it from all the other pins at that when we're not using it basically for this I picked IO pin 13. this is after trying the other ones with no luck now as I try to test multiple pins I tested the system using a push button and then I move into a par sensor so let me show you now how to wire it for the push button now as we looked at the wiring diagram for our example we can see that ground on our esp32 cam goes to the camera ground which also connects to the collector on our 2N 2222 npn bat transistor the base connects to a 4 kilo Ohm resistor which connects to our push button which then goes to or 5 volt those 5 volts also go to the 5 volts input of our esp32 Cam and that esp32cam digital input connects to our 10 kilo Ohm resistor which connects to the emitter now let's go ahead and set up our example so let me quickly set it up I'll speed up this so you can see but it's not that many steps and we can quickly get our example going so I'll now turn it on as soon as I turn it on it says it's treated as a restart so you'll see the Flash and then as soon as I hit the push button it will go through the same cycle flash take the picture save it in the SD card do it one more time all right so let's Power It Off and now that we've tested this let's try it with the par sensor so now this is basically the same circuit we just looked at with the minor difference that now instead of a push button here sending the signal we're sending the signal via the PIR output which by the way will connect to ground and also to the 5 volts and again you can check out my video in par if you need to learn more so now let's go ahead and change the circuit from push button to PIR sensor now we can go and test that and again as soon as I turn it on see the Flash [Music] okay and now instead of the push button if the pr sensors detects the motion it will apply it up so there I guess that was too close to that side try it again and again one more time just for fun all right so as you can see we're able to test the camera to Auto take a picture and save it on the SD card by using either a push button or in this case a PR sensor but really you could use any sensor that you want to trigger the camera to take the picture and Save that could be like a limit switch or any proximity sensor like for a security system etc etc all right let's move on so now we'll jump into the fourth example which is doing Vision processing with opencv so if you go to the blog post that I've referenced several times go ahead and scroll to the section for this example and click on this link to get to the right page to download Anaconda which we'll be using in this example once you get there go ahead and download The Right installer for me I'm using Windows so I'm going to download the one for Windows it'll take some time so let's go ahead and wait until it downloads alright so now download it and we can continue so now let's go ahead and open the installer and go through the steps to get installed here just me pick the folder click your settings I left the default click install this could take a little bit then just wait until it's complete and then we're done then after that we'll just go ahead and open Anaconda so now once you have opened Anaconda go ahead and type the following will be panda face create space hyphen name virtual end python equals 3.11 and then hit enter I'm not going to do it because I already have it installed but I'll show you an image of what it looks like so then once you enter that you'll get a message saying hey the follow new packages will be installed and you'll get a full list kind of like what's shown here uh and then at the bottom we'll say proceed yes or no answer is yes you want to proceed so you enter a y hit enter and a bunch of stuff will begin installing then once everything is installed you'll get a message saying hey to activate this virtual environment you want to use the command conda activate virtual m just shown here and then to deactivate or get out of that environment you want to type con dot deactivate and hit enter also as shown here so now go ahead and get back into your virtual environment by typing conda activate virtualim and run the command pip install opencv hyphen contrib hyphen python that will go ahead and install a bunch of stuff now once that's done go ahead and run pip install requests so we'll go ahead and download another set of things once that's done run pip install zv lip again pip install CV lib and once that's done go ahead and run pip install tensorflow and after that pip install mat plot lib once all of that is completed we can go back to diydeniors.com again the blog post I provided the link to and look for the following python code so once you get to this example now scroll down to the section shown python code for example and download this python code and place it in a simple folder for me I have it on my downloads folder it says the short path but you can place it on your desktop or anywhere else after you do that we can test examples so I've shown that the blog post is pretty simple basically you want to complete all the steps listed under example one which was the one of sending the video to your computer except we will not open it via web browser then within Anaconda we're going to activate the virtual environment and then we're going to go ahead and run the python code so for me I had it on my downloads folder so I'm going to run it as download slash test dot python or pi so just save this within a text file on a specific folder and ran go ahead and run it so now I'm going to show you how that looks like so now we're back to Anaconda and step one is open in the virtual environment then go ahead and run python command needed to execute my code if you can see I actually rename them to test R3 and we immediately get video output now the speed in which you get your data will depend on how quickly your computer can process and run the whole algorithm for the computer vision as well as the speed of your Wi-Fi connection which might be impacted by how far you are from the router and interferences Etc but for the most part I mean you can see it provides a very good result we have a ball and a book and it identifies this as a sports ball and a book it's not perfect I think earlier I tried like lemon or an orange and the lighting wasn't great so I still thought it was a sports baller sorry sports ball but it's still still very good so I hope you enjoy this example um you know it can you can shows you how you can go from using a simple camera taking a few pictures saving an SD card and you can even use it all the way with you know computer vision so hope you liked it this concludes the video I hope you really enjoyed it if you liked it please give us a thumbs up and consider subscribing thank you very much and see you in the next one bye
Info
Channel: DIY Engineers
Views: 4,850
Rating: undefined out of 5
Keywords: ESP32-Cam, esp32-cam arduino, esp32-cam projects, esp32-cam object detection, esp32-cam setup, esp32-cam security camera, ESP32 Cam, ESP32 Cam project, ESP32 Cam object detection, ESP32 Cam programming, ESP32-Cam SD Card, ESP32 Cam SD Card, ESP32-Cam with PIR, ESP32-Cam OpenCV, Computer Vision, ESP32-Cam Computer Vision, ESP32-Cam Vision, ESP32-Cam Tutorial, ESP32-Cam How to, ESP32-Cam Guide, ESP32-Cam Complete Guide, ESP32 Cam Guide, ESP32-Cam Get Started, program esp32
Id: hSr557hppwY
Channel Id: undefined
Length: 26min 30sec (1590 seconds)
Published: Mon May 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.