# esp32-camera

`esp32-camera` is the camera model that supports all cameras that work with Espressif’s [esp32-camera drivers](https://github.com/espressif/esp32-camera) including:

- `OV2640`
  - [Datasheet](https://www.uctronics.com/download/OV2640_DS.pdf)
  - 1600 x 1200, Color, ¼” lens
  - You can use a cam ribbon adapter to connect to your `esp32` board
- `OV3660`: an [m5 camera timer module](https://docs.m5stack.com/en/unit/timercam_f)
  - [Datasheet](https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/unit/OV3660_CSP3_DS_1.3_sida.pdf)
  - 2048 x 1536, Color, ⅕” lens

## Software requirements

To use this model, you must follow the [Set up an ESP32 guide](https://docs.viam.com/reference/device-setup/setup-micro/#build-and-flash-custom-firmware), which enables you to install and activate the ESP-IDF.
When you create a new project with `cargo generate`, select the option to include camera module traits when prompted.
Finish building and flashing custom firmware, then return to this guide.

## Data management not supported

The `esp32-camera` camera model does not currently support the [data management service](https://docs.viam.com/data/capture-sync/capture-and-sync-data/).

## Configuration

- [JSON Template](https://docs.viam.com/reference/components/camera/micro-rdk/esp32-camera/#configure-a-esp32-camera-0)
- [JSON Example: OV2640](https://docs.viam.com/reference/components/camera/micro-rdk/esp32-camera/#configure-a-esp32-camera-1)
- [JSON Example: OV3660](https://docs.viam.com/reference/components/camera/micro-rdk/esp32-camera/#configure-a-esp32-camera-2)

#### Note

While the following attributes marked as **Optional** do have defaults, it is recommended that you configure them according to your datasheet as your device may not align with the defaults which could cause damage to your board or camera.

## Attributes

| Name | Type | Required? | Description |
| --- | --- | --- | --- |
| `pin_pwdn` | int | Optional | GPIO pin for camera power down line.<br>Default: -1 |
| `pin_reset` | int | Optional | GPIO pin for camera reset line.<br>Default: -1 |
| `pin_xclk` | int | Optional | GPIO pin for camera XCLK line.<br>Default: 21 |
| `pin_sccb_sda` | int | Optional | GPIO pin for camera SDA line.<br>Default: 26 |
| `pin_sccb_scl` | int | Optional | GPIO pin for camera SCL line.<br>Default: 27 |
| `pin_d7` | int | Optional | GPIO pin for camera D7 line.<br>Default: 35 |
| `pin_d6` | int | Optional | GPIO pin for camera D6 line.<br>Default: 34 |
| `pin_d5` | int | Optional | GPIO pin for camera D5 line.<br>Default: 39 |
| `pin_d4` | int | Optional | GPIO pin for camera D4 line.<br>Default: 36 |
| `pin_d3` | int | Optional | GPIO pin for camera D3 line.<br>Default: 19 |
| `pin_d2` | int | Optional | GPIO pin for camera D2 line.<br>Default: 18 |
| `pin_d1` | int | Optional | GPIO pin for camera D1 line.<br>Default: 5 |
| `pin_d0` | int | Optional | GPIO pin for camera D0 line.<br>Default: 4 |
| `pin_vsync` | int | Optional | GPIO pin for camera VSYNC line.<br>Default: 25 |
| `pin_href` | int | Optional | GPIO pin for camera HREF line.<br>Default: 23 |
| `pin_pclk` | int | Optional | GPIO pin for camera PLCK line.<br>Default: 22 |
| `xclk_freq_hz` | int | Optional | Frequency of XCLK signal, in Hz.<br>Experimental: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode.<br>Default: 20000000 |
| `ledc_timer` | int | Optional | LEDC timer to generate XCLK.<br>Default: 1 |
| `ledc_channel` | int | Optional | LEDC channel to generate XCLK.<br>Default: 1 |
| `frame_size` | int | Optional | Size of the output image.<br>Default: 1 |
| `jpeg_quality` | int | Optional | Quality of JPEG output. Lower means higher quality.<br>Range: 0-63<br>Default: 32 |
