Build a Smart Doorbell with ESP32-CAM: Motion-Triggered Photo Alerts

A DIY smart doorbell replaces a mechanical chime with a small Wi-Fi camera board that watches an entrance, notices when someone or something moves in front of it, and reports that event as a photo and a status message instead of just a bell sound. The core hardware is a microcontroller with a built-in camera module, such as the ESP32-CAM, running firmware that watches for motion, wakes the camera, captures a frame, and reports over a connection back to you, while a physical button and a small buzzer cover the traditional ring-and-chime behavior a visitor expects at the door.

What parts does a DIY smart doorbell need?

At minimum, a build like this needs a main controller with an onboard camera, a continuous power source (this is a fixed installation, not a battery gadget you charge occasionally), something for a visitor to press to trigger a chime, a buzzer or speaker for the audible notification, and wiring to tie it together. The ESP32-CAM specifically has no USB port on the board itself, so it also needs a separate USB-to-serial programmer to get firmware onto it in the first place — that is a one-time flashing tool, not a permanent part of the installed doorbell.

How does the ESP32-CAM capture and send images?

The ESP32-CAM pairs an ESP32 microcontroller with an OV2640 or OV3660 camera sensor connected over a parallel DVP interface, not I2C or SPI. The firmware generated for this build initializes that interface with a specific pin map: PWDN_GPIO_NUM 32, RESET_GPIO_NUM -1, XCLK_GPIO_NUM 0, SIOD_GPIO_NUM 26, SIOC_GPIO_NUM 27, and the eight parallel data lines Y9 through Y2 on GPIOs 35, 34, 39, 36, 21, 19, 18 and 5, with VSYNC_GPIO_NUM 25 for frame sync. That pin map is standard for the AI-Thinker ESP32-CAM module and is what the Espressif esp_camera.h library expects to talk to the sensor.

Where it gets specific to this particular sketch: the assistant's own summary of the generated code says, verbatim, "It will detect motion using the PIR sensor, capture a photo, and print status messages to the serial monitor. The captured image data will be streamed over serial if you send a 'c' character." In other words, this exact generated sketch does not push the photo to the internet or a phone app on its own — it captures on motion and holds the frame, and you pull the image data over the serial/USB connection by sending a single character. Turning that into a phone notification or cloud upload is additional work on top of what this sketch does out of the box, typically an HTTP POST from the ESP32 to a server or a service like a Telegram bot, which the WiFi.h include at the top of the sketch prepares for but the printed status-monitor behavior does not yet implement.

Does the camera need a separate power supply?

No — one 5V supply runs the whole build. The ESP32-CAM accepts power over micro-USB or its 5V/3.3V pin and draws roughly 180mA on its own, and the tray built for this project used a single 5V 2A (2000mA) Micro-USB Power Adapter sized against the whole build's combined active draw, which the assistant itself totaled at roughly 1020mA across every part. That leaves headroom, which matters here: ESP32-CAM boards are known for pulling short current spikes above their steady-state draw during Wi-Fi transmission, and an undersized supply is a common cause of random resets or a camera that fails to initialize on these boards.

How does this compare to a commercial smart doorbell?

A retail smart doorbell arrives with a weatherproof housing, a rechargeable or hardwired battery option, a finished mobile app with push notifications, and cloud video storage, usually behind a subscription. This build does none of that automatically. The parts list below totals about Rs.1,085 before an enclosure, and the generated firmware in this run prints to the serial monitor and streams an image only when you manually request it over serial — there is no app, no push notification, and no cloud storage unless you write that layer yourself on top of the Wi-Fi connectivity the ESP32-CAM provides. What you get instead is full visibility into the code, no recurring fees, and a board you can reprogram for a completely different trigger condition or output later. What you give up is the finished, weatherproof, app-connected product that arrives working out of the box.

Watch it built live

We typed this into Compoden's storefront assistant, Soldr, exactly as a customer would:

"I want to build a smart doorbell with a camera that detects motion, using an ESP32-CAM"

Compoden storefront AI assistant Soldr building an ESP32-CAM smart doorbell parts tray

Soldr assembled a seven-part tray and explained its reasoning in plain language: "This build creates a smart doorbell with a camera. When motion is detected, it will capture an image and notify you. You can also press a button to ring the doorbell, which will make a sound." For the trigger itself, it picked a 5D Rocker Joystick Module rather than a simple push button, and was upfront about why: "This module is chosen to be the physical button that a visitor would press to ring your doorbell," adding later that it "can be used as a button to ring the doorbell or to navigate menus if you add a screen later." It also flagged a real wiring caution: "while the ESP32-CAM uses 3.3V logic, the 5D Rocker Joystick Module and Active Piezo Buzzer Module 5V 2.3kHz use 5V logic," which means care is needed connecting those signal lines back into the ESP32-CAM's lower-voltage GPIO pins.

We also asked Soldr directly to add a dedicated PIR motion sensor to the same cart. It kept the build unchanged and said so plainly: "I kept your current build — that change would have replaced it, and the part you asked for isn't a fit for this setup." For this exact tray, motion detection stays camera-side rather than coming from a separate hardware PIR module — a real constraint worth knowing before you check out, not a missing step on our part.

Watch the firmware get generated

We then took the project to Compoden's VoltIQ code assistant and asked it to write working firmware:

"I'm building a smart doorbell with an ESP32-CAM and a PIR motion sensor. Write the full firmware to detect motion and capture a photo, printing status to the serial monitor."

VoltIQ PWA generated ESP32-CAM firmware for motion-triggered photo capture with PIR sensor wiring

Given a prompt that explicitly named a PIR sensor, the build log on the left matched five parts — ESP32-CAM, an HC-SR501 PIR Motion Sensor Module, a 5V 2A Micro-USB Power Adapter, jumper wires, and the ESP32-CAM-MB programmer — a different five-part list than the seven items Soldr's storefront cart settled on above, since the two assistants resolve parts independently. The generated sketch includes WiFi.h, esp_camera.h, and mbedtls/base64.h for encoding image data, and the reply above the code panel gives a direct wiring instruction: "Wire the HC-SR501 PIR sensor's VCC to 5V, GND to GND, and DATA pin to ESP32-CAM GPIO." Code appears in the editor all at once rather than streaming in. VoltIQ also flagged the sketch honestly rather than presenting it as finished: "Heads up — this sketch does not compile yet. I tried one automatic fix and it still fails. Tell me the board you're on and I'll correct it." That is a real limitation of this generated draft, not something to paper over — treat the firmware tab as a strong starting point that needs a compile pass before it goes on the board, not a drop-in finished sketch.

Who this build is for

This project suits someone who already has an Arduino IDE set up, is comfortable flashing a board over a USB-to-serial adapter, and wants a low-cost way to prototype a camera-based motion alert rather than buy a finished consumer doorbell. It is not a good fit if you want push notifications and cloud video working the moment you plug it in, or if you need a weatherproof unit ready for an exterior door without building your own enclosure first.

Get everything in this build

These are the exact parts Soldr selected for this build, with live prices and direct add-to-cart links.

Part Price Add to cart
ESP32-CAM (OV2640/OV3660, WiFi + Bluetooth) Rs.670 Add to cart
5V 2A Micro-USB Power Adapter Rs.140 Add to cart
5D Rocker Joystick Module (doorbell button) Rs.85 Add to cart
Active Piezo Buzzer Module 5V 2.3kHz Rs.45 Add to cart
23 AWG Multi-Strand Breadboard Wire Rs.10 Add to cart
Male-to-Male Breadboard Jumper Wires (20 cm, 24 AWG) Rs.40 Add to cart
ESP32-CAM-MB Programmer Module Rs.95 Add to cart
Total Rs.1,085 Add all 7 to cart

If you want hardware-triggered motion detection instead of relying on the camera side, a PIR motion sensor module can be added separately from Compoden's sensor category — it was not part of this exact resolved cart, as noted above.

Built and Backed by Compoden

Every part listed above ships from Compoden's India stock, so there's no long international shipping wait on a camera module or a programmer board. Parts are checked for compatibility with the boards they're paired with before they're listed together in a build like this one. Orders typically arrive in 3-7 days, Cash on Delivery and UPI are both supported at checkout, and Compoden's support team is available if you run into wiring or firmware issues while building.

Frequently asked questions

What parts do I need to build this ESP32-CAM smart doorbell?
An ESP32-CAM board, a 5V power adapter, a button or similar trigger for the chime, a small buzzer for the audible alert, jumper wires, and a USB-to-serial programmer module since the ESP32-CAM has no onboard USB port for flashing.

Does the camera need a separate power supply?
No. A single 5V 2A adapter powers the ESP32-CAM and the rest of the build's parts, which together draw roughly 1020mA active — well within that adapter's 2000mA capacity.

Does this build use a PIR motion sensor?
The exact storefront cart captured for this article does not include one; when asked directly to add one, Soldr kept the build unchanged and said the part wasn't a fit for this setup. A separately generated firmware sketch, given a prompt that named a PIR sensor, did include PIR wiring instructions, so a standalone PIR module can be added if you want hardware-interrupt-based detection instead of camera-side motion detection.

Is the generated firmware ready to flash as-is?
Not without review. The firmware assistant flagged its own output: "this sketch does not compile yet. I tried one automatic fix and it still fails." Treat the generated code as a strong starting draft and expect to run a compile pass, telling the assistant your exact board if it needs a further correction.

Back to blog