ESP32 WROVER - Lack of Photo Memory

MicheliBarcello
Posts: 6
Joined: Tue Apr 05, 2022 5:28 pm

ESP32 WROVER - Lack of Photo Memory

Postby MicheliBarcello » Wed Jun 07, 2023 5:49 pm

Good afternoon everyone, how are you?

I'm using an ESP32 WROVER

I just need to put it on the network and take a picture (good quality)
In the description it says that the card has 4mb flash memory, but when I go to record it appears as follows Flash: [====== ] 64.5% (used 845098 bytes from 1310720 bytes) that is, it has only 1.3mb

A high resolution photo needs 1mb, but as it has no memory, it gives an error.

Follow my program

Code: Select all

#include <WiFi.h>
#include <ESP_WiFiManager.h>
#include <esp_camera.h>
#include <WiFiServer.h>

const char* ssid = "ESP_Laser";
const char* password = "Laser123";

WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);

  ESP_WiFiManager WiFiManager;
  WiFiManager.setConfigPortalTimeout(240);

  if (!WiFiManager.autoConnect(ssid, password)) {
    Serial.println("Falha na conexao. Resetar e tentar novamente...");
    delay(3000);
    ESP.restart();
    delay(5000);
  }

  Serial.println("Conectado na rede WiFi.");
  Serial.print("Endereco IP: ");
  Serial.println(WiFi.localIP());

  camera_config_t config;

  config.pin_pwdn = -1;
  config.pin_reset = -1;  
  config.pin_xclk = 21;
  config.pin_sscb_sda = 26;
  config.pin_sscb_scl = 27;

  config.pin_d7 = 35;
  config.pin_d6 = 34;
  config.pin_d5 = 39;
  config.pin_d4 = 36;
  config.pin_d3 = 19;
  config.pin_d2 = 18;
  config.pin_d1 = 5;
  config.pin_d0 = 4;
  
  config.pin_vsync = 25;
  config.pin_href = 23;
  config.pin_pclk = 22;

  config.xclk_freq_hz = 20000000;
  config.ledc_timer = LEDC_TIMER_0;
  config.ledc_channel = LEDC_CHANNEL_0;
  
  config.pixel_format = PIXFORMAT_JPEG;
  config.frame_size = FRAMESIZE_UXGA;

  config.jpeg_quality = 10;
  config.fb_count = 2;

  esp_err_t cameraInitError = esp_camera_init(&config);
  if (cameraInitError != ESP_OK) {
    Serial.printf("Falha na inicialização da câmera! (erro 0x%x)\n", cameraInitError);
    return;
  }

  server.begin();
  Serial.println("Servidor iniciado.");

}

void loop() {
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  Serial.println("Novo cliente conectado.");

  camera_fb_t* fb = esp_camera_fb_get();
  if (!fb) {
    client.println("HTTP/1.1 500 Internal Server Error");
    client.println("Content-type:text/html");
    client.println();
    client.println("<html><body><h1>Erro ao capturar imagem</h1></body></html>");
    delay(1);
    client.stop();
    return;
  }

  client.println("HTTP/1.1 200 OK");
  client.println("Content-type:image/jpeg");
  client.println("Connection: close");
  client.println();
  client.write(fb->buf, fb->len);
  esp_camera_fb_return(fb);

  delay(1);
  client.stop();
}
I was disappointed because I thought that this board would be able to take only 1 photo in good resolution. Is there still a way to do this? or would I need to buy the card that comes with space to put a memory card?
Thanks

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 WROVER - Lack of Photo Memory

Postby ESP_Sprite » Thu Jun 08, 2023 4:42 am

You probably need to look into a custom partition table.

MicroController
Posts: 1688
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 WROVER - Lack of Photo Memory

Postby MicroController » Thu Jun 08, 2023 10:44 am

It seems you actually don't want to store an image to flash but just capture it and send it over HTTP.
If that's accurate, the amount of flash memory does not matter but rather the amount of RAM you have.
The 320KB of internal RAM of the ESP32 won't get you anywhere close to holding a full frame at good resolution, so you'll have to use the WROVER's external PSRAM, for which enabling PSRAM in menuconfig may already be sufficient.

MicheliBarcello
Posts: 6
Joined: Tue Apr 05, 2022 5:28 pm

Re: ESP32 WROVER - Lack of Photo Memory

Postby MicheliBarcello » Thu Jun 08, 2023 6:19 pm

I managed to change the card, it was 4mb of flash.
I would like to know if there is a way to send the photo to the clipboard, that is, I access the ESP IP, it takes the photo and sends it to the clipbord, so I would just open the image editing program and give control + V?

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP32 WROVER - Lack of Photo Memory

Postby corz.org » Fri Jun 09, 2023 12:18 am

Add:

Code: Select all

config.fb_location = CAMERA_FB_IN_PSRAM;
Assuming PSRAM is enabled at compile-time.

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP32 WROVER - Lack of Photo Memory

Postby corz.org » Fri Jun 09, 2023 1:02 am

MicheliBarcello wrote:
Thu Jun 08, 2023 6:19 pm
I managed to change the card, it was 4mb of flash.
I would like to know if there is a way to send the photo to the clipboard, that is, I access the ESP IP, it takes the photo and sends it to the clipbord, so I would just open the image editing program and give control + V?

You could write a small HTML container page with some JavaScript to grab the image and pop it in your clipboard. Serve this page up with the ESP32 webserver.

MicheliBarcello
Posts: 6
Joined: Tue Apr 05, 2022 5:28 pm

Re: ESP32 WROVER - Lack of Photo Memory

Postby MicheliBarcello » Sat Jun 10, 2023 11:57 pm

corz.org wrote:
Fri Jun 09, 2023 1:02 am
MicheliBarcello wrote:
Thu Jun 08, 2023 6:19 pm
I managed to change the card, it was 4mb of flash.
I would like to know if there is a way to send the photo to the clipboard, that is, I access the ESP IP, it takes the photo and sends it to the clipbord, so I would just open the image editing program and give control + V?

You could write a small HTML container page with some JavaScript to grab the image and pop it in your clipboard. Serve this page up with the ESP32 webserver.
can you teach me how to do this?

Who is online

Users browsing this forum: Bing [Bot] and 130 guests