Skip to content

Latest commit

 

History

History
205 lines (175 loc) · 7.35 KB

File metadata and controls

205 lines (175 loc) · 7.35 KB
title linkTitle weight type description images tags component_description micrordk_component toc_hide date aliases
Configure an esp32-camera (Micro-RDK)
esp32-camera (Micro-RDK)
33
docs
Configure a camera connected to an esp32 board, initialized and configured using esp-idf.
/icons/components/camera.svg
camera
components
Micro-RDK
An `OV2640` or `OV3660` camera connected to an esp32 board.
true
true
2024-08-28
/components/camera/esp32-camera/

esp32-camera is the camera model that supports all cameras that work with Espressif's esp32-camera drivers including:

For example, the OV2640 with a ribbon cable connected to an ESP32:

{{< imgproc src="/components/camera/esp32-camera-2640.png" alt="Fake Camera on the ESP32" resize="300x" class="shadow" >}}

{{< alert title="Software requirements" color="note" >}} To use this model, you must follow the viam-micro-server Development Setup, which enables you to install and activate the ESP-IDF. At the step Generate a new project from a template where you create a new project with cargo generate, select the option to include camera module traits when prompted. Finish the viam-micro-server Development Setup and return to this guide. {{< /alert >}}

{{< alert title="Data management not supported" color="caution" >}}

The esp32-camera camera model does not currently support the data management service.

{{< /alert >}}

First, connect your camera to your machine's microcontroller and turn the microcontroller on. Then, configure your camera:

{{< tabs name="Configure a esp32-camera" >}} {{% tab name="JSON Template" %}}

Navigate to the CONFIGURE tab of your machine's page in the Viam app. Select JSON mode. Copy and paste the following JSON into your existing machine configuration into the "components" array:

{
    "name": "my-esp32camera",
    "api": "rdk:component:camera",
    "model": "esp32-camera",
    "attributes": {
        "pin_d4": <int>,
        "jpeg_quality": <int>,
        "frame_size": <int>,
        "pin_d5": <int>,
        "pin_d3": <int>,
        "pin_d6": <int>,
        "pin_vsync": <int>,
        "ledc_timer": <int>,
        "pin_d7": <int>,
        "pin_sccb_sda": <int>,
        "pin_href": <int>,
        "pin_sccb_scl": <int>,
        "sccb_i2c_port": <int>,
        "pin_d1": <int>,
        "pin_d0": <int>,
        "pin_xclk": <int>,
        "pin_reset": <int>,
        "pin_pclk": <int>,
        "pin_d2": <int>,
        "xclk_freq_hz": <int>,
        "ledc_channel": <int>
    }
}

Edit and fill in the attributes as applicable.

{{% /tab %}} {{% tab name="JSON Example: OV2640" %}}

{
  "name": "my-esp32camera",
  "api": "rdk:component:camera",
  "model": "esp32-camera",
  "attributes": {
    "pin_pwdn": -1,
    "pin_reset": -1,
    "pin_xclk": 21,
    "pin_sccb_sda": 26,
    "pin_sccb_scl": 27,
    "pin_d7": 35,
    "pin_d6": 34,
    "pin_d5": 39,
    "pin_d4": 36,
    "pin_d3": 19,
    "pin_d2": 18,
    "pin_d1": 5,
    "pin_d0": 4,
    "pin_vsync": 25,
    "pin_href": 23,
    "pin_pclk": 22,
    "xclk_freq_hz": 20000000,
    "ledc_timer": 1,
    "ledc_channel": 1
  }
}

{{% /tab %}} {{% tab name="JSON Example: OV3660" %}}

{
  "name": "my-esp32camera",
  "api": "rdk:component:camera",
  "model": "esp32-camera",
  "attributes": {
    "pin_d4": 39,
    "jpeg_quality": 32,
    "frame_size": 5,
    "pin_d5": 18,
    "pin_d3": 5,
    "pin_d6": 36,
    "pin_vsync": 22,
    "ledc_timer": 1,
    "pin_d7": 19,
    "pin_sccb_sda": 25,
    "pin_href": 26,
    "pin_sccb_scl": 23,
    "sccb_i2c_port": -1,
    "pin_d1": 35,
    "pin_d0": 32,
    "pin_xclk": 27,
    "pin_reset": 15,
    "pin_pclk": 21,
    "pin_d2": 34,
    "xclk_freq_hz": 20000000,
    "ledc_channel": 1
  }
}

{{% /tab %}} {{< /tabs >}}

{{% alert title="Note" color="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. {{% /alert %}}

The following attributes are available for esp32-camera cameras:

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

View the camera stream

{{< readfile "/static/include/components/camera-view-camera-stream.md" >}}

Troubleshooting

{{< readfile "/static/include/components/troubleshoot/camera.md" >}}

Next steps

For more configuration and usage info, see:

{{< cards >}} {{% card link="/dev/reference/apis/components/camera/" customTitle="Camera API" noimage="true" %}} {{% card link="/data-ai/capture-data/capture-sync/" noimage="true" %}} {{< /cards >}}