OV-2640: ESP32 Digital Camera

icon picker
OV-2640 ESP32 Setup Guide (Advanced)

Important: This guide is for setting up the bare module on a breadboard. Visit this link for setup using the ESP32-CAM System on Chip Module (recommended): ​
This is much easier and more repeatable than the steps below which set up the module over pins.

Interfacing with OV-2640 Camera over CSI using ESP32 Microcontroller


Hardware Requirements
ESP32 microcontroller (e.g., ESP32 DevKitC)
OV-2640 camera module
CSI cable (or a compatible camera cable)
Breadboard and jumper wires

Software Requirements
ESP32 Arduino core (install via Arduino IDE)
ESP32-CAM library (install via Arduino Library Manager)

Connecting the Hardware

Connect the OV-2640 camera module to the ESP32 microcontroller using the CSI cable. Make sure to match the pinouts:
OV-2640 VCC to ESP32 3V3
OV-2640 GND to ESP32 GND
OV-2640 SCL to ESP32 SCL (GPIO22)
OV-2640 SDA to ESP32 SDA (GPIO21)
OV-2640 PCLK to ESP32 PCLK (GPIO0)
OV-2640 VSYNC to ESP32 VSYNC (GPIO25)
OV-2640 HREF to ESP32 HREF (GPIO26)
Connect the ESP32 microcontroller to your computer using a USB cable.
In the Arduino IDE, take note of which serial port becomes active when the device is connected. It is this port that we will use for flashing and debugging the microcontroller.

Installing the ESP32-CAM Library

Open the Arduino IDE and navigate to Sketch > Include Library > Manage Libraries.
Search for "ESP32-CAM” and install the library.
Restart the Arduino IDE.

Example Code
Create a new Arduino project and paste the following code:

#include "esp_camera.h"

// Pin definitions
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.