14106浏览
查看: 14106|回复: 1

[ESP8266/ESP32] 基于FireBeetle 2 ESP32-S3和行空板的无线图传相机

[复制链接]
本帖最后由 豆爸 于 2023-9-6 10:42 编辑



【项目背景】

FireBeetle 2 ESP32-S3是一款基于ESP32-S3-WROOM-1-N16R8模组设计的主控板,拥有16MB Flash和8MB PSRAM,板载摄像头接口。
开发板附带了一个OV2640摄像头,该摄像头拥有200万像素和68°视场角,最高支持1600*1200分辨率。本项目使用
FireBeetle 2 ESP32-S3与行空板来做一款相机,实现无线拍照


【硬件介绍

1.FireBeetle 2 ESP32-S3
基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图1

功能



基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图2

引脚


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图3

GPIO分配

2.行空板

基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图10




FireBeetle 2 ESP32-S3编程】

1.将DFRobot FireBeetle 2 ESP32-S3通过 USB线连接到电脑。打开Arduino IDE,选择开发板:DFRobot FireBeetle 2 ESP32-S3,选择端口,如下图所示。

基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图5

2.下载AXP313A库



3.新建程序

  1. #include "esp_camera.h"
  2. #include <WiFi.h>
  3. //
  4. // WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
  5. //            Ensure ESP32 Wrover Module or other board with PSRAM is selected
  6. //            Partial images will be transmitted if image exceeds buffer size
  7. //
  8. //            You must select partition scheme from the board menu that has at least 3MB APP space.
  9. //            Face Recognition is DISABLED for ESP32 and ESP32-S2, because it takes up from 15
  10. //            seconds to process single frame. Face Detection is ENABLED if PSRAM is enabled as well
  11. // ===================
  12. // Select camera model
  13. // ===================
  14. //#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
  15. //#define CAMERA_MODEL_ESP_EYE // Has PSRAM
  16. //#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
  17. //#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
  18. //#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
  19. //#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
  20. //#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
  21. //#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
  22. //#define CAMERA_MODEL_AI_THINKER // Has PSRAM
  23. //#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
  24. //#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM
  25. #define CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3 // Has PSRAN
  26. // ** Espressif Internal Boards **
  27. //#define CAMERA_MODEL_ESP32_CAM_BOARD
  28. //#define CAMERA_MODEL_ESP32S2_CAM_BOARD
  29. //#define CAMERA_MODEL_ESP32S3_CAM_LCD
  30. #include "camera_pins.h"
  31. #include "DFRobot_AXP313A.h"
  32. DFRobot_AXP313A axp;
  33. // ===========================
  34. // Enter your WiFi credentials
  35. // ===========================
  36. const char* ssid = "xiaogui";
  37. const char* password = "88888888";
  38. void startCameraServer();
  39. void setupLedFlash(int pin);
  40. void setup() {
  41.   Serial.begin(115200);
  42.   Serial.setDebugOutput(true);
  43.   Serial.println();
  44.   while(axp.begin() != 0){
  45.     Serial.println("init error");
  46.     delay(1000);
  47.   }
  48.   axp.enableCameraPower(axp.eOV2640);//设置摄像头供电
  49.   camera_config_t config;
  50.   config.ledc_channel = LEDC_CHANNEL_0;
  51.   config.ledc_timer = LEDC_TIMER_0;
  52.   config.pin_d0 = Y2_GPIO_NUM;
  53.   config.pin_d1 = Y3_GPIO_NUM;
  54.   config.pin_d2 = Y4_GPIO_NUM;
  55.   config.pin_d3 = Y5_GPIO_NUM;
  56.   config.pin_d4 = Y6_GPIO_NUM;
  57.   config.pin_d5 = Y7_GPIO_NUM;
  58.   config.pin_d6 = Y8_GPIO_NUM;
  59.   config.pin_d7 = Y9_GPIO_NUM;
  60.   config.pin_xclk = XCLK_GPIO_NUM;
  61.   config.pin_pclk = PCLK_GPIO_NUM;
  62.   config.pin_vsync = VSYNC_GPIO_NUM;
  63.   config.pin_href = HREF_GPIO_NUM;
  64.   config.pin_sccb_sda = SIOD_GPIO_NUM;
  65.   config.pin_sccb_scl = SIOC_GPIO_NUM;
  66.   config.pin_pwdn = PWDN_GPIO_NUM;
  67.   config.pin_reset = RESET_GPIO_NUM;
  68.   config.xclk_freq_hz = 20000000;
  69.   config.frame_size = FRAMESIZE_UXGA;
  70.   config.pixel_format = PIXFORMAT_JPEG; // for streaming
  71.   //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
  72.   config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
  73.   config.fb_location = CAMERA_FB_IN_PSRAM;
  74.   config.jpeg_quality = 12;
  75.   config.fb_count = 1;
  76.   
  77.   // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
  78.   //                      for larger pre-allocated frame buffer.
  79.   if(config.pixel_format == PIXFORMAT_JPEG){
  80.     if(psramFound()){
  81.       config.jpeg_quality = 10;
  82.       config.fb_count = 2;
  83.       config.grab_mode = CAMERA_GRAB_LATEST;
  84.     } else {
  85.       // Limit the frame size when PSRAM is not available
  86.       config.frame_size = FRAMESIZE_SVGA;
  87.       config.fb_location = CAMERA_FB_IN_DRAM;
  88.     }
  89.   } else {
  90.     // Best option for face detection/recognition
  91.     config.frame_size = FRAMESIZE_240X240;
  92. #if CONFIG_IDF_TARGET_ESP32S3
  93.     config.fb_count = 2;
  94. #endif
  95.   }
  96. #if defined(CAMERA_MODEL_ESP_EYE)
  97.   pinMode(13, INPUT_PULLUP);
  98.   pinMode(14, INPUT_PULLUP);
  99. #endif
  100.   // camera init
  101.   esp_err_t err = esp_camera_init(&config);
  102.   if (err != ESP_OK) {
  103.     Serial.printf("Camera init failed with error 0x%x", err);
  104.     return;
  105.   }
  106.   sensor_t * s = esp_camera_sensor_get();
  107.   // initial sensors are flipped vertically and colors are a bit saturated
  108.   if (s->id.PID == OV3660_PID) {
  109.     s->set_vflip(s, 1); // flip it back
  110.     s->set_brightness(s, 1); // up the brightness just a bit
  111.     s->set_saturation(s, -2); // lower the saturation
  112.   }
  113.   // drop down frame size for higher initial frame rate
  114.   if(config.pixel_format == PIXFORMAT_JPEG){
  115.     s->set_framesize(s, FRAMESIZE_QVGA);
  116.   }
  117. #if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
  118.   s->set_vflip(s, 1);
  119.   s->set_hmirror(s, 1);
  120. #endif
  121. #if defined(CAMERA_MODEL_ESP32S3_EYE)
  122.   s->set_vflip(s, 1);
  123. #endif
  124. // Setup LED FLash if LED pin is defined in camera_pins.h
  125. #if defined(LED_GPIO_NUM)
  126.   setupLedFlash(LED_GPIO_NUM);
  127. #endif
  128.   Serial.println("Connect to WiFi");
  129.   WiFi.begin(ssid, password);
  130.   WiFi.setSleep(false);
  131.   while (WiFi.status() != WL_CONNECTED) {
  132.     delay(500);
  133.     Serial.print(".");
  134.   }
  135.   Serial.println("");
  136.   Serial.println("WiFi connected");
  137.   startCameraServer();
  138.   Serial.print("Camera Ready! Use 'http://");
  139.   Serial.print(WiFi.localIP());
  140.   Serial.println("' to connect");
  141. }
  142. void loop() {
  143.   // Do nothing. Everything is done in another task by the web server
  144.   delay(10000);
  145. }
复制代码

4.修改上述程序中wifi的ssid、password,为您所在网络wifi的ssid与密码

  1. const char* ssid = "xiaogui";
  2. const char* password = "88888888";
复制代码



5.修改camera_pins.h文件,增加如下代码:

  1. #elif defined(CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3)
  2. #define PWDN_GPIO_NUM     -1
  3. #define RESET_GPIO_NUM    -1
  4. #define XCLK_GPIO_NUM     45
  5. #define SIOD_GPIO_NUM     1
  6. #define SIOC_GPIO_NUM     2
  7. #define Y9_GPIO_NUM       48
  8. #define Y8_GPIO_NUM       46
  9. #define Y7_GPIO_NUM       8
  10. #define Y6_GPIO_NUM       7
  11. #define Y5_GPIO_NUM       4
  12. #define Y4_GPIO_NUM       41
  13. #define Y3_GPIO_NUM       40
  14. #define Y2_GPIO_NUM       39
  15. #define VSYNC_GPIO_NUM    6
  16. #define HREF_GPIO_NUM     42
  17. #define PCLK_GPIO_NUM     5
复制代码

6.修改相应设置,如下图所示

基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图4


7.上传程序,等待上传完成。

基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图6



8.打开串口监视器,查看启动信息

基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图7

从串口监视器可看到:“Connect to WiFi”、“WiFi connected”、“Camera Ready! Use 'http://192.168.2.234' to connect”等信息,记住这个IP地址。通过这个IP地址就可以访问摄像头了。

9.OV2640设置
在浏览器中,输入刚才记住的IP地址,如192.168.2.234,即可打开设置页面。修改相应的选项,可以对摄像头进行设置。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图8


将网页垂直滑块向下拉,一直到网页的最底端。点击“start Stream”,即可打开视频浏览串口,位于页面最顶端。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图9




行空板编程】

1.将行空板通过 USB线连接到电脑。打开Mind+,选择Python模式,如下图所示。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图11


2.添加“行空板”库,如下图所示。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图12




3.拖到积木,完成编程,如下图所示。并修改192.168.2.234为刚才记住的IP地址。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图13


4.点击“连接远程终端”,选择“10.1.2.3”,如下图所示。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图14


5.点击“运行”,如下图所示。


基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图15



行空板的屏幕上显示DFRobot FireBeetle 2 ESP32-S3摄像头画面。按下A键,完成拍照,并保存。如下图所示



基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图17



基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图16




基于FireBeetle 2 ESP32-S3和行空板的无线图传相机图18



CameraWebServer.rar

52.84 KB, 下载次数: 2965

FireBeetle 2 ESP32-S3程序

打开摄像头2.rar

167.95 KB, 下载次数: 3001

行空板程序

rzyzzxw  版主

发表于 2023-9-9 07:31:14

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail