提交 9aaf1391 编写于 作者: 云逸之's avatar 云逸之 💬

兼容合宙S3

上级 d8ed2339
......@@ -7,12 +7,25 @@
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = heZhouS3
[env:esp32cam]
platform = espressif32
board = esp32cam
framework = arduino
upload_speed= 115200
upload_port = COM3
monitor_speed= 115200
monitor_port = COM3
\ No newline at end of file
upload_speed = 115200
monitor_speed = 115200
[env:heZhouS3]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
upload_speed = 921600
monitor_speed = 115200
; 重载摄像头配置 指定合宙S3引脚
build_flags = -DOVER_LOAD_CAM_CONF
-DHE_ZHOU_S3
; 指定帧大小
-DFRAMESIZE=FRAMESIZE_SVGA
;-DFRAMESIZE=FRAMESIZE_HD
\ No newline at end of file
//
// Created by lustre on 2023/2/2.
//
#ifndef CAM_PINS_H
#define CAM_PINS_H
#ifdef CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#elif defined(HE_ZHOU_S3)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 39
#define SIOD_GPIO_NUM 21
#define SIOC_GPIO_NUM 46
// 这里Y几并非真正的原理图上引脚的标号 而是 适配 D0 ~ D7 固定一套 Y标号的写法 以便于兼容其它esp32摄像头的定义
#define Y9_GPIO_NUM 40 //D7
#define Y8_GPIO_NUM 38 //D6
#define Y7_GPIO_NUM 37 //D5
#define Y6_GPIO_NUM 35 //D4
#define Y5_GPIO_NUM 33 //D3
#define Y4_GPIO_NUM 48 //D2
#define Y3_GPIO_NUM 47 //D1
#define Y2_GPIO_NUM 34 //D0
#define VSYNC_GPIO_NUM 42
#define HREF_GPIO_NUM 41
#define PCLK_GPIO_NUM 36
#endif
#endif // CAM_PINS_H
#include <Arduino.h>
#include <WiFi.h>
#include "esp_camera.h"
#define CAMERA_MODEL_AI_THINKER
#include "UdpClient.hpp"
#include "ai_thinker_esp32_cam_meta.h"
const char* ssid = "test0";
const char* passwd = "12345687";
const char* host = "192.168.137.1";
#ifndef OVER_LOAD_CAM_CONF
#define CAMERA_MODEL_AI_THINKER
#define FRAMESIZE FRAMESIZE_SVGA
//#define HE_ZHOU_S3
#endif
#include "cam_pins.h"
const char *ssid = "test0";
const char *passwd = "12345687";
const char *host = "192.168.137.1";
const uint16_t serverUdpPort = 8004;
const uint16_t localUdpPort = 2333;
LightUDP streamSender;
void connectWifi(const char* ssid, const char* passphrase) {
void connectWifi(const char *ssid, const char *passphrase) {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, passphrase);
......@@ -48,25 +54,29 @@ void setup() {
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 12;
config.fb_count = 1;
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
// for larger pre-allocated frame buffer.
if (psramFound()) {
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 10;
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_LATEST;
} else {
// 使用非psram申请
config.frame_size = FRAMESIZE_SVGA;
config.jpeg_quality = 12;
config.fb_count = 1;
config.fb_location = CAMERA_FB_IN_DRAM;
}
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
......@@ -74,9 +84,9 @@ void setup() {
return;
}
Serial.println("get sensor ");
sensor_t* s = esp_camera_sensor_get();
sensor_t *s = esp_camera_sensor_get();
// drop down frame size for higher initial frame rate
s->set_framesize(s, FRAMESIZE_SVGA);
s->set_framesize(s, FRAMESIZE);
connectWifi(ssid, passwd);
streamSender.begin(WiFi.localIP(), localUdpPort);
......@@ -84,7 +94,7 @@ void setup() {
}
void loop() {
camera_fb_t* fb = NULL;
camera_fb_t *fb = NULL;
size_t len = 0;
Serial.println("do loop");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册