ESP32 CAM - 10 Dollar Camera for IoT Projects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we're working with the esp32 cam i'll show you how to program and use this amazing module and i'll give you hints for resolving any problems you might encounter using it we're taking pretty pictures today so welcome to the workshop [Music] well hello and welcome to the workshop i hope you're doing well and staying safe and are ready to work again with the esp32 because that's what we're going to be doing today today we're going to be working with a very specialized version of the esp32 a small module called the esp32 cam now as its name implies the esp32 cam is an esp-32 module that also has a small camera on it and you can use this for projects that require streaming video for taking images for security projects and all sorts of interesting projects and iot devices now the other interesting thing about this device is its cost the esp32 cam module is available for 10 us dollars or less and when you consider that that even includes the camera it's an amazing bargain now this esp32 tip is a little bit different than the one we worked with before the module we had before had a lot of pins had most of the gpio outputs brought out to it and had a usb connector on it the esp32 cam does not have all the gpio pins brought out several of them are being used internally for the camera and for the micro sd card which is also on this device and it also does not have a usb port on it so we need to use an external ftdi adapter to work with this and i will be showing you how to do that in a few moments now we're going to be working with the arduino ide again and the ide needs to be modified with the board manager additions that i showed you in the last video so if you haven't done that to your arduino ide you're going to want to go back to the first esp-32 video i did and learn how to modify your ide to include all the esp32 boards and once you do that you'll have the sample code that we can use to work with the esp32 cam now another thing i'm going to do today after loading this showing you how to program it and running the sample code is i'm going to show you how to get around a few of the problems and issues that you might have with this device and indeed with other esp32 devices on the dronebot workshop forum i noticed that we've had a number of entries with people who've had problems getting the esp32 cam to work and i ran into a few snags myself and i've resolved them so i want to show you how to do that as well so if you've been trying to get this device to work and just haven't been able to do it well this is the video for you so we will start off as always by learning about the module we're working with we'll see how it is wired up how we can program it and we'll start working with our esp32 cam so let's take a quick look at the esp32 cam module the esp32 cam is a low-cost 32-bit microcontroller from expressive it has a built-in camera and micro sd card interface the pin outs are a subset of the full esp32 module the module includes a white led to use as a flash it has provisions for an external antenna the esp32 cam can operate on either 3.3 or 5 volts the module is based on an esp32s module it also comes with an ov2640 2 megapixel video camera so let's take a look at the pin outs on the esp32 cam you'll note that there are far fewer pinouts than a standard esp-32 module as many of the connections are used internally it has both a 5 volt dc and a 3.3 volt dc input you need to use one or the other but not both the vcc out will reflect that voltage gpio 3 and gpio1 are also used as receive and transmit for the module you'll want to note that the esp32 cam module has no usb port the initial programming of the module is done with an external ftdi module the microsd card is rated at a four gigabyte maximum you can use larger microsd cards but you'll only be able to store four gigabytes of data also note that the components are on both sides of the module so this is not as easy to breadboard as some modules so now let's take a look at the esp32 cam and so here's the esp32 cam module as you can see it's quite a compact module and the dominant feature of course is the camera over here now this camera is plugged into a small csi connector similar to the connector used on the raspberry pi zero now my module came with the camera already plugged in but many of them come with the camera as a separate item and you'll just need to snap it into this connector below the connector you can see a white square and that's a square led it's a white led that can be used as a flash for the camera and underneath the camera you will see a micro sd or tf card socket for placing a micro sd card now if we flip this over there's a lot of things on the bottom of this module because of that this is a module that isn't ideal for the breadboard instead you're going to want to be using female to female jumper wires to work with it so you can get it both sides of the board the dominant thing here of course is the esp32 module itself and up over here we have a small connector and that is for an external antenna and i'll be talking about the external antenna a little bit further on in this video now it's probably pretty hard for you to see but down over here there is a very tiny push button switch and that's the reset switch and that's another reason why this is a difficult module to use on a solderless breadboard and that you're best using it out in the open but other than that it's a very easy module to work with a very inexpensive module so now let's go and work with it so now that we've looked at the esp32 cam it's time to start programming it now as i mentioned already the esp32 cam does not have an integrated micro usb or mini usb port so you are going to need an external ftdi adapter in order to program this device your ftdi adapter will also require a strap that allows you to change the output voltage to 3.3 volts as opposed to 5 volts and on most of these it's either a strap a switch or perhaps a solder pad and these are the same ftdi adapters that we have already used for using with the arduino pro mini so if you've done that already then you already have your ftdi adapter there are also two pins on the esp32 cam that are going to be needed to be tied together the gpio0 and the ground pin and they need to be connected while you are programming and then that connection can be removed and so let's go and take a look at the hookup for that right now and then i'll show you how to program your esp32 cam to work with the esp32 cam you will obviously need an esp32 cam module you'll also need an ftdi interface and you'll need to set the jumper on your interface for a 3.3 volt output instead of a 5 volt output we'll begin by connecting the 3.3 volt pin on the esp-32 to the vcc output on the ftdi interface gpio pin 3 which is also labeled u0r is connected to the tx or transmit line on the ftdi adapter gpio pin 1 also labeled as u0t will be connected to the rx or receive line on the ftdi interface and finally the ground on the esp32 cam will be connected to the ground on the ftdi interface during programming you'll also need to connect the jumper from gpio0 to ground this jumper will be removed after you program the device now to test out the operation of our camera i'm going to be using a very sophisticated sketch that came as an example with the esp32 board manager and this sketch will build a complete web server with the camera and a number of controls that you can use through the camera so it is extremely sophisticated before we get started we need to go into our board manager and select the correct board so go up into tools and then go into board now what i'm looking for and i've already selected it is the ai thinker esp32 cam and it's going to be down with your esp32 boards over here unfortunately these are not in alphabetical order and there are a lot of esp32 boards so you're just going to have to look for it but once you've selected that you've got the correct board selected for working with your esp32 cam now the example sketch you're going to be using is already included in the example so go into examples and go down to examples for ai thinker into that section and go into the esp32 section go into camera and select camera web server and that's the example we're going to be using now i am not going to go through this sketch line by line we would be here all day there is a lot to this sketch while it may not look like a huge file over here you have to realize there are actually four files that come with this sketch and are included with it so it is very sophisticated and considering what the sketch accomplishes that's not surprising however you are going to need to modify this before you can get it to work now the first thing you're going to need to do is select the camera model now by default it uses this particular one that is not the one that i used for the esp32 cam and probably won't be the one that you used you're going to have to select this one so you're going to have to remove these two dashes over here and you're also going to need of course to place two dashes over here the next thing you are going to need to do is to enter in the credentials for your network so you're going to need to enter the ssid which is your network name and you're going to need to enter your password now remember this is only going to work with 2.4 gigahertz wi-fi networks and so you can't use this with a 5 gigahertz wi-fi network once you've done that you can compile the sketch and load it to the esp32 similar to the way you do with the arduino unlike the previous esp32 models you do not need to hold down a reset key but remember that jumper that goes between gpio0 and the ground you're going to need to do that also be prepared this may take a little while to compile a lot longer than you're used to and this is normal so let's take a quick look at my setup with the ftdi module in the esp32 i will upload this sketch and then we'll test it out now here's the setup i have with the esp32 cam and as you can see i've got my ftdi module over here it's powered up as you can see the indicator and i have it strapped over here for 3.3 volts it's important to get that correct or else you could destroy your esp32 cam now the connections are all made with female to female jumper wires it's a lot easier than using a solderless breadboard although you could use the solderless breadboard you just won't have access to the reset switch which you're going to need a little later on you don't need it during the programming process however now this jumper over here is another female to female connection that is going from gpio0 to ground and they're conveniently located next to each other my gray wire over here being my 3.3 volt wire and then i have my transmit and receive wires here in the ground at the end so very simple connections to the device again made without the benefit of the solderless breadboard and so when you're uploading programs this is how you're going to want to set things up when you finish uploading you can disconnect your usb cable and remove this jumper cable because you don't want it there during normal operation it's just there for programming purposes okay so i have loaded the program up to my esp32 cam you can see at the bottom of the screen where it says hard resetting by rts pin that indicates that the upload has been finished now i've disconnected and reconnected the camera this time without the jumper between gpio0 and the ground and i'm going to hit the reset button on the camera right now and it resets and here i have wi-fi connected and it says i've started the web server and it's given me an ip address so i'm going to need to go to a web browser next which i've already done here i'll just refresh that and i'm going to do start stream and here i have an upside down image of the workshop and i can move there's my cabinets and that tilt it around and oh there's a couple of microphones and there's my stomach so it actually is working i have a number of different things i can adjust over here i can adjust the resolution i can adjust brightness contrast saturation there are a great deal of controls over here i can stop the stream by hitting the button or by clicking it over here i can get a still picture i can even do face recognition by turning these buttons on doing enroll face so as you can see it's a very complicated interface for the esp32 cam now let's go back into the arduino ide for a moment and as you can see the serial monitor is displaying some statistics from the camera the number of frames per second for example are being displayed the latency is being displayed so a very sophisticated program that you can upload to your esp32 cam and get it working pretty well right away so as you've seen getting the esp32 cam up and running using the demo sketch is fairly simple however you can run into a couple of problems working with this and some of these problems incidentally are not just inherent to the esp32 cam but to all esp32s the problems arise because of the amount of current that the esp32 requires although it can run at very very low currents it also can consume bursts of currents when using operations like wi-fi and bluetooth and of course our camera was using wi-fi wifi now the problem you'll notice is that you'll get a brown out condition in fact if you looked at my very first video on the esp32 you may have noticed that on my serial monitor i did indeed run into this problem and i've managed to resolve the problem now the problem arises because of the current that you're consuming from your computer when you're driving the ftdi card and then powering the esp32 cam sometimes it can't deliver enough current a lot of the reason for that is the usb cables now in my case my computer is actually below my workbench and there's a relatively long usb cable that runs up to a jack at the back of the workbench in turn i plug another usb cable into that so by the time that it has reached the esp32 cam the signal is traveled over quite a few meters of cable and usb cables tend to be relatively low gauge so i've come up with a couple of solutions for this problem and i want to show them to you right now so let's move over to the workbench and i'll show you a couple of ways that you can resolve the brown oak condition that you might get when working with the esp32 cam or indeed with any esp32 now the way that i resolved the issue with the usb cable not having enough current in order to drive the esp32 module correctly is to use a powered usb hub and this is one that i've had for several years it simply has an input over here and four outputs on this side but the key thing is that this is a powered hub it has its own transformer and the transformer supplies 5 volt power to this hub and in turn the 5 volt power to your device is being supplied by the transformer and not by your computer and this was sufficient in order to resolve that brown out condition that i ran into with my esp32 both with the esp32 cam and with the esp32 module in general now this model of powered usb hub is probably not even available anymore as i said i've had this for years but you can get many different powered usb hubs and they're quite inexpensive and you don't need to get a usb 3 one this is a usb 2 device and it works quite satisfactorily so i would suggest adding one of these into your circuit if you're having problems with brown out conditions while you're programming the esp-32 and hopefully it should resolve your issues now another solution for resolving esp32 cam power problems is to use the 5 volt power supply as opposed to the 3.3 volt supply and as you'll recall from the pin out the 5 volt supply has an input pin over here as opposed to the 3.3 which is over here in actual fact the module does run on 3.3 volts but there's an internal regulator that will reduce the voltage to 3.3 and i've found that that tends to work a bit better than trying to supply 3.3 volts yourself now what i've done over here as you can see is i've mounted my esp32 cam i've already programmed it and it's mounted onto a solderless breadboard and i've also used one of these breadboard power supplies these are really common devices i've showed them to you before and they're capable of supplying both 5 or 3.3 volts as they have two linear voltage regulators on them they also provide a handy power switch for you and in this case i'm powering it with a 9 volt battery to make this cam a little bit portable so i can kind of move it around and get pictures from different areas of my workshop and my basement now of course by blocking off the bottom of it it does create a few problems if you're trying to use an external antenna you may be able to get the antenna wire under here to the antenna connector one other thing of course is the reset switch and that's just at the front over here so you can actually get at that with a toothpick or another insulated object i wouldn't use a screwdriver because it isn't insulated if you need to use the reset button or of course you could just power it off and power it on but if you're having problems with the power on your esp32 you may want to try using the 5 volt supply instead of the 3.3 now another problem that you can run into using the esp32 cam has to do with the wi-fi signal strength and this can also affect the bluetooth and the reason for both is the same the 2.4 gigahertz signal that is used for the wi-fi and bluetooth is transmitted through a small antenna that is etched onto the printed circuit board of the esp32 cam module now this antenna can perform satisfactorily as long as you have a very strong wi-fi signal but if you're in an area where the signal is weaker the antenna gives rather mediocre performance in fact in my case on the workbench i'm not that far from my router it's just a couple of doors down on the other end of the basement but there are a couple of walls and a few appliances between me and the router and i think it tends to affect the signal strength so the best way to improve that is to add an external antenna something like this one over here which is an antenna made for 2.4 gigahertz wi-fi and bluetooth and these are very inexpensive antennas and you can get them on ebay amazon and of course at your local electronic shop now there is a connector already on the esp32 cam board for one of these antennas however the connector is not enabled and in order to enable it you're actually going to need to get your soldering iron out but don't worry it's not a very difficult task to perform so let me show you how you can modify the esp32 cam module to use an external antenna and then we'll test the performance of the esp32 cam both with and without an external antenna just to see what the difference is the esp32 cam module has an internal printed circuit board antenna for improved performance it can also use an external antenna this external antenna requires an ipex connector you'll need to modify your esb32 cam board to use the external antenna now here's the location of the antenna connector on the bottom of the esp32 cam board you'll note a couple of pads beside the antenna and there is a zero ohm surface mount resistor on these pads for the internal antenna the resistor will be in this position in order to use the external antenna you will need to unsolder the resistor and move it into this position as this is a zero ohm resistor you can also simply sort out these two leads if you wish note that you can't use both the internal and external antenna simultaneously once you've completed these modifications you'll be ready to hook an external antenna up to your esp32 cam module here's the sketch that we're going to be using to measure the wi-fi signal strength and compared to the last sketch this is an extremely simple sketch it basically just exploits a few properties of the wi-fi library now the wi-fi library is already built into your arduino ide and so you will not need to install any external libraries to use this library so we start off by including the wi-fi library and then we have the same lines that we saw at the beginning of the last sketch where we enter our ssid which is our network name and the password so of course you're going to need to edit these lines and include your own ssid and password over here then we go into the setup and in the setup we start our serial monitor and then we connect to the wi-fi and as you can see connecting to the wi-fi is extremely simple you just do a wi-fi dot begin and then pass it the ssid and the password now we look for the status of wl connected when that is true we are connected to the wi-fi so we check and see if wl connected is actually true while it is not true we delay for half a second and print a dash on the screen and then go back and do it again and the effect of that is going to be a series of dashes printed across our screen until we're actually connected to the wi-fi once we have connected we do a print line in order to go to a new line and to send it a blank character and then we write connected to network and the name of the network and then after that we delay for a short period and go down into the loop now the loop is very simple we just print out the network name again we print the word signal level and then we print the actual signal level which we define by getting this over here and this will print the level in dbm so this will be a negative number after that we delay for two seconds and just go ahead and do it again and so a very simple sketch but a useful one for measuring wi-fi signal strength let's try it with both the esp32 cam with its internal antenna and then we'll try it with an esp-32 cam that's been modified to use an external antenna so here's our sketch running with the esp32 cam and its internal wi-fi antenna and i've set it up to use one of my wi-fi networks called wjnet2 and as you can see my signal strength is fluctuating but it is in the neighborhood of negative 60 to negative 65 dbm and this again is with the internal antenna being used so now let's go and load this to another esp32 that i have modified to use an external antenna and we will see what that looks like as far as dbm level goes so here's our demonstration again and as you can see i've got an external antenna now connected to my esp32 cam and if you look at the levels i'm getting right now you can see that this has made quite an improvement i'm getting levels in the neighborhood of negative 48 negative 46 dbm quite a substantial difference from the levels i was getting using the internal antenna in fact it's a improvement of about 15 dbm which is really a great deal of difference as far as wi-fi signal quality goes and so as you can plainly see using an external antenna is a great way to improve the performance of your esp32 cam so that brings us to the end of our introduction to the esp32 cam however it is certainly not the last time we are going to be using the esp32 cam module here in the dronebot workshop it's a very versatile and inexpensive device and once you get around a few of the quirks with it it is very easy to use now if you want to stay informed about all those videos the best way to do that is to subscribe to the youtube channel so if you haven't done so already please hit the subscribe button and also hit that bell notification because that way you'll get informed every time i make a new video if you'd like some more information about the esp32 cam please check out the article that accompanies this video you'll find a link to that article right below the video and that's on the dronebotworkshop.com website when you're on the website another thing you can subscribe to is the newsletter it's my way of staying in touch with you and just letting you know what is going on here in the workshop and finally if you'd like to discuss the esp32 cam or anything else electronic with a number of great people who have similar interest to you well the best place to do that is the dronebot workshop forum at forum.dronebotworkshop.com and you'll find information about signing up for the forum below this video as well so until we meet the next time please take good care of yourself please stay safe and i will see you again very soon here in the dronebot workshop goodbye for now [Music] you
Info
Channel: DroneBot Workshop
Views: 683,721
Rating: undefined out of 5
Keywords:
Id: visj0KE5VtY
Channel Id: undefined
Length: 29min 39sec (1779 seconds)
Published: Sun May 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.