ESP32-CAM security camera watching a front door with AI detection boxes and a Home Assistant dashboard
ESP32-CAM β€’ Home Assistant β€’ Smart Security

Build an AI-Powered Security Camera with ESP32-CAM

This tutorial shows you how to turn a low-cost ESP32-CAM into a smart front-door security system with live video, motion detection, snapshots, phone alerts, and a Home Assistant dashboard.

What You Are Building

You are not building a toy camera. You are building a real smart-home security node: ESP32-CAM captures the video, Home Assistant organizes the dashboard and automations, and your phone receives alerts when motion or a known face is detected.

Live front-door cameraView your ESP32-CAM stream from your local network or Home Assistant dashboard.
Motion-triggered snapshotsUse motion detection to capture useful evidence instead of recording useless empty footage.
Face detection workflowUse ESP32-CAM face detection concepts or upgrade later with a stronger AI server.
Mobile notificationsSend a front-door alert with a snapshot so you know what happened fast.
Reality check: ESP32-CAM is powerful for the price, but it is not a $300 AI camera. Keep expectations sane: use it for learning, local monitoring, snapshots, and smart-home automation. For heavy AI recognition, let Home Assistant, Frigate, or another local server do the harder work.

Parts List

These are the core parts for the build. Some links below are Amazon affiliate links, which may help support WolfieWeb at no extra cost to you.

ESP32-CAM module

Main camera board with WiFi and OV2640 camera. This is the brain and camera for the project.

πŸ“· Buy ESP32-CAM
FTDI USB programmer

Used to flash firmware to the ESP32-CAM before the camera runs on its own power.

πŸ”Œ Buy USB Programmer
PIR motion sensor

Optional hardware trigger for motion-based snapshots and smarter alerts.

🚢 Buy Motion Sensor
5V power supply

Use a stable power source. Weak USB power causes random resets, brownouts, and camera dropouts.

πŸ”‹ Buy 5V Power Supply
Upgrade option: Want a finished consumer-style version of this idea? Compare AI doorbell cameras here: View AI doorbell cameras on Amazon.

Step 1: Mount the ESP32-CAM Near the Door

Place the camera where it can see faces clearly: about chest to head height, angled slightly downward, and close enough to the porch light to avoid muddy night footage.

ESP32-CAM mounted beside a front door at night
Front-door install concept: mount the board securely, protect it from rain, and keep the lens aimed at the walkway.
Important: Do not leave a bare ESP32-CAM exposed to weather. Use a small enclosure, seal cable entry points, and keep the board dry.

Step 2: Wire the ESP32-CAM

The ESP32-CAM has no built-in USB port, so you normally flash it with an FTDI adapter. During flashing, GPIO0 is connected to GND. After flashing, remove that GPIO0-to-GND jumper and reboot the board.

Detailed ESP32-CAM FTDI and PIR motion sensor wiring diagram
Wiring diagram for flashing, powering, and adding a PIR motion sensor trigger.
  1. Connect FTDI 5V to ESP32-CAM 5V and FTDI GND to ESP32-CAM GND.
  2. Connect FTDI TX to ESP32-CAM U0R and FTDI RX to ESP32-CAM U0T.
  3. For flashing only, connect GPIO0 to GND before pressing reset.
  4. Connect PIR VCC to 5V, PIR GND to GND, and PIR OUT to a safe input pin such as GPIO13.

Step 3: Flash the Camera Firmware

The simplest starting point is the ESP32 CameraWebServer example from the Arduino IDE. It gives you a working live stream first. Once the stream works, then you can add Home Assistant and automations.

  1. Install the Arduino IDE.
  2. Add ESP32 board support in Board Manager.
  3. Select an ESP32-CAM board profile such as AI Thinker ESP32-CAM.
  4. Open the CameraWebServer example.
  5. Enter your WiFi name and password.
  6. Upload while GPIO0 is connected to GND.
  7. Remove GPIO0 from GND, press reset, and open the serial monitor to find the camera IP address.
// Basic ESP32-CAM idea
// 1. Connect WiFi
// 2. Start camera server
// 3. Visit the board IP address in your browser
// 4. Add that stream to Home Assistant

Step 4: Connect the Camera to Home Assistant

Once the ESP32-CAM is streaming on your local network, Home Assistant becomes the control center. Your camera feeds the dashboard, automations watch for events, and your phone gets alerts.

ESP32-CAM WiFi router Home Assistant phone network flow diagram
Network flow: ESP32-CAM sends video through WiFi to the router, Home Assistant reads the stream, and your phone receives alerts.
Home Assistant dashboard showing front door camera security events
Home Assistant dashboard concept with live view, motion events, recent snapshots, and camera controls.

Step 5: Add Motion and Face Detection Logic

For a beginner-friendly build, start with motion detection. Then layer in face detection. The smart way is simple: motion wakes the workflow, face detection checks the frame, and Home Assistant sends the alert.

Motion face detection notification snapshot cloud storage workflow diagram
Detection workflow: motion starts the event, face detection checks the scene, alerts go out, snapshots are saved, and storage keeps the history.
ESP32-CAM face detection security interface
Face detection in action: the system flags a face, labels the event, and prepares a snapshot for review.
Privacy note: Use face recognition responsibly. Keep processing local when possible, avoid recording public areas, and follow local laws before pointing cameras at sidewalks, neighbors, or shared spaces.

Step 6: Send Phone Alerts with Snapshots

The best security alert is not just β€œmotion detected.” It should tell you where it happened and show you a snapshot. That is what turns a basic camera into a useful smart-home device.

Phone notification from Home Assistant showing ESP32-CAM front door snapshot
Phone notification screenshot style: person detected, camera location, snapshot preview, and quick action buttons.
alias: Front Door Camera Alert
trigger:
  - platform: state
    entity_id: binary_sensor.front_door_motion
    to: "on"
action:
  - service: camera.snapshot
    target:
      entity_id: camera.front_door_esp32
    data:
      filename: /config/www/front_door_latest.jpg
  - service: notify.mobile_app_your_phone
    data:
      title: "Security Alert"
      message: "Person detected at the front door."
      data:
        image: /local/front_door_latest.jpg

Step 7: Save Snapshots and Build an Event History

Do not rely only on live view. Save snapshots when events happen. Keep the newest image for notifications and archive important events to Home Assistant storage, a NAS, or cloud sync.

  1. Create a folder for camera snapshots.
  2. Use timestamped filenames so old events are not overwritten.
  3. Keep a low-resolution version for mobile alerts.
  4. Delete old snapshots automatically after a set number of days.

Helpful Embedded Videos

These three videos use direct YouTube embed URLs from the exact links you provided, so the lightbox opens the selected video instead of a search playlist.

ESP32-CAM setup video thumbnail

Video 1: ESP32-CAM setup

Use this first video to help readers get the ESP32-CAM ready, powered, connected, and streaming.

Open on YouTube
Home Assistant camera integration video thumbnail

Video 2: Home Assistant camera workflow

This second video supports the smart home dashboard and automation side of the security camera build.

Open on YouTube
ESP32-CAM face detection video thumbnail

Video 3: Face detection and AI alerts

This third video fits the recognition, detection, and alerting part of the tutorial.

Open on YouTube

Troubleshooting

Upload fails

Check TX/RX crossover, GPIO0 to GND, correct board selection, and press reset when uploading starts.

Camera reboots

Use a stronger 5V supply. ESP32-CAM is picky with weak USB ports.

No stream appears

Open Serial Monitor, confirm WiFi connection, and verify the IP address.

Bad night image

Add better porch lighting or use an IR-capable camera module and matching illumination.

Recommended Next Builds

AI Doorbell Camera

Add a button, chime, speaker, and visitor snapshot workflow.

πŸšͺ View Doorbell Cameras
AI Robot Rover with ESP32-CAM

Take the camera off the wall and put it on wheels.

Package Detection System

Use object detection to watch for deliveries at your front door.

Home Assistant Masterclass

Turn all your ESP32 builds into one smart dashboard.

πŸ€–