Is ESP32-CAM Board with OV2640 Camera Compatible with Home Assistant (ESPHome)?
Compatibility Overview
Popular low-cost ESP32 camera development board with OV2640 2MP CMOS camera sensor for video streaming in Home Assistant.
Wiring ESP32-CAM Board with OV2640 Camera to ESP32-CAM
| Module pin | ESP32-CAM | Note |
|---|---|---|
| 5V | 5V supply | Power it here, not from 3.3V. Ai-Thinker gives about 180mA at 5V with the flash off and 310mA with it at full brightness; a supply that cannot keep up shows as brownout resets. |
| GND | GND | |
| U0R / U0T | USB-serial adapter TX / RX | For the first flash only, crossed over. After that ESPHome updates over Wi-Fi. An ESP32-CAM-MB carrier board does the same job with a USB socket. |
| IO0 | GND, while flashing | Held to ground at reset, it starts the bootloader. Remove the link afterwards: the same pin is the camera's XCLK in the config, and left grounded the board boots straight back into the bootloader. |
| Camera XCLK / SIOD / SIOC | GPIO0 / GPIO26 / GPIO27 | Fixed by the board through the ribbon connector; nothing on the camera is wired by hand. SIOD and SIOC are the sensor's control bus. |
| Camera D0–D7 | GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35 | In that order in data_pins. |
| Camera VSYNC / HREF / PCLK / PWDN | GPIO25 / GPIO23 / GPIO22 / GPIO32 | |
| Flash LED | GPIO4 | The bright white LED on the front. GPIO4 is also DATA1 of the microSD slot, so the flash and a card get in each other's way. |
| Red LED | GPIO33 | Active low, hence inverted: true in the config. |
| Antenna | PCB antenna or IPEX socket | A 0Ω resistor beside the IPEX socket selects one or the other. |
Host pins are the ones the configuration on this page uses. Move a pin here and change it in the YAML — they are documented together so they cannot disagree.
Technical Specification Matrix
| Feature / Attribute | Specification / Status |
|---|---|
| Hardware Protocol | DVP Parallel / 3.3V |
| Bridge Required | NO |
| Border Router Needed | None |
| Hardware Capabilities & Peripherals | Camera Motion Stream Flashlight LED Frame Rate Note: these entities come from the ESPHome configuration you flash — each one needs its matching component in that YAML before it appears. |
| Pairing Complexity | Intermediate |
| Factory Reset Instruction | Connect GPIO0 to GND and press Reset button to enter serial flash mode. |
Wire, Flash, Adopt, Check
Wire it up
Follow the wiring table above. The ESP32-CAM pins there are the ones the configuration uses, so if you move one, change it in both places.
Flash the configuration
Create a new device in the ESPHome dashboard (the Home Assistant add-on) and paste the configuration below into it, or save it as emb_esp32cam_ov2640_ha.yaml and run esphome run emb_esp32cam_ov2640_ha.yaml. The first flash goes over USB. If it is not detected, connect GPIO0 to GND and press Reset button to enter serial flash mode to put it in download mode. Every update after that is over the air.
Adopt it in Home Assistant
Settings → Devices & Services. A node on the same network shows up as a discovered ESPHome device within a minute of joining Wi-Fi; choose Configure and enter the API encryption key from your secrets.yaml. If discovery does not find it, add the ESPHome integration by hand with the node's IP address.
Check it works
The boot log's setup section lists the camera with the sensor it detected, and Home Assistant adds a Camera entity. Open http://<node-ip>:8080: a moving picture means the ribbon, PSRAM and power are all right. A camera that fails to initialise is the ribbon or a warm board; resets as the stream starts are power; a Flash light that misbehaves, or a camera that fails once the flash is used, means channel: 2 has gone missing from the flash output.
ESPHome Configuration
Starting configuration for ESP32-CAM Board with OV2640 Camera on ESP32-CAM. Untested on hardware — verify wiring and pins against your own board.
# ESPHome configuration for ESP32-CAM Board with OV2640 Camera
# Host: ESP32-CAM. Pin numbers below are host-side defaults — any free
# GPIO will do, and you should change them to match your own wiring.
esphome:
name: emb_esp32cam_ov2640_ha
friendly_name: "ESP32-CAM Board with OV2640 Camera"
esp32:
board: esp32cam
framework:
type: esp-idf
psram:
logger:
api:
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# AI-Thinker ESP32-CAM pin map. These are fixed by the board.
esp32_camera:
name: "Camera"
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
resolution: 800x600
jpeg_quality: 12
max_framerate: 10 fps
idle_framerate: 0.2 fps
esp32_camera_web_server:
- port: 8080
mode: stream
# The white flash LED on GPIO4 and the red status LED on GPIO33. The camera
# already drives XCLK from LEDC channel 0; an ledc output left to pick its own
# channel lands on the same one, so the flash gets channel 2.
output:
- platform: ledc
pin: GPIO4
channel: 2
id: flash_pwm
light:
- platform: monochromatic
output: flash_pwm
name: "Flash"
- platform: status_led
name: "Status LED"
pin:
number: GPIO33
inverted: true
Before you flash:
the !secret values come from your
secrets.yaml, and the GPIO numbers are host-side
defaults rather than properties of this part — change them to match how you actually wired it.
What Appears in Home Assistant
Snapshots and a stream through the native API, at 800x600. When no client wants a stream the camera idles at 0.2 frames per second, which keeps the board cooler.
Open http://<node-ip>:8080 in a browser, or add it as a Generic Camera in Home Assistant. The web server serves one stream at a time.
Dimmable, from the ledc output on GPIO4, which the config puts on its own LEDC channel so it stays clear of the camera clock.
The red LED as an ordinary on/off light. While the node has a warning or error ESPHome takes it over and blinks it, then hands it back.
Known Problems and Fixes
The flash needs its own LEDC channel
The camera component generates XCLK on LEDC timer 0, channel 0. An ledc output with no channel: set is handed channel 0 as well, which puts the flash on the camera clock's timer and leaves one of the two misbehaving. That is why flash_pwm carries channel: 2, the fix ESPHome's camera documentation gives. Keep it when copying the flash block into another camera config.
Flashing without a USB port
The board has no USB. Wire a USB-serial adapter to U0R and U0T, link IO0 to GND, power the 5V pin and press the reset button; the ESP32 comes up in its bootloader for the first ESPHome install. Remove the IO0 link and reset again to run the firmware. Every later update goes over Wi-Fi.
Brownouts are the usual failure
Resets as Wi-Fi or the camera starts, with a brownout message in the serial log, are power. A thin or long USB lead, a computer's USB port or an adapter's 3.3V pin are the usual causes. Feed the 5V pin from a proper 5V supply.
Almost no pins to spare
The camera takes most of the GPIOs. Of the rest, GPIO1 and GPIO3 are the serial port, GPIO16 is wired to the PSRAM on most of these boards and trips the watchdog if reused, and GPIO2, GPIO4 and GPIO12–GPIO15 belong to the microSD slot. Adding a sensor to this board usually means giving up the card.
Check the antenna resistor
A slow stream or a node that keeps dropping off Wi-Fi is often the antenna. The 0Ω resistor next to the IPEX socket must sit in the position for the antenna actually in use: selecting the socket with nothing plugged in leaves almost no signal. An external antenna on the socket, with the resistor moved to match, is a large improvement over the PCB antenna.
Warm boards lose the camera
Continuous streaming heats the module, and idle_framerate in the config keeps the camera slow until something is watching. If the camera is not detected after a reboot and the board feels warm, ESPHome's advice is to let it cool down and try again.
Seat the ribbon
Most camera probe failures at boot are the sensor's ribbon not fully home in its connector. Flip the latch up, push the ribbon in straight, and close the latch.
Report a Pinout Error or Submit Tested Code Snippets
Found a pin mapping quirk or built a custom ESPHome YAML driver for ESP32-CAM Board with OV2640 Camera? Submit a pull request or report corrections to our index.
Hardware Correction Reporter (emb-esp32cam-ov2640-ha)
Frequently Asked Questions
Does ESP32-CAM Board with OV2640 Camera work without an internet connection?
How is ESP32-CAM Board with OV2640 Camera powered?
How does ESP32-CAM Board with OV2640 Camera connect to your network?
Alternatives
Seeed Studio XIAO ESP32S3 Sense Cam & Mic
An ESP32-S3 camera with USB-C for flashing, a microphone, an external antenna and 8MB of PSRAM, on a much smaller board.
ESP32-S3-CAM OV2640 Camera Module
The generic ESP32-S3 camera boards: a newer chip and a USB port on the board, so no serial adapter.
eufyCam 2C Wireless Camera
A finished wireless camera, when the goal is watching the door rather than building the camera.