Smartcam Using ESP32Cam

Introduction: Smartcam Using ESP32Cam

Hello! Every one This article gives a base idea of using esp32cam as smart cam

Step 1: Getting Started

Great day guys! Welcome to Technofreak8085 Today lets work on a mini project of making esp32 cam as a smart cam so without any delay lets get started!!

Thing Needed:

1.Esp32cam module



4.Jumper wires

5.Ftdi programmer

6.Cable to connect ftdi and esp module with pc or laptop

Step 2: Getting Familiar With Esp32cam

What is Esp32 cam?

It is a low cost devlopment board with wificam and bluetooth support it helps us in creating ip camera projects like this !

Now lets take a look at Esp32cam pinouts

1.5v 9. 3.3V

10.GPIO 16

2.GND 11.GPIO 0

3.GPIO 12 12.GND

4.GPIO 13 13.3.3/5V

5.GPIO 15 14.GPIO 3

6.GPIO 14 15.GPIO1

7.GPIO 2 16.GND

8.GPIO 4

Here to put it simply 5v,3v and GND are POWER Pins and the other GPIO Are the input and the output pins

And FTDI Programmer is used to transfer info from pc to esp as it doesnt have any usb ports to it

I will make sure to drop the image of the ftdi and the connections with the esp module

The connections to be made as below :

ESP32-CAM FTDI Programmer


5V VCC (5V)




Step 3: Getting Familiar With Blynk

Download Blynk app and sign up with your email and then create a new project and there setup a switch and note the auth token and use it I am not going to show you These steps as it is easy and you can find it yourself if anyone is finding any difficulty i will help you out!!!

Step 4: Idea of the Project

The aim of this project is to make an ip server through which we can access the camera of the esp32cam module and to program it such a way that it recognises the faces of registerd users and we will have the option to unlock the door from our mobiles As i dont have a solonoid lock i will just show you by sending output signal to a pin in our esp module through which we could control solonoidal lock

Step 5: Starting to Code

Now lets code the esp 32 Module

Before coding just make sure that you have installed all the drivers related to it in your pc by cheching the COM port in ardunio ide here you should enter the auth token of blynk app after you complete its setup and your wifi credentials

A jist of the code :

Basically i am just creating a server for esp32cam by using the example provided in the arduino ide

Here we are defining our esp32cam module and declaring the input and the output ports and we program the basics such as adjusting the width and using the image provided by module and program to stream the video to an ip address

I will be uploading the code and in it if anyone has anny question on the working you can just comment down i will be replying as soon as possible

Step 6: Here Is the Code

NOTE: This code is just the main code there are different base codes which are to be uploaded at a time other codes are for camera pins , for server etc

#include "esp_camera.h"
#include #include #include

// WARNING!!! Make sure that you have either selected ESP32 Wrover Module, // or another board which has PSRAM enabled // // Select camera model //#define CAMERA_MODEL_WROVER_KIT //#define CAMERA_MODEL_ESP_EYE //#define CAMERA_MODEL_M5STACK_PSRAM //#define CAMERA_MODEL_M5STACK_WIDE #define CAMERA_MODEL_AI_THINKER #include "camera_pins.h" const char* ssid = "*********"; const char* password = "********"; char auth[] = "aVfUowZM4R_ThA_-vGkRTXQjWGjCFkvz"; String my_Local_IP; #define LED_BUILTIN 4 #define relay 4 #define buzzer 2 #define LED 13 #define BUTTON 15 boolean matchFace = false; boolean activeRelay = false; long prevMillis = 0; int interval = 5000; void startCameraServer(); void check();

void check() { digitalWrite(LED,HIGH); uint32_t number = random(40000000); Blynk.notify("Some one Has Arrived!!!"); Serial.println("https://"+my_Local_IP+"/check?_cb="+(String)number); Blynk.setProperty(V1,"urls","https://"+my_Local_IP+"/check?_cb="+(String)number); delay(1000); digitalWrite(LED,LOW);


void setup() { Serial.begin(115200); pinMode(LED,OUTPUT); pinMode(relay, OUTPUT); pinMode(buzzer, OUTPUT); pinMode (LED_BUILTIN, OUTPUT); Serial.setDebugOutput(true); Serial.println(); digitalWrite(LED_BUILTIN, LOW); digitalWrite(relay, LOW); digitalWrite(buzzer, LOW); camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; config.pixel_format = PIXFORMAT_JPEG; //init with high specs to pre-allocate larger buffers if(psramFound()){ config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = 10; config.fb_count = 2; } else { config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = 12; config.fb_count = 1; } #if defined(CAMERA_MODEL_ESP_EYE) pinMode(13, INPUT_PULLUP); pinMode(14, INPUT_PULLUP); #endif // camera init esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; } sensor_t * s = esp_camera_sensor_get(); //initial sensors are flipped vertically and colors are a bit saturated if (s->id.PID == OV3660_PID) { s->set_vflip(s, 1);//flip it back s->set_brightness(s, 1);//up the blightness just a bit s->set_saturation(s, -2);//lower the saturation } //drop down frame size for higher initial frame rate s->set_framesize(s, FRAMESIZE_QVGA); #if defined(CAMERA_MODEL_M5STACK_WIDE) s->set_vflip(s, 1); s->set_hmirror(s, 1); #endif WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); startCameraServer(); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Serial.println("' to connect"); Blynk.begin(auth, ssid, password); } void loop() {; if(digitalRead(BUTTON) == LOW) check(); if (matchFace == true && activeRelay == false){ activeRelay = true; digitalWrite (relay, HIGH); digitalWrite (buzzer, HIGH); Blynk.notify("Opening the door"); delay(800); digitalWrite (buzzer, LOW); prevMillis = millis();

} if(activeRelay == true && millis()- prevMillis > interval){ activeRelay = false; matchFace = false; digitalWrite(relay, LOW); } }

Step 7: Any Qustions Related to the Code Are Welcome

Please note that this is not the entire code this is just the first code in that example

now i am placing some images.. Hope you enjoyed the project.Thanks for reading

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge



    2 years ago on Step 6

    well done. just a tip: if you want your work to be used easily by others, you may format the code ;)


    2 years ago

    Nice. Thanks for sharing.