Problem with ESP32-cam, SD & FTP

Chuma87
Posts: 8
Joined: Sun Jan 26, 2020 6:34 pm

Problem with ESP32-cam, SD & FTP

Postby Chuma87 » Mon Feb 17, 2020 10:40 am

Is it possible that uploading a file to FTP takes a long time?

The test I am doing is ... With a doppler sensor, save the image to the SD, and after that, upload it to an FTP. If I only save in the SD, it works perfectly, if I add it to upload to FTP, it doesn't work any more by movement, only every 30 seconds. Why does this happen?

Code: Select all

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();
    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);
    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"); 

 
          
  }
Video Here

Who is online

Users browsing this forum: lbernstone and 63 guests