Overview

The OV2640 is a 1/4"1/4\text{"} 2-megapixel UXGA (1600×12001600 \times 1200) CMOS image sensor manufactured by OmniVision Technologies. What sets the OV2640 apart from standard parallel camera sensors is its integrated hardware JPEG compression encoder engine.

By compressing raw image frames into lightweight JPEG byte streams directly inside the sensor before transmission, the OV2640 allows microcontrollers with modest RAM and processing power—most notably the ESP32-CAM (AI-Thinker) development board—to stream live video over Wi-Fi and capture high-resolution photos without needing megabytes of external frame buffers.

Quick reference

Optical format1/4-inch (3.52 mm×2.64 mm3.52\text{ mm} \times 2.64\text{ mm})
Active pixel array1600 (H)×1200 (V)1600 \text{ (H)} \times 1200 \text{ (V)} (~2.0 Megapixels UXGA)
Pixel size2.2 μm×2.2 μm2.2\ \mu\text{m} \times 2.2\ \mu\text{m}
Hardware JPEG encoderBuilt-in (outputs compressed JPEG, YUV422, RGB565, or RAW)
Control interfaceSCCB (I2CI^2C compatible, default address 0x30)
Data interface8-Bit Parallel DVP (Y0Y7, PCLK, VSYNC, HREF, XCLK)
Frame rates15 fps (UXGA 1600×12001600\times 1200), 30 fps (SVGA 800×600800\times 600), 60 fps (CIF)
Connector24-pin 0.5 mm pitch FPC flex connector

Pinout (24-Pin FPC Flex Connector)

PinNameTypeDescription
1VCC / DOVDDPowerDigital I/O supply (+2.8 V DC)
2GNDPowerGround (0 V)
3Y2 / D0OutputParallel Data bit 2 (DVP D0)
4Y3 / D1OutputParallel Data bit 3 (DVP D1)
5Y4 / D2OutputParallel Data bit 4 (DVP D2)
6Y5 / D3OutputParallel Data bit 5 (DVP D3)
7Y6 / D4OutputParallel Data bit 6 (DVP D4)
8Y7 / D5OutputParallel Data bit 7 (DVP D5)
9Y8 / D6OutputParallel Data bit 8 (DVP D6)
10Y9 / D7OutputParallel Data bit 9 (DVP D7)
11PCLKOutputPixel Clock output
12XCLKInputMaster Clock input (typically 20 MHz generated by MCU)
13HREFOutputHorizontal Reference / Line Sync output
14VSYNCOutputVertical Sync / Frame Start output
15RESETInputActive-Low hardware reset pin
16PWDNInputActive-High power-down pin
17SIOC / SCLInputSCCB Clock (I2CI^2C SCL)
18SIOD / SDAI/OSCCB Data (I2CI^2C SDA)
19–24AGND, AVDD, DVDDPowerAnalog & Core power supply pins

Specifications

ParameterSymbolMinTypMaxUnitConditions
Analog Supply VoltageAVDDAVDD2.52.83.0VSensor core analog
Digital Core VoltageDVDDDVDD1.141.21.3VInternal logic
I/O VoltageDOVDDDOVDD1.712.83.3VDVP bus logic
Active Supply CurrentIactiveI_{active}125140mA15 fps UXGA JPEG
Standby CurrentIstandbyI_{standby}600µASoftware standby
Master Clock FrequencyfXCLKf_{XCLK}62027MHzInput from MCU
SensitivitySsensS_{sens}0.6V/Lux-secGreen channel
Frame SizeResolutionImage FormatTypical JPEG Size
UXGA1600×12001600 \times 1200JPEG~100–150 KB
SXGA1280×10241280 \times 1024JPEG~80–120 KB
XGA1024×7681024 \times 768JPEG~50–80 KB
SVGA800×600800 \times 600JPEG~30–50 KB
VGA640×480640 \times 480JPEG~15–30 KB
QVGA320×240320 \times 240JPEG~6–12 KB

Wiring (ESP32-CAM AI-Thinker Board Pinout)

On ESP32-CAM boards, the 24-pin connector is pre-wired to ESP32 GPIOs:

OV2640 SignalESP32 GPIOFunction
Y2Y9 (D0–D7)GPIO 5, 18, 19, 21, 36, 39, 34, 358-bit Parallel DVP Data Bus
PCLKGPIO 22Pixel Clock
XCLKGPIO 0Master Clock (20 MHz PWM)
HREFGPIO 23Line Sync
VSYNCGPIO 25Frame Sync
SIOC (SCL)GPIO 27SCCB Control Clock
SIOD (SDA)GPIO 26SCCB Control Data
PWDNGPIO 32Power Down
RESET-1 (tied High)Reset
Warning

PSRAM Requirement for UXGA:

  • Frame buffers for high resolutions (1600×12001600 \times 1200 UXGA or 1280×10241280 \times 1024 SXGA) require allocating large memory buffers in external PSRAM (Pseudo-Static RAM).
  • Boards without external PSRAM (e.g. basic ESP32 chips without IPEX/PSRAM) are restricted to resolutions 640×480\le 640 \times 480 (VGA) due to limited internal SRAM (520 KB520\text{ KB}).

Example (Arduino ESP32 esp_camera Web Server)

cpp
#include "esp_camera.h"
#include <WiFi.h>

// Select AI THINKER Camera Model
#define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"

void setup() {
  Serial.begin(115200);

  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sscb_sda = SIOD_GPIO_NUM;
  config.pin_sscb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;

  if(psramFound()){
    config.frame_size = FRAMESIZE_UXGA; // 1600x1200
    config.jpeg_quality = 10;           // 0-63 (lower is higher quality)
    config.fb_count = 2;
  } else {
    config.frame_size = FRAMESIZE_SVGA; // 800x600
    config.jpeg_quality = 12;
    config.fb_count = 1;
  }

  // Camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }
  Serial.println("OV2640 camera initialized successfully!");
}

void loop() {
  // Capture camera frame
  camera_fb_t * fb = esp_camera_fb_get();
  if(!fb) {
    Serial.println("Camera capture failed");
    return;
  }
  
  Serial.printf("Captured JPEG: %u bytes\n", fb->len);
  
  // Return frame buffer back to memory pool
  esp_camera_fb_return(fb);
  delay(5000);
}

Common mistakes

  • Leaving 24-pin FPC connector unlatched: The tiny flip-up black latch on the ESP32-CAM 24-pin socket must be locked flat after inserting the flex ribbon. Unlatched ribbons cause missing pixel clocks or corrupt images.
  • Overheating ESP32-CAM during streaming: Continuous 15 fps video streaming causes the ESP32 chip and 3.3V LDO regulator to heat up quickly (~60C60^\circ\text{C}). Ensure adequate ventilation or add a heatsink.

Notes

  • OV2640 vs OV5640: OV2640 is 2MP UXGA with parallel DVP; OV5640 is 5MP QSXGA with autofocus and MIPI CSI/DVP interfaces.

Assets & downloads