简体中文
English
简体中文
日本語

Stamp-AddOn Cam0308 ESPHome 集成

本教程介绍如何将 Stamp-AddOn Cam0308 连接到 Stamp-S3Bat,并通过 ESPHome 集成到 Home Assistant。

1. 设备简介

项目 信息
产品名称 Stamp-AddOn Cam0308
SKU A178
适配主控 Stamp-S3Bat
图像传感器 GC0308,0.3MP
图像接口 SCCB、8 位 DVP 并行接口
ESPHome 版本要求 2026.3.0 及以上

2. 配置说明

ESP32 框架

GC0308 需要使用 ESP-IDF 框架,并通过 CONFIG_GC0308_SUPPORT 启用传感器驱动:

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_GC0308_SUPPORT: "y"

启动初始化

摄像头驱动初始化前,需要先将 PWDN (GPIO39) 拉低、RESET (GPIO41) 拉高并等待 500ms。完整案例通过 M5Stack 的 early_init 外部组件执行该启动时序:

external_components:
  - source: github://m5stack/esphome-yaml/components@main
    components: [early_init]

early_init:
  id: power_up_barrier
  pins:
    - pin:
        number: GPIO39
        allow_other_uses: true
      level: false
    - pin:
        number: GPIO41
        allow_other_uses: true
      level: true
  delay: 500ms
启动时序
early_init、GPIO39/GPIO41 的电平设置及 500ms 延时用于保证摄像头正常启动,请保留该配置。

摄像头配置

Cam0308 的 SCCB 数据线为 GPIO48/GPIO47,图像数据通过 8 位 DVP 接口输入。allow_other_uses: true 用于允许摄像头组件复用启动初始化阶段使用的 GPIO39 和 GPIO41:

i2c:
  - id: cam_bus
    sda: GPIO48
    scl: GPIO47
    frequency: 100kHz

esp32_camera:
  name: "Camera"
  id: gc0308_camera
  i2c_id: cam_bus
  data_pins:
    - GPIO21
    - GPIO18
    - GPIO16
    - GPIO15
    - GPIO14
    - GPIO12
    - GPIO38
    - GPIO40
  vsync_pin: GPIO42
  href_pin: GPIO17
  pixel_clock_pin: GPIO13
  external_clock:
    pin:
      number: GPIO46
      ignore_strapping_warning: true
    frequency: 20MHz
  power_down_pin:
    number: GPIO39
    allow_other_uses: true
  reset_pin:
    number: GPIO41
    allow_other_uses: true
  resolution: 320x240
  pixel_format: RGB565
  jpeg_quality: 12
  max_framerate: 10 fps
  frame_buffer_count: 1
  frame_buffer_location: PSRAM
  agc_mode: auto
  agc_value: 10
  aec_mode: auto
  aec_value: 480
  vertical_flip: true
  horizontal_mirror: false
  test_pattern: false

示例默认使用 QVGA (320 x 240) 分辨率和 10 fps 最大帧率。需要调整分辨率或帧率时,建议逐项修改并确认设备运行稳定。

3. 参考案例

完整配置请参考 stamp-addon-cam0308.yaml。该文件已经包含设备、网络、API、OTA、启动初始化和摄像头配置。

  1. 在 ESPHome 中导入完整案例。
  2. 按照 ESPHome 常规流程完成配置、编译和固件烧录。
  3. 设备连接网络后,在 Home Assistant 中完成发现和添加。
  4. 打开设备页面,将 Camera 实体添加到 Dashboard,即可查看摄像头画面。

4. 相关链接

Page Tools
PDF
On This Page