Configure an esp32-camera (viam-micro-server)

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:

Fake Camera on the ESP32

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",
    "namespace": "rdk",
    "type": "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.

{
  "name": "my-esp32camera",
  "namespace": "rdk",
  "type": "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
  }
}
{
  "name": "my-esp32camera",
  "namespace": "rdk",
  "type": "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
  }
}

The following attributes are available for esp32-camera cameras:

NameTypeRequired?Description
pin_pwdnintOptionalGPIO pin for camera power down line.
Default: -1
pin_resetintOptionalGPIO pin for camera reset line.
Default: -1
pin_xclkintOptionalGPIO pin for camera XCLK line.
Default: 21
pin_sccb_sdaintOptionalGPIO pin for camera SDA line.
Default: 26
pin_sccb_sclintOptionalGPIO pin for camera SCL line.
Default: 27
pin_d7intOptionalGPIO pin for camera D7 line.
Default: 35
pin_d6intOptionalGPIO pin for camera D6 line.
Default: 34
pin_d5intOptionalGPIO pin for camera D5 line.
Default: 39
pin_d4intOptionalGPIO pin for camera D4 line.
Default: 36
pin_d3intOptionalGPIO pin for camera D3 line.
Default: 19
pin_d2intOptionalGPIO pin for camera D2 line.
Default: 18
pin_d1intOptionalGPIO pin for camera D1 line.
Default: 5
pin_d0intOptionalGPIO pin for camera D0 line.
Default: 4
pin_vsyncintOptionalGPIO pin for camera VSYNC line.
Default: 25
pin_hrefintOptionalGPIO pin for camera HREF line.
Default: 23
pin_pclkintOptionalGPIO pin for camera PLCK line.
Default: 22
xclk_freq_hzintOptionalFrequency of XCLK signal, in Hz.
Experimental: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode.
Default: 20000000
ledc_timerintOptionalLEDC timer to generate XCLK.
Default: 1
ledc_channelintOptionalLEDC channel to generate XCLK.
Default: 1
frame_sizeintOptionalSize of the output image.
Default: 1
jpeg_qualityintOptionalQuality of JPEG output. Lower means higher quality.
Range: 0-63
Default: 32

View the camera stream

Once your camera is configured and connected, expand the TEST panel on the CONFIGURE or CONTROL tabs. If everything is configured correctly, you will see the live feed from your camera.

Example Camera view inside Viam app

Troubleshooting

If your camera is not working as expected, follow these steps:

  1. Check your machine logs on the LOGS tab to check for errors.
  2. Review this camera model’s documentation to ensure you have configured all required attributes.
  3. Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the camera there.

If none of these steps work, reach out to us on the Community Discord and we will be happy to help.

Next steps

For more configuration and usage info, see:

Have questions, or want to meet other people working on robots? Join our Community Discord.

If you notice any issues with the documentation, feel free to file an issue or edit this file.