_深蓝_ 发表于 2023-9-6 12:12:45

FireBeetle 2 ESP32-S3初体验之教师投影辅助神器

本帖最后由 _深蓝_ 于 2023-9-6 12:12 编辑

一、项目背景    在各位老师教学过程当中经常会碰到一个问题,需要将学生的书写的答案投影到屏幕上面,而现在的大多数白板软件都有这样的功能,需要下载对应的app并连接与触摸一体机组成的局域网中,然后手机拍摄图片或视频上传到大屏电脑上,这样存着以下问题,上课必须要带手机;每次需要手动拍摄;经常由于手机的信息而打断上课的节奏;有没有一个专门的工具让老师带着,他可以将图传到我们的屏幕上去呢?答案是肯定的。近期有幸获得FireBeetle 2 ESP32-S3的试用机会,特使用FireBeetle 2 ESP32-S3主控板制作教师投影辅助神器。https://ws.dfrobot.com.cn/FjT3K9mjN2g8wh_8pkccM7zScAxh

二、项目思路1、使用Arduino 1.8.19编程。2、Arduino环境配置。3、编程以及图传的实现。由于FireBeetle 2 ESP32-S3板载摄像头接口,附带了一个OV2640摄像头,可以直接使用该摄像头,如何把图像投屏呢,使用web服务器把拍摄的图像上传,可以看到实时图像。4、制作一个便于携带的盒子,简单、易用。以下是制作该项目的思维导图三、制作步骤1、Arduino环境配置配置URL网址到Arduino IDE,具体步骤:a)    打开Arduino IDE,点击File->Preferences,http://imgtest.dfrobot.com.cn/DFRobotCnWikiImage/ESP32-1.pnghttps://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/ac759f8fa7dbbe060629f605d1fee569.pnghttps://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/30194f4c55b35fac49b7b56d2c3da661.png
b)    在新打开的界面中,点击红色圆圈中的按钮,将如下链接地址复制到新弹出的对话框中:https://raw.githubusercontent.co ... ge_esp32_index.json。如果您之前安装过其它的环境,那么您可以在上一个链接地址开头或末尾处直接回车并将上面链接粘贴在其上下任意一行http://imgtest.dfrobot.com.cn/DFRobotCnWikiImage/ESP32-5.png
c)   打开Tools->Board:->Boards Manager...,BoardsManager会自动更新板卡,   更新完成后,您可以在上方输入esp32,出现如下情况时选择esp32点击安装即可(建议安装最新版本)http://imgtest.dfrobot.com.cn/DFRobotCnWikiImage/ESP32-6.pnghttps://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/78fa38f61eb45a8cb8ca20ff1755cdda.pnghttps://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/b3c2b3e4144ab0529b49e8375699ef4e.pngd)    等待进度条结束,列表会显示已经安装esp32主板,点击Tools->Board:,选择DFRobot FireBeetle 2 ESP32-S3,点击Port选择对应的串口
https://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/3935a04548347b7dde5048aa6322fde0.png
https://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/d9ea35017da12f9638c3d261d03a405f.png
https://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/c69cf7111eb4bf1165bfbd6237e677b1.png
截止目前,Arduino环境配置已经完成,如果需要串口通信,需要进行以下操作:(当您选择 Disabled 时,串口为RX(44)、TX(43),如果您需要通过USB在Arduino监视器上打印,您需要选择Enable)
https://img.dfrobot.com.cn/wiki/5d57611a3416442fa39bffca/414feb6647e12c93c55c634840a00c55.png
在这里踩了坑,由于没有打开串口通信,看不到web地址,傻傻的问群里的老师们,是不是串口没有数据还是程序出现了错误。
环境配置完后可以编写程序了,我呢,首先从例程开始学习,网址为https://wiki.dfrobot.com.cn/_SKU ... le_2_Board_ESP32_S3
这里有FireBeetle-ESP32-S3简介、硬件详情、基础教程等,初学小白可以看看这里。

2、编写代码

注意使用您家或者单位局域网中的无线连接,便于调试。


点击验证、上传,将程序烧录到主板上,并打开工具-》串口监视器(或按快捷键ctrl+shift+M)

打开网页192.168.97.90即可打开视频的设置界面,确认设置后可以打开视频。


拔下与电脑的接线到学生教室后给该板供电,稍等一会即可在浏览器打开视频界面。
3、外观设计
很简单的外观,使用订书钉的盒子,将板子粘贴到盒子内部,天线固定盒外,摄像头固定在盒子上


四、效果展示
拍摄电脑画面清晰,有深邃的感脚。


拍摄墙壁上五笔字根图与打卡


拍摄教案的情景,完全可以满足授课时使用。

五、附件
使用摄像头的C代码如下:
#include "esp_camera.h"
#include <WiFi.h>

//
// WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
//            Ensure ESP32 Wrover Module or other board with PSRAM is selected
//            Partial images will be transmitted if image exceeds buffer size
//
//            You must select partition scheme from the board menu that has at least 3MB APP space.
//            Face Recognition is DISABLED for ESP32 and ESP32-S2, because it takes up from 15
//            seconds to process single frame. Face Detection is ENABLED if PSRAM is enabled as well

// ===================
// Select camera model
// ===================
#define PWDN_GPIO_NUM   -1
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM   45
#define SIOD_GPIO_NUM   1
#define SIOC_GPIO_NUM   2

#define Y9_GPIO_NUM       48
#define Y8_GPIO_NUM       46
#define Y7_GPIO_NUM       8
#define Y6_GPIO_NUM       7
#define Y5_GPIO_NUM       4
#define Y4_GPIO_NUM       41
#define Y3_GPIO_NUM       40
#define Y2_GPIO_NUM       39
#define VSYNC_GPIO_NUM    6
#define HREF_GPIO_NUM   42
#define PCLK_GPIO_NUM   5

#include "DFRobot_AXP313A.h"

DFRobot_AXP313A axp;

// ===========================
// Enter your WiFi credentials
// ===========================
const char* ssid = "HHZX";
const char* password = "123456789";

void startCameraServer();

void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println("waiting...");
while(axp.begin() != 0){
    Serial.println("init error");
    delay(1000);
}
axp.enableCameraPower(axp.eOV2640);//设置摄像头供电
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
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_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size = FRAMESIZE_UXGA;
config.pixel_format = PIXFORMAT_JPEG; // for streaming
//config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
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(config.pixel_format == PIXFORMAT_JPEG){
    if(psramFound()){
      config.jpeg_quality = 10;
      config.fb_count = 2;
      config.grab_mode = CAMERA_GRAB_LATEST;
    } else {
      // Limit the frame size when PSRAM is not available
      config.frame_size = FRAMESIZE_SVGA;
      config.fb_location = CAMERA_FB_IN_DRAM;
    }
} else {
    // Best option for face detection/recognition
    config.frame_size = FRAMESIZE_240X240;
#if CONFIG_IDF_TARGET_ESP32S3
    config.fb_count = 2;
#endif
}

#if defined(CAMERA_MODEL_ESP_EYE)
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
#endif

// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
}

sensor_t * s = esp_camera_sensor_get();
// initial sensors are flipped vertically and colors are a bit saturated
if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1); // flip it back
    s->set_brightness(s, 1); // up the brightness just a bit
    s->set_saturation(s, -2); // lower the saturation
}
// drop down frame size for higher initial frame rate
if(config.pixel_format == PIXFORMAT_JPEG){
    s->set_framesize(s, FRAMESIZE_QVGA);
}

#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
s->set_vflip(s, 1);
s->set_hmirror(s, 1);
#endif

#if defined(CAMERA_MODEL_ESP32S3_EYE)
s->set_vflip(s, 1);
#endif

WiFi.begin(ssid, password);
WiFi.setSleep(false);

while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

startCameraServer();

Serial.print("Camera Ready! Use 'http://");
Serial.print(WiFi.localIP());
Serial.println("' to connect");
}

void loop() {
// Do nothing. Everything is done in another task by the web server
delay(10000);
}



页: [1]
查看完整版本: FireBeetle 2 ESP32-S3初体验之教师投影辅助神器