2019-03-13 16:17:05 +01:00
ESP32 Camera Component
======================
.. seo ::
:description: Instructions for setting up the ESP32 Cameras in ESPHome
2021-11-16 03:19:33 +01:00
:image: camera.svg
2019-03-13 16:17:05 +01:00
The `` esp32_camera `` component allows you to use ESP32-based camera boards in ESPHome that
directly integrate into Home Assistant through the native API.
.. code-block :: yaml
# Example configuration entry
esp32_camera:
name: My Camera
external_clock:
2024-05-07 07:40:12 +02:00
pin: GPIOXX
2019-03-13 16:17:05 +01:00
frequency: 20MHz
i2c_pins:
2024-05-07 07:40:12 +02:00
sda: GPIOXX
scl: GPIOXX
data_pins: [GPIOXX, GPIOXX, GPIOXX, GPIOXX, GPIOXX, GPIOXX, GPIOXX, GPIOXX]
vsync_pin: GPIOXX
href_pin: GPIOXX
pixel_clock_pin: GPIOXX
reset_pin: GPIOXX
2019-03-13 16:17:05 +01:00
resolution: 640x480
jpeg_quality: 10
Configuration variables:
------------------------
- **name** (**Required** , string): The name of the camera.
2021-12-22 07:25:23 +01:00
- **icon** (*Optional* , icon): Manually set the icon to use for the camera in the frontend.
- **internal** (*Optional* , boolean): Mark this component as internal. Internal components will
not be exposed to the frontend (like Home Assistant). Only specifying an `` id `` without
a `` name `` will implicitly set this to true.
2021-08-10 03:45:41 +02:00
- **disabled_by_default** (*Optional* , boolean): If true, then this entity should not be added to any client's frontend,
(usually Home Assistant) without the user manually enabling it (via the Home Assistant UI).
2024-04-23 06:46:47 +02:00
Defaults to `` false `` .
2021-11-07 19:24:55 +01:00
- **entity_category** (*Optional* , string): The category of the entity.
See https://developers.home-assistant.io/docs/core/entity/#generic-properties
2024-04-23 06:46:47 +02:00
for a list of available options.
2021-11-07 19:24:55 +01:00
Set to `` "" `` to remove the default entity category.
2019-03-13 16:17:05 +01:00
Connection Options:
- **data_pins** (**Required** , list of pins): The data lanes of the camera, this must be a list
2020-05-10 21:27:59 +02:00
of 8 GPIO pins.
2019-03-13 16:17:05 +01:00
- **vsync_pin** (**Required** , pin): The pin the VSYNC line of the camera is connected to.
- **href_pin** (**Required** , pin): The pin the HREF line of the camera is connected to.
- **pixel_clock_pin** (**Required** , pin): The pin the pixel clock line of the camera is connected to.
- **external_clock** (**Required** ): The configuration of the external clock to drive the camera.
- **pin** (**Required** , pin): The pin the external clock line is connected to.
2023-03-19 20:50:38 +01:00
- **frequency** (*Optional* , float): The frequency of the external clock, must be between 10
and 20MHz. Defaults to `` 20MHz `` .
2019-03-13 16:17:05 +01:00
2020-11-09 02:22:55 +01:00
- **i2c_pins** (**Required** ): The I²C control pins of the camera.
2019-03-13 16:17:05 +01:00
2020-11-09 02:22:55 +01:00
- **sda** (**Required** , pin): The SDA pin of the I²C interface. Also called `` SIOD `` .
- **scl** (**Required** , pin): The SCL pin of the I²C interface. Also called `` SIOC `` .
2019-03-13 16:17:05 +01:00
- **reset_pin** (*Optional* , pin): The ESP pin the reset pin of the camera is connected to.
If set, this will reset the camera before the ESP boots.
- **power_down_pin** (*Optional* , pin): The ESP pin to power down the camera.
If set, this will power down the camera while it is inactive.
- **test_pattern** (*Optional* , boolean): When enabled, the camera will show a test pattern
that can be used to debug connection issues.
Frame Settings:
- **max_framerate** (*Optional* , float): The maximum framerate the camera will generate images at.
Up to 60Hz is possible (with reduced frame sizes), but beware of overheating. Defaults to `` 10 fps `` .
- **idle_framerate** (*Optional* , float): The framerate to capture images at when no client
is requesting a full stream. Defaults to `` 0.1 fps `` .
2022-01-24 23:54:00 +01:00
Image Settings:
2019-03-13 16:17:05 +01:00
- **resolution** (*Optional* , enum): The resolution the camera will capture images at. Higher
resolutions require more memory, if there's not enough memory you will see an error during startup.
2024-05-18 08:34:32 +02:00
- `` 160x120 `` (QQVGA, 4:3)
- `` 176x144 `` (QCIF, 11:9)
- `` 240x176 `` (HQVGA, 15:11)
- `` 320x240 `` (QVGA, 4:3)
- `` 400x296 `` (CIF, 50:37)
- `` 640x480 `` (VGA, 4:3, default)
- `` 800x600 `` (SVGA, 4:3)
- `` 1024x768 `` (XGA, 4:3)
- `` 1280x1024 `` (SXGA, 5:4)
- `` 1600x1200 `` (UXGA, 4:3)
- `` 1920x1080 `` (FHD, 16:9)
- `` 720x1280 `` (Portrait HD, 9:16)
- `` 864x1536 `` (Portrait 3MP, 9:16)
- `` 2048x1536 `` (QXGA, 4:3)
- `` 2560x1440 `` (QHD, 16:9)
- `` 2560x1600 `` (WQXGA, 8:5)
- `` 1080x1920 `` (Portrait FHD, 9:16)
- `` 2560x1920 `` (QSXGA, 4:3)
2023-03-19 20:50:38 +01:00
2019-03-13 16:17:05 +01:00
- **jpeg_quality** (*Optional* , int): The JPEG quality that the camera should encode images with.
2019-08-31 19:49:13 +02:00
From 10 (best) to 63 (worst). Defaults to `` 10 `` .
2022-01-24 23:54:00 +01:00
- **vertical_flip** (*Optional* , boolean): Whether to flip the image vertically. Defaults to `` true `` .
- **horizontal_mirror** (*Optional* , boolean): Whether to mirror the image horizontally. Defaults to `` true `` .
2019-03-13 16:17:05 +01:00
- **contrast** (*Optional* , int): The contrast to apply to the picture, from -2 to 2. Defaults to `` 0 `` .
- **brightness** (*Optional* , int): The brightness to apply to the picture, from -2 to 2. Defaults to `` 0 `` .
- **saturation** (*Optional* , int): The saturation to apply to the picture, from -2 to 2. Defaults to `` 0 `` .
2022-01-24 23:54:00 +01:00
- **special_effect** (*Optional* , enum): The effect to apply to the picture. Defaults to `` none `` (picture without effect).
- `` none `` : Picture without effect
- `` negative `` : Colors of picture are inverted
- `` grayscale `` : Only luminance of picture is kept
- `` red_tint `` : Picture appear red-tinted
- `` green_tint `` : Picture appear green-tinted
- `` blue_tint `` : Picture appear blue-tinted
- `` sepia `` : Sepia effect is applied to picture
Exposure Settings:
- **aec_mode** (*Optional* , enum): The mode of exposure module. Defaults to `` auto `` (leave camera to automatically adjust exposure).
- `` manual `` : Exposure can be manually set, with **aec_value** parameter. **ae_level** has no effect here
- `` auto `` : Camera manage exposure automatically. Compensation can be applied, thanks to **ae_level** parameter. **aec_value** has no effect here
- **aec2** (*Optional* , boolean): Whether to enable Auto Exposure Control 2. Seems to change computation method of automatic exposure. Defaults to `` false `` .
- **ae_level** (*Optional* , int): The auto exposure level to apply to the picture (when **aec_mode** is set to `` auto `` ), from -2 to 2. Defaults to `` 0 `` .
- **aec_value** (*Optional* , int): The Exposure value to apply to the picture (when **aec_mode** is set to `` manual `` ), from 0 to 1200. Defaults to `` 300 `` .
Sensor Gain Settings:
- **agc_mode** (*Optional* , enum): The mode of gain control module. Defaults to `` auto `` (leave camera to automatically adjust sensor gain).
- `` manual `` : Gain can be manually set, with **agc_value** parameter. **agc_gain_ceiling** has no effect here
- `` auto `` : Camera manage sensor gain automatically. Maximum gain can be defined, thanks to **agc_gain_ceiling** parameter. **agc_value** has no effect here
- **agc_value** (*Optional* , int): The gain value to apply to the picture (when **aec_mode** is set to `` manual `` ), from 0 to 30. Defaults to `` 0 `` .
- **agc_gain_ceiling** (*Optional* , enum): The maximum gain allowed, when **agc_mode** is set to `` auto `` . This parameter seems act as "ISO" setting. Defaults to `` 2x `` .
- `` 2x `` : Camera is less sensitive, picture is clean (without visible noise)
- `` 4x ``
- `` 8x ``
- `` 16x ``
- `` 32x ``
- `` 64x ``
- `` 128x `` : Camera is more sensitive, but picture contain lot of noise
White Balance Setting:
- **wb_mode** (*Optional* , enum): The mode of white balace module. Defaults to `` auto `` .
- `` auto `` : Camera choose best white balance setting
- `` sunny `` : White balance sunny mode
- `` cloudy `` : White balance cloudy mode
- `` office `` : White balance office mode
- `` home `` : White balance home mode
2022-05-19 02:23:56 +02:00
Automations:
- **on_stream_start** (*Optional* , :ref: `Automation <automation>` ): An automation to perform
when a stream starts.
2022-08-31 03:55:05 +02:00
- **on_stream_stop** (*Optional* , :ref: `Automation <automation>` ): An automation to perform
2022-05-19 02:23:56 +02:00
when a stream stops.
2023-12-12 05:48:25 +01:00
- **on_image** (*Optional* , :ref: `Automation <automation>` ): An automation called when image taken. Image is available as `` image `` variable of type :apistruct: `esp32_camera::CameraImageData` .
2022-05-19 02:23:56 +02:00
2022-01-24 23:54:00 +01:00
Test Setting:
- **test_pattern** (*Optional* , boolean): For tests purposes, it's possible to replace picture get from sensor by a test color pattern. Defaults to `` false `` .
2019-03-13 16:17:05 +01:00
2019-03-17 20:45:03 +01:00
.. note ::
2019-10-20 16:28:02 +02:00
Camera uses PWM timer #1. If you need PWM (via the `` ledc `` platform) you need to manually specify
a channel there (with the `` channel: 2 `` parameter)
2019-03-17 20:45:03 +01:00
2024-06-04 15:34:45 +02:00
Configuration examples
----------------------
**Ai-Thinker Camera** :
2019-03-17 12:10:03 +01:00
2023-10-25 16:45:13 +02:00
.. warning ::
2024-04-23 06:46:47 +02:00
GPIO16 on this board (and possibly other boards below) is connected to onboard PSRAM.
2023-10-25 16:45:13 +02:00
Using this GPIO for other purposes (eg as a button) will trigger the watchdog.
Further information on pin notes can be found here: https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/esp32cam-pin-notes.md
2019-03-17 12:10:03 +01:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
# Image settings
name: My Camera
# ...
2024-06-04 15:34:45 +02:00
**M5Stack Camera** :
2019-03-17 12:10:03 +01:00
.. warning ::
This camera board has insufficient cooling and will overheat over time,
ESPHome does only activate the camera when Home Assistant requests an image, but
2019-05-08 15:37:44 +02:00
the camera unit can still heat up considerably for some boards.
2019-03-17 12:10:03 +01:00
If the camera is not recognized after a reboot and the unit feels warm, try waiting for
it to cool down and check again - if that still doesn't work try enabling the test pattern.
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO27
frequency: 20MHz
i2c_pins:
sda: GPIO25
scl: GPIO23
data_pins: [GPIO17, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
vsync_pin: GPIO22
href_pin: GPIO26
pixel_clock_pin: GPIO21
reset_pin: GPIO15
# Image settings
name: My Camera
# ...
2024-06-04 15:34:45 +02:00
**M5Stack Timer Camera X/F** :
2022-01-10 00:22:41 +01:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO27
frequency: 20MHz
i2c_pins:
sda: GPIO25
scl: GPIO23
data_pins: [GPIO32, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
vsync_pin: GPIO22
href_pin: GPIO26
pixel_clock_pin: GPIO21
reset_pin: GPIO15
# Image settings
name: My Camera
# ...
2019-03-17 12:10:03 +01:00
2024-06-04 15:34:45 +02:00
**M5Stack M5CameraF New** :
2023-11-05 21:23:04 +01:00
.. code-block :: yaml
# Example configuration entry as per https://docs.m5stack.com/en/unit/m5camera_f_new
esp32_camera:
external_clock:
pin: GPIO27
frequency: 20MHz
i2c_pins:
sda: GPIO22
scl: GPIO23
data_pins: [GPIO32, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
vsync_pin: GPIO25
href_pin: GPIO26
pixel_clock_pin: GPIO21
reset_pin: GPIO15
2024-06-04 15:34:45 +02:00
**Wrover Kit Boards** :
2019-03-17 12:10:03 +01:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO21
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO4, GPIO5, GPIO18, GPIO19, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
# Image settings
name: My Camera
# ...
2024-06-04 15:34:45 +02:00
**TTGO T-Camera V05** :
2019-04-24 14:00:09 +02:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO32
frequency: 20MHz
i2c_pins:
sda: GPIO13
scl: GPIO12
data_pins: [GPIO5, GPIO14, GPIO4, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]
vsync_pin: GPIO27
href_pin: GPIO25
pixel_clock_pin: GPIO19
power_down_pin: GPIO26
# Image settings
name: My Camera
# ...
2024-06-04 15:34:45 +02:00
**TTGO T-Camera V162** :
2020-07-21 01:33:27 +02:00
.. code-block :: yaml
esp32_camera:
external_clock:
pin: GPIO4
frequency: 20MHz
i2c_pins:
sda: GPIO18
scl: GPIO23
data_pins: [GPIO34, GPIO13, GPIO14, GPIO35, GPIO39, GPIO38, GPIO37, GPIO36]
vsync_pin: GPIO5
href_pin: GPIO27
pixel_clock_pin: GPIO25
jpeg_quality: 10
vertical_flip: true
horizontal_mirror: false
2021-09-22 13:41:09 +02:00
# Image settings
name: My Camera
2020-07-21 01:33:27 +02:00
# ...
2019-08-27 22:20:00 +02:00
2024-06-04 15:34:45 +02:00
**TTGO T-Camera V17** :
2019-08-27 22:20:00 +02:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO32
frequency: 20MHz
i2c_pins:
sda: GPIO13
scl: GPIO12
data_pins: [GPIO5, GPIO14, GPIO4, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]
vsync_pin: GPIO27
href_pin: GPIO25
pixel_clock_pin: GPIO19
# power_down_pin: GPIO26
vertical_flip: true
horizontal_mirror: true
# Image settings
name: My Camera
# ...
2024-06-04 15:34:45 +02:00
**TTGO T-Journal** :
2019-07-11 10:19:53 +02:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO27
frequency: 20MHz
i2c_pins:
sda: GPIO25
scl: GPIO23
data_pins: [GPIO17, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
vsync_pin: GPIO22
href_pin: GPIO26
pixel_clock_pin: GPIO21
2020-05-27 01:02:09 +02:00
# Image settings
name: My Camera
# ...
2020-11-09 02:22:55 +01:00
2024-06-04 15:34:45 +02:00
**TTGO-Camera Plus** :
2020-05-27 01:02:09 +02:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO4
frequency: 20MHz
i2c_pins:
sda: GPIO18
scl: GPIO23
data_pins: [GPIO34, GPIO13, GPIO26, GPIO35, GPIO39, GPIO38, GPIO37, GPIO36]
vsync_pin: GPIO5
href_pin: GPIO27
pixel_clock_pin: GPIO25
vertical_flip: false
horizontal_mirror: false
2021-02-20 22:01:59 +01:00
# Image settings
name: My Camera
# ...
2024-06-04 15:34:45 +02:00
**TTGO-Camera Mini** :
2021-02-20 22:01:59 +01:00
.. code-block :: yaml
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO32
frequency: 20MHz
i2c_pins:
2021-08-10 03:45:41 +02:00
sda: GPIO13
2021-02-20 22:01:59 +01:00
scl: GPIO12
data_pins: [GPIO5, GPIO14, GPIO4, GPIO15, GPIO37, GPIO38, GPIO36, GPIO39]
vsync_pin: GPIO27
href_pin: GPIO25
pixel_clock_pin: GPIO19
2021-09-22 13:41:09 +02:00
# Image settings
name: My Camera
# ...
2021-11-07 19:24:55 +01:00
2024-06-04 15:34:45 +02:00
**ESP-EYE** :
2021-09-22 13:41:09 +02:00
.. code-block :: yaml
2021-02-20 22:01:59 +01:00
2021-09-22 13:41:09 +02:00
# Example configuration entry
esp32_camera:
external_clock:
pin: GPIO4
frequency: 20MHz
i2c_pins:
sda: GPIO18
scl: GPIO23
data_pins: [GPIO34, GPIO13, GPIO14, GPIO35, GPIO39, GPIO38, GPIO37, GPIO36]
vsync_pin: GPIO5
href_pin: GPIO27
pixel_clock_pin: GPIO25
2021-02-20 22:01:59 +01:00
2019-07-11 10:19:53 +02:00
# Image settings
name: My Camera
# ...
2019-04-24 14:00:09 +02:00
2024-06-04 15:34:45 +02:00
**ESP32S3_EYE** on `Freenove ESP32-S3-DevKitC-1 <https://github.com/Freenove/Freenove_ESP32_S3_WROOM_Board> `__ :
2023-10-25 17:04:20 +02:00
.. code-block :: yaml
# Example configuration entry
external_components:
- source:
type: git
url: https://github.com/MichaKersloot/esphome_custom_components
components: [ esp32_camera ]
esp32_camera:
external_clock:
pin: GPIO15
frequency: 20MHz
i2c_pins:
sda: GPIO4
scl: GPIO5
data_pins: [GPIO11, GPIO9, GPIO8, GPIO10, GPIO12, GPIO18, GPIO17, GPIO16]
vsync_pin: GPIO6
href_pin: GPIO7
pixel_clock_pin: GPIO13
# Image settings
name: My Camera
# ...
2021-09-22 13:41:09 +02:00
2024-06-04 15:34:45 +02:00
**Seeed Studio XIAO ESP32S3 Sense** :
.. code-block :: yaml
esp32_camera:
external_clock:
pin: GPIO10
frequency: 20MHz
i2c_pins:
sda: GPIO40
scl: GPIO39
data_pins: [GPIO15, GPIO17, GPIO18, GPIO16, GPIO14, GPIO12, GPIO11, GPIO48]
vsync_pin: GPIO38
href_pin: GPIO47
pixel_clock_pin: GPIO13
# Image settings
name: My Camera
# ...
2019-03-13 16:17:05 +01:00
See Also
--------
2019-05-12 22:44:59 +02:00
- :apiref: `esp32_camera/esp32_camera.h`
2019-03-13 16:17:05 +01:00
- :ghedit: `Edit`