ESP32-Cam. It takes photo data even if the camera pins are out

Hi all,

My project is like this, when the button is pressed, it takes a photo at that moment. And I am sending it over tcp. My point is this:

I take pictures with the pins of the camera attached, there is no problem normally, it works fine and sends. I take a photo after removing the pins of the camera, the system pretends to take a photo and sends and receives information from somewhere, but this is wrong. Then, when I take a photo with the pins out for the second time, it gives an error that the pins are not inserted. I can't get this error when I was supposed to get it the first time.

My opinion; After taking a photo, it informs the system that the pins are ready, next time you can take a photo.

fb = esp_camera_fb_get();
esp_camera_fb_return(fb);

I think it has to do with these functions.

I clean inside fb, inside buf and len, but from here the camera pulls the literal. How can I do this in a controlled way?

Every time I call the CameraVideo function, I take a picture and send it. Here I want to check the camera pins before taking every photo how can I do it?

Thanks all.


void cameraVideo()                                         
{
  size_t _jpg_buf_len = 0;
  uint8_t * _jpg_buf = NULL;

  int m = 0;
  count = 0;
  bool ok = 0;                                             
  camera_fb_t *fb = 0;                                 

  while (m < 1) {
    do {

      m++;
      fb = esp_camera_fb_get();                              
      if (!fb) {                                             
        Serial.println("Camera capture failed");
        ESP.restart();
        return;
      }
      // Photo file name
      Serial.printf("Picture file name: %s\n", FILE_PHOTO);  
      File file = SPIFFS.open(FILE_PHOTO, FILE_WRITE);       

      // Insert the data in the photo file
      if (!file) { 
        Serial.println("Failed to open file in writing mode");
      }
      else {                                                
        _jpg_buf_len = fb->len;
        _jpg_buf = fb->buf;

        file.write(_jpg_buf, _jpg_buf_len);                 
        Serial.print("The picture has been saved in ");
        Serial.print(FILE_PHOTO);
      }
      // Close the file
      file.close();               

      ok = checkPhoto(SPIFFS);    
      if (fb) {
        esp_camera_fb_return(fb);
        fb = NULL;
        _jpg_buf = NULL;
      } else if (_jpg_buf) {
        free(_jpg_buf);
        _jpg_buf = NULL;
      }
      free(fb);
    } while (!ok);               

    photostatusPackage(SPIFFS);   
              
    dirCheck2(SPIFFS);

  }
}

What pins?

pins where the camera connects to esp32

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

If you get errors when compiling please copy them from the IDE using the "Copy error messages" button and paste the clipboard here in code tags

Where is the esp_camera_fb(return(fb) instruction?

So under normal operations you'll be inserting and removing the camera, why?

You'll have to write code to detect the removal and insertion of the actual camera. good luck.

ESP32-cam will be used on a project and there is a possibility that the pins may be dislodged due to vibration, so the pins need to be checked.

You can dig into the web cams various libraries to see where the cam is checked for proper connection and use those features to do the thing.

good luck.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.