ESP32-CAM - SPIFF - Mail

Bonjour

Je ne comprends pourquoi ce ino fonctionne et un moment apres pas !!!

Log Good

15:57:31.707 -> 
15:57:31.707 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:57:31.707 -> configsip: 0, SPIWP:0xee
15:57:31.707 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:57:31.707 -> mode:DIO, clock div:1
15:57:31.707 -> load:0x3fff0018,len:4
15:57:31.707 -> load:0x3fff001c,len:1216
15:57:31.707 -> ho 0 tail 12 room 4
15:57:31.707 -> load:0x40078000,len:9720
15:57:31.741 -> ho 0 tail 12 room 4
15:57:31.741 -> load:0x40080400,len:6352
15:57:31.741 -> entry 0x400806b8
15:57:33.501 -> 
15:57:33.501 -> Booting...
15:57:33.571 -> SPIFFS ok 
15:57:33.571 -> Delete picture.jpg 
15:57:33.672 -> SPIFFS.dir passed 
15:57:33.672 -> Connecting to AP.
15:57:33.878 -> WiFi connected.
15:57:33.878 -> IP address: 
15:57:33.912 -> 192.168.1.54
15:57:33.912 -> 
15:57:33.912 -> OTA start Sillage
15:57:33.912 -> ArduinoOTA.setHostname Sillage-94b088
15:57:33.912 -> OTA Initialized
15:57:34.724 -> Taking a picture ...
15:57:34.894 -> Picture file name: /picture.jpg
15:57:34.894 -> Size of image:148648
15:57:34.894 -> Shape->width:1600height:1200
15:57:36.015 -> The picture has been saved in /picture.jpg - Size: 148608 bytes
15:57:36.015 -> Sending email...
15:57:36.015 -> Connecting to SMTP server...
15:57:42.043 -> Identification...
15:57:42.145 -> Authentication...
15:57:42.178 -> Sign in...
15:57:42.553 -> Sending Email header...
15:57:42.587 -> Sending Email body...
15:57:42.857 -> Sending attachments...
15:57:42.857 -> /picture.jpg
15:58:13.612 -> Finalize...
15:58:15.004 -> Finished
15:58:15.004 -> Email sent successfully
15:58:15.004 -> ----------------
15:58:15.004 -> Entering deep sleep mode
15:58:15.004 -> GPIO_NUM_13 = 1
15:58:15.004 -> Wakeup caused by external signal using RTC_IO
15:58:30.028 -> delay(10000)

Log Bad

15:56:06.384 -> 
15:56:06.384 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:56:06.384 -> configsip: 0, SPIWP:0xee
15:56:06.384 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:56:06.384 -> mode:DIO, clock div:1
15:56:06.384 -> load:0x3fff0018,len:4
15:56:06.384 -> load:0x3fff001c,len:1216
15:56:06.384 -> ho 0 tail 12 room 4
15:56:06.384 -> load:0x40078000,len:9720
15:56:06.384 -> ho 0 tail 12 room 4
15:56:06.418 -> load:0x40080400,len:6352
15:56:06.418 -> entry 0x400806b8
15:56:08.160 -> 
15:56:08.160 -> Booting...
15:56:08.228 -> SPIFFS ok 
15:56:08.262 -> Delete picture.jpg 
15:56:08.329 -> SPIFFS.dir passed 
15:56:08.329 -> Connecting to AP..
15:56:08.773 -> WiFi connected.
15:56:08.773 -> IP address: 
15:56:08.773 -> 192.168.1.54
15:56:08.773 -> 
15:56:08.773 -> OTA start Sillage
15:56:08.773 -> ArduinoOTA.setHostname Sillage-94b088
15:56:08.773 -> OTA Initialized
15:56:09.587 -> Taking a picture ...
15:56:09.964 -> Picture file name: /picture.jpg
15:56:09.964 -> Size of image:326938
15:56:09.964 -> Shape->width:1600height:1200
15:56:10.855 -> The picture has been saved in /picture.jpg - Size: 0 bytes
15:56:10.855 -> Sending email...
15:56:10.855 -> Connecting to SMTP server...
15:56:16.964 -> Identification...
15:56:16.964 -> Authentication...
15:56:16.998 -> Sign in...
15:56:17.477 -> Sending Email header...
15:56:17.782 -> Sending Email body...
15:56:18.023 -> Sending attachments...
15:56:18.023 -> /picture.jpg
15:56:18.023 -> Finalize...
15:56:18.704 -> Finished
15:56:18.704 -> Email sent successfully
15:56:18.704 -> ----------------
15:56:18.704 -> Entering deep sleep mode
15:56:18.704 -> GPIO_NUM_13 = 0
15:56:18.704 -> Wakeup caused by external signal using RTC_IO
15:56:33.687 -> delay(10000)

Size of image:148648 <> Size of image:326938

Pouquoi ???

Merci

extrait de code

#define CAMERA_MODEL_AI_THINKER

#define FILE_PHOTO "/picture.jpg"

bool checkPhoto( fs::FS & fs ) {
  File f_pic = fs.open( FILE_PHOTO );
  unsigned int pic_sz = f_pic.size();
  return ( pic_sz > 100 );
}
................
/***********************   SPIFFS **********************/
  if (!SPIFFS.begin())
  {
    Serial.println("Erreur SPIFFS...");
    return;
  }
  Serial.println("SPIFFS ok ");

  //---------------------------------------------------- delete /picture.jpg
  if (SPIFFS.remove("/picture.jpg")){
    Serial.println("Delete picture.jpg ");
  } else {
    Serial.println("Delete picture.jpg Erreur");
  }
  
  File SPIFF_root = SPIFFS.open("/", "r");
  File SPIFF_file = SPIFF_root.openNextFile();
  Serial.println("SPIFFS.dir passed ");
  while (SPIFF_file) {
    Serial.print("FILE: ");
    Serial.print(SPIFF_file.name());
    Serial.print(" - Size: ");
    Serial.print(SPIFF_file.size());
    Serial.println(" bytes");
    SPIFF_file = SPIFF_root.openNextFile();
  }

 //init with high specs to pre-allocate larger buffers
  if (psramFound())
  {
    config.frame_size = FRAMESIZE_UXGA;
    config.jpeg_quality = 10;
    config.fb_count = 2;
  } else
  {
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 12;
    config.fb_count = 1;
  }
..................
 //---------------------------------------------------- camera capture to SPIFFS
  Serial.println("Taking a picture ...");
  camera_fb_t * fb = NULL;
  //obtain camera frame buffer
  fb = esp_camera_fb_get();
  if (!fb)
  {
    Serial.println("Camera capture failed");
    Serial.println("Exiting now");
    while (1);  //wait here as something is not right
  }
  Serial.printf("Picture file name: %s\n", FILE_PHOTO);
  Serial.print("Size of image:");
  Serial.println(fb->len);
  Serial.print("Shape->width:");
  Serial.print(fb->width);
  Serial.print("height:");
  Serial.println(fb->height);

  //create new file
  File file = SPIFFS.open(FILE_PHOTO, FILE_WRITE);
  if (!file)
  {
    Serial.println("Failed to create file");
    Serial.println("Exiting now");
    while (1);  //wait here as something is not right
  }
  else
  {
    file.write(fb->buf, fb->len); // payload (image), payload length
    Serial.print("The picture has been saved in ");
    Serial.print(FILE_PHOTO);
    Serial.print(" - Size: ");
    Serial.print(file.size());
    Serial.println(" bytes");
  }
  file.close();
..........
  //return camera frame buffer
  esp_camera_fb_return(fb);

  //Set the storage types to read the attach files (SPIFF is default)
  smtpData.addAttachFile("/picture.jpg", "image/jpeg");

  // Set the storage type to attach files in your email (SPIFFS)
  smtpData.setFileStorageType(MailClientStorageType::SPIFFS);

force to

config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = 12; config.fb_count = 1;