Buenas..
Es posible que el subir una foto al FTP demore mucho? Entre 15 a 30 segundos?
Lo que intento hacer es que la esp32cam saque una foto, guarde en la SD y suba al FTP. Recibe una frecuencia por el GPIO_13, para convertirla a velocidad, con eso controla si excede la maxima y saca la foto.
El problema es que saca fotos cada 30 segundos, todo el tiempo. No es que lo hace por el sensor. Si elimino las 10 lineas de codigo de FTP, funciona perfectamente.
Abajo dejo el codigo y en negrita las lineas de FTP, y mas abajo, el video.
if (ex > 20) {
// Init Camera
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
Serial.println("Starting SD Card");
delay(500);
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 nombre = "picture" + String(pictureNumber) + "_" + String(ex) + "kmh.jpg";
String path = "/" + nombre;
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();
[b] WiFi.begin( WIFI_SSID, WIFI_PASS );
Serial.println("Connecting Wifi...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
ftp.OpenConnection();
// Create the new file and send the image
ftp.ChangeWorkDir("/public_html/FOTOMULTA/");
const char *web_nombre = nombre.c_str();
ftp.InitFile("Type I");
ftp.NewFile(web_nombre);
ftp.WriteData(fb->buf, fb->len);
ftp.CloseFile();
ftp.CloseConnection();
delay(100);[/b]
esp_camera_fb_return(fb);
delay(300);
// 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);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_13, 0);
Serial.println("Going to sleep now");
delay(300);
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
Si ustedes me confirman que el FTP demora un buen tiempo, me podrian explicar como hacer para que en una hora determinada, recupere las fotos guardadas en la SD y las suba todas?
Gracias