Initial commit

This commit is contained in:
2026-04-26 21:35:04 +08:00
commit da6ca1b09a
1483 changed files with 115719 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
# DFRobot ESP32-S3 AI智能摄像头模块
## 介绍
ESP32-S3 AI CAM是一款基于ESP32-S3芯片设计的智能摄像头模组专为视频图像处理和语音交互打造适用于视频监控、边缘图像识别、语音对话等AI项目。
![](https://ws.dfrobot.com.cn/FsTrGbrX2NZAwzWS8OSQGOGikuYA)
[点击查看详细介绍](https://wiki.dfrobot.com.cn/SKU_DFR1154_ESP32_S3_AI_CAM)
[点击查看视觉功能演示](https://www.bilibili.com/video/BV1ktjSzNEUU/)
# 特性
* 使用PDM麦克风
* 板载 OV3660 摄像头
## 按键配置
* BOOT短按-打断/唤醒
## 编译配置命令
**配置编译目标为 ESP32S3**
```bash
idf.py set-target esp32s3
```
**打开 menuconfig**
```bash
idf.py menuconfig
```
**选择板子:**
```
Xiaozhi Assistant -> Board Type -> DFRobot ESP32-S3 AI智能摄像头模块
```
**修改 psram 配置:**
```
Component config -> ESP PSRAM -> SPI RAM config -> Mode (QUAD/OCT) -> Octal Mode PSRAM
```
**修改 WiFi 发射功率 为 10**
```
Component config -> PHY -> (10)Max WiFi TX power (dBm)
```
**配置摄像头:**
* **OV3660**
```
Component config -> Espressif Camera Sensors Configurations -> Camera Sensor Configuration -> Select and Set Camera Sensor -> OV3660 -> Auto detect OV3660
```
```
Component config -> Espressif Camera Sensors Configurations -> Camera Sensor Configuration -> Select and Set Camera Sensor -> OV3660 -> Select default output format for DVP interface (YUV422 240x240 24fps, DVP 8-bit, 20M input)
```
* **OV2640**
```
Component config -> Espressif Camera Sensors Configurations -> Camera Sensor Configuration -> Select and Set Camera Sensor -> OV2640 -> Auto detect OV2640
```
```
Component config -> Espressif Camera Sensors Configurations -> Camera Sensor Configuration -> Select and Set Camera Sensor -> OV2640 -> Select default output format for DVP interface (YUV422 240x240 25fps, DVP 8-bit, 20M input)
```
**编译:**
```bash
idf.py build
```

View File

@@ -0,0 +1,63 @@
#ifndef _BOARD_CONFIG_H_
#define _BOARD_CONFIG_H_
#include <driver/gpio.h>
#define AUDIO_INPUT_SAMPLE_RATE 16000
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
#define AUDIO_I2S_MIC_GPIO_SCK GPIO_NUM_38
#define AUDIO_I2S_MIC_GPIO_DIN GPIO_NUM_39
#define AUDIO_I2S_SPK_GPIO_DOUT GPIO_NUM_42
#define AUDIO_I2S_SPK_GPIO_BCLK GPIO_NUM_45
#define AUDIO_I2S_SPK_GPIO_LRCK GPIO_NUM_46
#define AUDIO_I2S_SPK_GPIO_GAIN GPIO_NUM_41
#define BUILTIN_LED_GPIO GPIO_NUM_3
#define BOOT_BUTTON_GPIO GPIO_NUM_0
#define TOUCH_BUTTON_GPIO GPIO_NUM_NC
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
#define RESET_NVS_BUTTON_GPIO GPIO_NUM_NC
#define RESET_FACTORY_BUTTON_GPIO GPIO_NUM_NC
/* DFRobot Camera pins */
#define PWDN_GPIO_NUM GPIO_NUM_NC
#define RESET_GPIO_NUM GPIO_NUM_NC
#define XCLK_GPIO_NUM GPIO_NUM_5
#define Y9_GPIO_NUM GPIO_NUM_4
#define Y8_GPIO_NUM GPIO_NUM_6
#define Y7_GPIO_NUM GPIO_NUM_7
#define Y6_GPIO_NUM GPIO_NUM_14
#define Y5_GPIO_NUM GPIO_NUM_17
#define Y4_GPIO_NUM GPIO_NUM_21
#define Y3_GPIO_NUM GPIO_NUM_18
#define Y2_GPIO_NUM GPIO_NUM_16
#define VSYNC_GPIO_NUM GPIO_NUM_1
#define HREF_GPIO_NUM GPIO_NUM_2
#define PCLK_GPIO_NUM GPIO_NUM_15
#define SIOD_GPIO_NUM GPIO_NUM_8
#define SIOC_GPIO_NUM GPIO_NUM_9
/* Camera pins */
#define CAMERA_PIN_PWDN PWDN_GPIO_NUM
#define CAMERA_PIN_RESET RESET_GPIO_NUM
#define CAMERA_PIN_XCLK XCLK_GPIO_NUM
#define CAMERA_PIN_SIOD SIOD_GPIO_NUM
#define CAMERA_PIN_SIOC SIOC_GPIO_NUM
#define CAMERA_PIN_D7 Y9_GPIO_NUM
#define CAMERA_PIN_D6 Y8_GPIO_NUM
#define CAMERA_PIN_D5 Y7_GPIO_NUM
#define CAMERA_PIN_D4 Y6_GPIO_NUM
#define CAMERA_PIN_D3 Y5_GPIO_NUM
#define CAMERA_PIN_D2 Y4_GPIO_NUM
#define CAMERA_PIN_D1 Y3_GPIO_NUM
#define CAMERA_PIN_D0 Y2_GPIO_NUM
#define CAMERA_PIN_VSYNC VSYNC_GPIO_NUM
#define CAMERA_PIN_HREF HREF_GPIO_NUM
#define CAMERA_PIN_PCLK PCLK_GPIO_NUM
#define XCLK_FREQ_HZ 20000000
#endif // _BOARD_CONFIG_H_

View File

@@ -0,0 +1,19 @@
{
"target": "esp32s3",
"builds": [
{
"name": "df-s3-ai-cam",
"sdkconfig_append": [
"CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=10",
"CONFIG_ESP_PHY_MAX_TX_POWER=10",
"CONFIG_SPIRAM_MODE_OCT=y",
"CONFIG_CAMERA_OV2640=n",
"CONFIG_CAMERA_OV2640_AUTO_DETECT_DVP_INTERFACE_SENSOR=y",
"CONFIG_CAMERA_OV2640_DVP_YUV422_240X240_25FPS=y",
"CONFIG_CAMERA_OV3660=y",
"CONFIG_CAMERA_OV3660_AUTO_DETECT_DVP_INTERFACE_SENSOR=y",
"CONFIG_CAMERA_OV3660_DVP_YUV422_240X240_24FPS=y"
]
}
]
}

View File

@@ -0,0 +1,112 @@
#include "wifi_board.h"
#include "codecs/no_audio_codec.h"
#include "system_reset.h"
#include "application.h"
#include "button.h"
#include "config.h"
#include "esp_video.h"
#include "mcp_server.h"
#include "settings.h"
#include "led/gpio_led.h"
#include <esp_log.h>
#include <driver/i2c_master.h>
#include <driver/gpio.h>
#define TAG "DfrobotEsp32S3AiCam"
class DfrobotEsp32S3AiCam : public WifiBoard {
private:
Button boot_button_;
EspVideo* camera_;
void InitializeButtons() {
boot_button_.OnClick([this]() {
auto& app = Application::GetInstance();
if (app.GetDeviceState() == kDeviceStateStarting) {
EnterWifiConfigMode();
return;
}
app.ToggleChatState();
});
}
void InitializeCamera() {
static esp_cam_ctlr_dvp_pin_config_t dvp_pin_config = {
.data_width = CAM_CTLR_DATA_WIDTH_8,
.data_io = {
[0] = CAMERA_PIN_D0,
[1] = CAMERA_PIN_D1,
[2] = CAMERA_PIN_D2,
[3] = CAMERA_PIN_D3,
[4] = CAMERA_PIN_D4,
[5] = CAMERA_PIN_D5,
[6] = CAMERA_PIN_D6,
[7] = CAMERA_PIN_D7,
},
.vsync_io = CAMERA_PIN_VSYNC,
.de_io = CAMERA_PIN_HREF,
.pclk_io = CAMERA_PIN_PCLK,
.xclk_io = CAMERA_PIN_XCLK,
};
esp_video_init_sccb_config_t sccb_config = {
.init_sccb = true,
.i2c_config = {
.port = 1,
.scl_pin = CAMERA_PIN_SIOC,
.sda_pin = CAMERA_PIN_SIOD,
},
.freq = 100000,
};
esp_video_init_dvp_config_t dvp_config = {
.sccb_config = sccb_config,
.reset_pin = CAMERA_PIN_RESET,
.pwdn_pin = CAMERA_PIN_PWDN,
.dvp_pin = dvp_pin_config,
.xclk_freq = XCLK_FREQ_HZ,
};
esp_video_init_config_t video_config = {
.dvp = &dvp_config,
};
camera_ = new EspVideo(video_config);
#if ( CONFIG_CAMERA_OV3660 )
camera_->SetVFlip(true);
camera_->SetHMirror(true);
#elif ( CONFIG_CAMERA_OV2640 )
camera_->SetVFlip(false);
camera_->SetHMirror(false);
#endif
}
public:
DfrobotEsp32S3AiCam() :
boot_button_(BOOT_BUTTON_GPIO) {
InitializeButtons();
InitializeCamera();
}
// Wakenet model only
virtual Led* GetLed() override {
static GpioLed led(BUILTIN_LED_GPIO, 0);
return &led;
}
virtual AudioCodec* GetAudioCodec() override {
static NoAudioCodecSimplexPdm audio_codec(AUDIO_INPUT_SAMPLE_RATE, AUDIO_OUTPUT_SAMPLE_RATE,
AUDIO_I2S_SPK_GPIO_BCLK, AUDIO_I2S_SPK_GPIO_LRCK, AUDIO_I2S_SPK_GPIO_DOUT,
AUDIO_I2S_MIC_GPIO_SCK, AUDIO_I2S_MIC_GPIO_DIN);
return &audio_codec;
}
virtual Camera* GetCamera() override {
return camera_;
}
};
DECLARE_BOARD(DfrobotEsp32S3AiCam);