The circuit in question appears to be designed for a security or access control application, utilizing an ESP32-CAM module to potentially capture images or video. The ESP32-CAM is interfaced with a 5V relay that controls a 12V solenoid lock, allowing for electronic locking and unlocking mechanisms. The system is powered by a 12V battery, and the ESP32-CAM module is mounted on an ESP32-CAM MB FLIP for ease of use. The embedded code provided suggests that the ESP32-CAM is configured for WiFi connectivity and may perform facial recognition or similar image processing tasks to control the relay and, consequently, the solenoid lock.
#include "esp_camera.h"
#include <WiFi.h>
// WARNING!!! PSRAM enabled board is required for this camera module type
#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;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
// ... (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;
}
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
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 for the ESP32-CAM microcontroller and includes setup for the camera, WiFi connectivity, and control logic for a relay and buzzer based on facial recognition or other triggering conditions. The actual facial recognition logic is not included in the provided code snippet.