Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-CAM Controlled Solenoid Lock with Relay and Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP32-CAM Controlled Solenoid Lock with Relay and Wi-Fi Connectivity

Circuit Documentation

Summary

The circuit in question is designed to control a 12V Solenoid Lock using an ESP32-CAM microcontroller, which is capable of image processing and Wi-Fi communication. The ESP32-CAM is interfaced with a ProtoSnap - Pro Mini - FTDI for programming purposes and a 1-Channel Relay to drive the solenoid lock. The system is powered by a 12V battery, which provides power to both the solenoid lock and the relay, while the ESP32-CAM and ProtoSnap are powered by a regulated 5V derived from the relay module.

Component List

12V Solenoid Lock

ESP32 - CAM

ProtoSnap - Pro Mini - FTDI

1-Channel Relay (5V 10A)

12V Battery

Wiring Details

12V Solenoid Lock

ESP32 - CAM

ProtoSnap - Pro Mini - FTDI

1-Channel Relay (5V 10A)

12V Battery

Documented Code

ESP32 - CAM Code (sketch.ino)

#include "esp_camera.h"
#include <WiFi.h>

// Select camera model
#define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"

const char* ssid = "Galaxy-M20";
const char* password = "ac312124";

#define LED_BUILTIN 4
#define relay 4 
#define buzzer 2

boolean matchFace = false;
boolean activeRelay = false;
long prevMillis = 0;
int interval = 5000;

void startCameraServer();

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println();

  pinMode(relay, OUTPUT); 
  pinMode(buzzer, OUTPUT); 
  pinMode (LED_BUILTIN, OUTPUT);

  digitalWrite(LED_BUILTIN, LOW);
  digitalWrite(relay, LOW);
  digitalWrite(buzzer, LOW);

  // Camera configuration
  camera_config_t config;
  // ... (configuration code omitted for brevity)
  
  // Camera initialization
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }
  
  // Sensor settings
  sensor_t * s = esp_camera_sensor_get();
  // ... (sensor configuration code omitted for brevity)
  
  // Wi-Fi connection
  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");
}

void loop() {
  if (matchFace == true && activeRelay == false){
    activeRelay = true;
    digitalWrite (relay, HIGH);
    digitalWrite (buzzer, HIGH);
    delay(800);
    digitalWrite (buzzer, LOW);
    prevMillis = millis();
  }
  if(activeRelay == true && millis()- prevMillis > interval){
    activeRelay = false;
    matchFace = false; 
    digitalWrite(relay, LOW);
  }               
}

Note: The code provided is a partial representation of the actual code used in the ESP32-CAM. It includes the setup for the camera, Wi-Fi connection, and the main loop that controls the relay and buzzer based on facial recognition (matchFace variable). The actual facial recognition implementation and the startCameraServer function are not included in the provided code snippet.