Overview
The OV2640 is a 2-megapixel UXGA () 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 format | 1/4-inch () |
| Active pixel array | (~2.0 Megapixels UXGA) |
| Pixel size | |
| Hardware JPEG encoder | Built-in (outputs compressed JPEG, YUV422, RGB565, or RAW) |
| Control interface | SCCB ( compatible, default address 0x30) |
| Data interface | 8-Bit Parallel DVP (Y0–Y7, PCLK, VSYNC, HREF, XCLK) |
| Frame rates | 15 fps (UXGA ), 30 fps (SVGA ), 60 fps (CIF) |
| Connector | 24-pin 0.5 mm pitch FPC flex connector |
Pinout (24-Pin FPC Flex Connector)
| Pin | Name | Type | Description |
|---|---|---|---|
| 1 | VCC / DOVDD | Power | Digital I/O supply (+2.8 V DC) |
| 2 | GND | Power | Ground (0 V) |
| 3 | Y2 / D0 | Output | Parallel Data bit 2 (DVP D0) |
| 4 | Y3 / D1 | Output | Parallel Data bit 3 (DVP D1) |
| 5 | Y4 / D2 | Output | Parallel Data bit 4 (DVP D2) |
| 6 | Y5 / D3 | Output | Parallel Data bit 5 (DVP D3) |
| 7 | Y6 / D4 | Output | Parallel Data bit 6 (DVP D4) |
| 8 | Y7 / D5 | Output | Parallel Data bit 7 (DVP D5) |
| 9 | Y8 / D6 | Output | Parallel Data bit 8 (DVP D6) |
| 10 | Y9 / D7 | Output | Parallel Data bit 9 (DVP D7) |
| 11 | PCLK | Output | Pixel Clock output |
| 12 | XCLK | Input | Master Clock input (typically 20 MHz generated by MCU) |
| 13 | HREF | Output | Horizontal Reference / Line Sync output |
| 14 | VSYNC | Output | Vertical Sync / Frame Start output |
| 15 | RESET | Input | Active-Low hardware reset pin |
| 16 | PWDN | Input | Active-High power-down pin |
| 17 | SIOC / SCL | Input | SCCB Clock ( SCL) |
| 18 | SIOD / SDA | I/O | SCCB Data ( SDA) |
| 19–24 | AGND, AVDD, DVDD | Power | Analog & Core power supply pins |
Specifications
| Parameter | Symbol | Min | Typ | Max | Unit | Conditions |
|---|---|---|---|---|---|---|
| Analog Supply Voltage | 2.5 | 2.8 | 3.0 | V | Sensor core analog | |
| Digital Core Voltage | 1.14 | 1.2 | 1.3 | V | Internal logic | |
| I/O Voltage | 1.71 | 2.8 | 3.3 | V | DVP bus logic | |
| Active Supply Current | — | 125 | 140 | mA | 15 fps UXGA JPEG | |
| Standby Current | — | 600 | — | µA | Software standby | |
| Master Clock Frequency | 6 | 20 | 27 | MHz | Input from MCU | |
| Sensitivity | — | 0.6 | — | V/Lux-sec | Green channel |
Recommended Resolutions
| Frame Size | Resolution | Image Format | Typical JPEG Size |
|---|---|---|---|
| UXGA | JPEG | ~100–150 KB | |
| SXGA | JPEG | ~80–120 KB | |
| XGA | JPEG | ~50–80 KB | |
| SVGA | JPEG | ~30–50 KB | |
| VGA | JPEG | ~15–30 KB | |
| QVGA | JPEG | ~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 Signal | ESP32 GPIO | Function |
|---|---|---|
Y2–Y9 (D0–D7) | GPIO 5, 18, 19, 21, 36, 39, 34, 35 | 8-bit Parallel DVP Data Bus |
PCLK | GPIO 22 | Pixel Clock |
XCLK | GPIO 0 | Master Clock (20 MHz PWM) |
HREF | GPIO 23 | Line Sync |
VSYNC | GPIO 25 | Frame Sync |
SIOC (SCL) | GPIO 27 | SCCB Control Clock |
SIOD (SDA) | GPIO 26 | SCCB Control Data |
PWDN | GPIO 32 | Power Down |
RESET | -1 (tied High) | Reset |
Warning
PSRAM Requirement for UXGA:
- Frame buffers for high resolutions ( UXGA or 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 (VGA) due to limited internal SRAM ().
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 (~). 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
- datasheetdatasheet
- product-pagereference