Posted on

How to Build a WiFi Security Camera with ESP32-CAM

ESP32-CAM development board with OV2640 camera module

How to Build a WiFi Security Camera with ESP32-CAM

Build the camera from an ESP32-CAM board, an OV2640 camera module, and a PIR sensor. The board streams video over WiFi and costs $25.99 with the camera fitted. The PIR sensor wakes the camera when motion crosses its 7 m range. The sensor 2-pack costs $7.62 and holds its output for 0.3 to 18 sec.

Quick facts

Fact Value
ESP32-CAM board $25.99, OV2640 2MP, 4MB PSRAM
ESP32-S3-CAM board $11.97 board only, 16MB flash, 8MB PSRAM
PIR sensor Up to 7 m range, under 120 degree cone
PIR delay 0.3 to 18 sec adjustable, 5 to 20V
Storage TF card slot on both boards
Wireless WiFi and Bluetooth on both boards

What does the ESP32-CAM board include?

The board ships with an OV2640 camera and 4MB of PSRAM for $25.99.

It gives WiFi and Bluetooth on one chip. That lets you stream video to a phone or a laptop with no extra radio.

It uses a micro USB port for power and programming. A TF card slot stores stills when the network drops.

How does the PIR sensor wake the camera?

The PIR sensor sees motion up to 7 m away inside a cone under 120 degrees.

It runs on 5V to 20V and holds its output for 0.3 to 18 sec. Set a short delay for stills and a long delay for video.

The 2-pack costs $7.62, so keep one spare in the parts box. Wire its output to a GPIO pin and wake the camera on a rising edge.

Should you pick the ESP32-S3-CAM instead?

Pick the S3-CAM board at $11.97 when you need 16MB of flash and 8MB of PSRAM.

Add an OV2640 camera for $23.12 in total, or an OV5640 camera for $29.99 in total. The OV5640 gives 5MP stills for sharper photos.

The S3-CAM uses dual USB-C ports and the same TF card slot. Pick the older ESP32-CAM when the $25.99 fitted board suits the job.

How do you power the camera and sensor?

Power the board from a stable 5V supply over its micro USB port.

A weak supply drops the video feed when the camera captures a frame. Use a dedicated 5V supply, not a shared hub.

The PIR sensor runs on 5V to 20V, so the same 5V supply feeds it. Join the grounds of the board and the sensor.

How do you view the video stream?

The board serves its video stream over WiFi to a browser.

Open the stream address on a phone or a laptop on the same network. The 4MB of PSRAM holds each frame while the board sends it.

Test the stream at 2 m from the router first. Move the camera farther only after the near stream runs clean.

How the options compare

Camera option Camera Flash and PSRAM Price
ESP32-CAM OV2640 2MP included Not listed flash, 4MB PSRAM $25.99
ESP32-S3-CAM board No camera 16MB flash, 8MB PSRAM $11.97
S3-CAM + OV2640 OV2640 2MP 16MB flash, 8MB PSRAM $23.12
S3-CAM + OV5640 OV5640 5MP 16MB flash, 8MB PSRAM $29.99
PIR sensor, 2-pack Motion trigger, up to 7 m Not listed $7.62

How do you build the WiFi security camera?

  1. Fit the OV2640 camera module on the ESP32-CAM board connector.
  2. Connect the board to a stable 5V supply over micro USB.
  3. Load the camera sketch from the Arduino-ESP32 examples.
  4. Join the board to your WiFi network with your network name and password.
  5. Wire the PIR sensor output to a GPIO pin.
  6. Open the stream address in a browser and test the motion trigger.

Parts that fit this guide

In-stock parts ship from the New York, USA warehouse in 1-2 business days. Prices below are the live store prices we verified on November 10, 2026.

ESP32-CAM Development Board with OV2640 Camera Module, 4MB PSRAM ($25.99)

ESP32-CAM board at $25.99. It ships with an OV2640 camera module, 4MB of PSRAM, WiFi, Bluetooth, and a TF card slot.

ESP32-S3-CAM Development Board N16R8 – Board, OV2640 or OV5640 Camera, 1/5/10-Pack ($11.97)

ESP32-S3-CAM board at $11.97 for the board only. It carries 16MB of flash and 8MB of PSRAM, with OV2640 or OV5640 camera options.

HC-SR501 PIR Motion Sensor Module, 2-Pack ($7.62)

PIR sensor at $7.62. It is a 2-pack that sees motion up to 7 m away, with a 0.3 to 18 sec delay.

Shop the full range: ESP32 and ESP8266 at Quality RC Parts. See also: Related guide.

Frequently asked questions

Does the ESP32-CAM board include a camera?

Yes. The $25.99 board ships with an OV2640 camera module and 4MB of PSRAM.

How far does the PIR sensor see?

Up to 7 m inside a cone under 120 degrees. Mount it where the subject crosses the cone.

Can the camera save photos without a network?

Yes. Both boards in this guide have a TF card slot for stills and video storage.

Should I pick the S3-CAM board instead?

Pick it at $11.97 when you need 16MB of flash and 8MB of PSRAM. Add an OV2640 camera for $23.12 in total.

Sources

Last updated: November 10, 2026.