Hey Leute,
folgender Funktion ruf ich auf und funktioniert genau 1x. Danach bekomme ich einen Fehler "sdmmc_sd: sdmmc_check_scr: send_scr returned" also -> SD Card Mount Failed
Die anderen Beispiele im Netz machen das meist so, dass sie den ESP in deep sleep schicken und beim betätigen einer Taste wieder aufwecken -> dadurch wird der Code im setup ausgeführt und ein Foto wird gemacht...
Steh ich aufn Schlauch? Kann ich SD_MMC nicht einfach neu initialisieren pro Funktionsaufruf?
void takePhoto(){
delay(500);
//Serial.println("Starting SD Card");
if(!SD_MMC.begin()){
Serial.println("SD Card Mount Failed");
return;
}
uint8_t cardType = SD_MMC.cardType();
if(cardType == CARD_NONE){
Serial.println("No SD Card attached");
return;
}
camera_fb_t * fb = NULL;
// Take Picture with Camera
fb = esp_camera_fb_get();
if(!fb) {
Serial.println("Camera capture failed");
return;
}
// initialize EEPROM with predefined size
EEPROM.begin(EEPROM_SIZE);
pictureNumber = EEPROM.read(0) + 1;
// Path where new picture will be saved in SD Card
String path = "/picture" + String(pictureNumber) +".jpg";
fs::FS &fs = SD_MMC;
Serial.printf("Picture file name: %s\n", path.c_str());
File file = fs.open(path.c_str(), FILE_WRITE);
if(!file){
Serial.println("Failed to open file in writing mode");
}
else {
file.write(fb->buf, fb->len); // payload (image), payload length
Serial.printf("Saved file to path: %s\n", path.c_str());
EEPROM.write(0, pictureNumber);
EEPROM.commit();
}
file.close();
esp_camera_fb_return(fb);
SD_MMC.end();
fb=NULL;
// Turns off the ESP32-CAM white on-board LED (flash) connected to GPIO 4
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
rtc_gpio_hold_en(GPIO_NUM_4);
delay(2000);
}
Grüße