Das ist der Code zum Generieren der Fotos den ich derzeit versuche zum Laufen zu bekommen. Hier mal mit dem Beispiel von 3 anstelle von 5 Bildern in Folge.
// Foto 1
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Fotografieren fehlgeschlagen!");
return;
}
// Foto 1 unter diesem Pfad speichern
String path = "/Foto" + String(fotoNummer) + ".jpg";
fs::FS &fs = SD_MMC;
File file = fs.open(path.c_str(), FILE_WRITE);
if(!file) {
Serial.println("Fehler beim File erstellen");
}
else {
file.write(fb->buf, fb->len);
EEPROM.write(COUNT_ADDRESS, fotoNummer);
EEPROM.commit();
}
delay(2000);
file.close();
esp_camera_fb_return(fb);
// Foto 2
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Fotografieren fehlgeschlagen!");
return;
}
// Foto 2 unter diesem Pfad speichern
String path = "/Foto" + String(fotoNummer) + ".jpg";
fs::FS &fs = SD_MMC;
File file = fs.open(path.c_str(), FILE_WRITE);
if(!file) {
Serial.println("Fehler beim File erstellen");
}
else {
file.write(fb->buf, fb->len);
EEPROM.write(COUNT_ADDRESS, fotoNummer);
EEPROM.commit();
}
delay(2000);
file.close();
esp_camera_fb_return(fb);
// Foto 3
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Fotografieren fehlgeschlagen!");
return;
}
// Foto 3 unter diesem Pfad speichern
String path = "/Foto" + String(fotoNummer) + ".jpg";
fs::FS &fs = SD_MMC;
File file = fs.open(path.c_str(), FILE_WRITE);
if(!file) {
Serial.println("Fehler beim File erstellen");
}
else {
file.write(fb->buf, fb->len);
EEPROM.write(COUNT_ADDRESS, fotoNummer);
EEPROM.commit();
}
delay(1000);
file.close();
esp_camera_fb_return(fb);
Serial.printf("Fotos gespeichert: %s\n", path.c_str());
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
rtc_gpio_hold_en(GPIO_NUM_4);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_13,0);
delay(1000);
Serial.println("Gehe in den deep-sleep mode");
esp_deep_sleep_start();
}
So hatte ich gedacht könnte es funktionieren. Allerdings bringt er mir dann folgenden Fehlercode:
FEHLERCODE
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino: In function 'void setup()':
The_Code-WildCam:127:10: error: redeclaration of 'String path'
String path = "/Foto" + String(fotoNummer) + ".jpg";
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino:102:10: note: 'String path' previously declared here
String path = "/Foto" + String(fotoNummer) + ".jpg";
The_Code-WildCam:128:11: error: redeclaration of 'fs::FS& fs'
fs::FS &fs = SD_MMC;
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino:103:11: note: 'fs::FS& fs' previously declared here
fs::FS &fs = SD_MMC;
The_Code-WildCam:130:8: error: redeclaration of 'fs::File file'
File file = fs.open(path.c_str(), FILE_WRITE);
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino:105:8: note: 'fs::File file' previously declared here
File file = fs.open(path.c_str(), FILE_WRITE);
The_Code-WildCam:152:10: error: redeclaration of 'String path'
String path = "/Foto" + String(fotoNummer) + ".jpg";
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino:102:10: note: 'String path' previously declared here
String path = "/Foto" + String(fotoNummer) + ".jpg";
The_Code-WildCam:153:11: error: redeclaration of 'fs::FS& fs'
fs::FS &fs = SD_MMC;
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino:103:11: note: 'fs::FS& fs' previously declared here
fs::FS &fs = SD_MMC;
The_Code-WildCam:155:8: error: redeclaration of 'fs::File file'
File file = fs.open(path.c_str(), FILE_WRITE);
/Users/jbs/Documents/The_Code-WildCam/The_Code-WildCam.ino:105:8: note: 'fs::File file' previously declared here
File file = fs.open(path.c_str(), FILE_WRITE);
exit status 1
redeclaration of 'String path'
Bin wie gesagt kein Coder, daher weiß ich damit recht wenig anzufangen. Wahrscheinlich ein schlichter Anfängerfehler....