Pan Tilt Control using Servos for ESP32 Cam | WiFi Security Camera

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] hey guys welcome back to hash include electronics with another video and in this video we are going to add pan and tilt control for esp32 camera using servo motors using this assembly we can rotate the camera horizontally and vertically from 0 degrees to 180 degrees this can easily be used as surveillance camera in our home we will capture images using esp32 camera module and send these images to our mobile phone using websocket through wifi connection we will control camera rotation using our own mobile app so let's get started and make it if you haven't subscribed yet please hit subscribe button below and press bell icon to get latest updates for making this pan tilt control we will need esp32 cam module pan tilt servo assembly [Music] sg90 servo motors we will need two servos [Music] 5v ac dc adapter for power supply arduino uno for uploading code breadboard and few jumper wires let's assemble the pan tilt bracket and fix servos [Music] this will be the pan servo [Music] so [Music] [Music] [Music] [Applause] [Music] this will be the tilt servo [Music] we need to make sure that this servo's initial position is in the middle [Music] now let's make a connection as per circuit diagram connect pan servo to io14 pin of esp32 cam model [Music] connect tilt servo to io15 pin [Music] now provide plus 5 and ground to esp32 cam module from ac dc adapter also provide plus 5 and ground to servos [Music] fix esp32 camera module on bracket now [Music] [Applause] [Music] let's take a quick look at the code first we need to install esp32 board using arduino board manager i have provided the esp32 board link in the description below go to file then go to preferences and add the esp32 board link then go to tools and then board manager and search for esp32 and install it after that we need to install the async tcp and async web server library download these libraries from the links provided in the description below once downloaded go to sketch include library and then click on add zip file select the downloaded zip library file and click add similarly add async web server library as well now we need to set one parameter which is very important step so that video runs smoothly go inside your sketch folder then libraries folder search for esp async web server folder and then go inside src folder open async websocket.h file and change ws max skewed messages to one for our esp32 board and save it now we need to install esp32 servo library as well for controlling servo motors go to tools and then manage library search for esp32 servo and install it now we need to include the esp camera async tcp library and async web server library also we need to include esp32 server library we have defined two dummy servo pins this is needed so that our servo library does not interfere with pwm channel and also timer used by camera after that define pan and tilt servo pins as io 14 and io15 we have created object for two dummy servos and pan tilt servos after that we have defined some constants for camera settings we need to set the ssid and password for our esp32 wifi we have created web server at port number 80. we will be using websocket for camera and servo input control we have defined pin for led flashlight as io4 then we have created html page for our camera control app and stored it in html homepage variable this is main page which will be displayed on mobile it has the image section to display the video and also has slider to control pan and tilt the mean and max value for pan tilt slider is 0 and 180 respectively when pan or tilt slider is selected on mobile it will send current slider name and also value to esp32 module using websocket we have created websocket to display the images sent from camera we have handle root function which will send html page when we type ip address on mobile browser we have onservo input websocket event callback function which will be called when esp32 receives any value from mobile if received key is panned then we will rotate pan servo as per slider value received if received key is tilt then we will rotate tilt servo as per slider value received if received key is light then we will control the light we have on camera websocket even call back function which will be called when we get request for video stream once connected we will set the client id we have created setup camera function to init the camera then we have created send camera picture function which will capture the image and send it to camera websocket client we have created setup pin mode function to setup the servers it will attach servo pins to servo objects also we need to setup pwm for controlling led flashlight inside setup function we will call setup pin mode function then begin wifi using soft ap mode setup callback function on root and on not phone then attach the websocket handler to web server now begin the wi-fi server also set up the camera inside loop function we just need to call cleanup client function to clean up old client connections we will also capture and send the camera images i have provided the link to the code in the description below you can upload it directly in our case we will use arduino uno for uploading the code into esp32 cam module check my previous video on esp32 cam car for detailed explanation on how to upload code using arduino uno power on adapter now let's open mobile app now go to wifi settings and connect to now icu ssid using password as one two three four five six seven eight open google chrome browser on mobile and type 192.168.4.1 it will open our camera pan tilt control app sometimes we might have to reconnect the wi-fi if the app does not open that's it let's see how it works [Music] [Music] [Music] [Music] [Music] so [Music] so [Music] so [Music] there are few points which we need to remember while making this esp32 cam car first we need to set the ws max skewed messages to one otherwise the video will be very slow second if video is not displayed on the app then reconnect the wi-fi on the mobile and try again do not connect io 16 pin of esp32 cam it is used internally by ps ram if uploading of code fails then try after reconnecting usb cable to laptop make sure to provide proper 5v dc supply only hope you guys enjoyed the video and thanks for watching stay safe and please like share comment and don't forget to subscribe to my channel [Music]
Info
Channel: hash include electronics
Views: 3,047
Rating: undefined out of 5
Keywords: esp32cam, pantilt, hashincludeelectonics, esp32securitycam, pantiltservo, arduino, arduinoprojects, esp32
Id: Rm_R0MAmHHA
Channel Id: undefined
Length: 12min 9sec (729 seconds)
Published: Sun Oct 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.