buenas tardes, primero quisiera presentarme, soy muy novato, tanto en Arduino como en este foro, por lo que si cometo algún error, ruego me disculpen y me ayuden a ir aprendiendo y mejorando, por ello doy las gracias de corazón a todos los que aportan su conocimiento para que los novatos podamos ir creciendo.
el tema es el siguiente:
Tengo una IA Thinker ESP32 CAM, el proyecto que tengo entre manos es grabar videos en la tarjeta micro sd que incorpora esta placa, al mismo tiempo a través de wifi ver las imágenes en tiempo real en un móvil.
he utilizado el Github Copilot para hacer el código, en un principio me ha proporcionado uno que se ha compilado bien, pero el monitor serial termina diciendo que la tarjeta sd falla, evidentemente hay algo que no estoy haciendo bien, he buscado en el foro y no encuentro ninguna entrada que me pueda ayudar, por eso inicio este hilo, estoy utilizando una tarjeta de 64 Gb, el código que me ha proporcionado el copilot es el siguiente:
#include "esp_camera.h"
#include "FS.h"
#include "SD_MMC.h"
#include <WiFi.h>
#include <WebServer.h>
// Replace with your network
const char* ssid = " mi SSID";
const char* password = "mi password";
// Camera settings
#define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"
// Web server
WebServer server(80);
void startCameraServer();
void setup() {
Serial.begin(115200);
// Initialize the camera
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.pin_xclk = XCLK_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 10;
config.fb_count = 2;
// Camera init
if (esp_camera_init(&config) != ESP_OK) {
Serial.println("Camera init failed");
return;
}
// Initialize SD card
if (!SD_MMC.begin()) {
Serial.println("SD Card Mount Failed");
return;
}
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Start the camera server
startCameraServer();
}
void loop() {
// Handle web server
server.handleClient();
}
void startCameraServer() {
server.on("/", HTTP_GET, []() {
server.send(200, "text/plain", "ESP32-CAM Video Streaming");
});
server.on("/capture", HTTP_GET, []() {
camera_fb_t * fb = esp_camera_fb_get();
if (!fb) {
server.send(500, "text/plain", "Camera capture failed");
return;
}
File file = SD_MMC.open("/capture.jpg", FILE_WRITE);
if (!file) {
server.send(500, "text/plain", "Failed to open file in writing mode");
return;
}
file.write(fb->buf, fb->len);
file.close();
esp_camera_fb_return(fb);
server.send(200, "text/plain", "Capture saved to SD card");
});
server.on("/stream", HTTP_GET, []() {
server.sendHeader("Access-Control-Allow-Origin", "*");
server.sendHeader("Content-Type", "multipart/x-mixed-replace; boundary=frame");
while (true) {
camera_fb_t * fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
continue;
}
server.sendContent("--frame\r\n");
server.sendContent("Content-Type: image/jpeg\r\n\r\n");
server.sendContent((const char *)fb->buf, fb->len);
server.sendContent("\r\n");
esp_camera_fb_return(fb);
if (server.client().available() == 0) break;
}
});
server.begin();
}
y el mensaje que da el serial monitor es:
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
E (721) vfs_fat_sdmmc: mount_to_vfs failed (0xffffffff).
SD Card Mount Failed
no sé si será suficiente información, muchas gracias por su apoyo.
