• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 camera.c:1249] esp_camera_init(): Camera probe failed with error 0x20004

Q&A Forum › ESP32 camera.c:1249] esp_camera_init(): Camera probe failed with error 0x20004
0 Vote Up Vote Down
Zulis Widiyantoro asked 7 months ago

Dear Mr. Rui and Sara Santos
Please help,
I buy your book ESP32 Cam, I download your source code Modul 1 CameraWebServer. after input SSID then complie and download success, after reset at output serial come out error “ESP32 camera.c:1249] esp_camera_init(): Camera probe failed with error 0x20004”
Please help what is the problem my trial?
Thank you

13 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 7 months ago

Hi.

Sometimes, resetting the ESP32-CAM several times solves the problem.

What is the ESP32-CAM model you’re using? If you’re using a different board, you need to change the pin assignment.

Additionally, it might be one of the following issues:

    • Not enough power through USB source
      If you’re powering your ESP32 through a USB port on your computer, it might not be supplying enough power.
    • Faulty FTDI programmer
      Some readers also reported this problem was solved by replacing their actual FTDI programmer with this one.
    • The camera/connector is broken
      If you get this error, it might also mean that your camera or the camera ribbon is broken. If that is the case, you may get a new OV2640 camera probe.

Additionally, if you have the ESP32-CAM connected to your computer using an FTDI programmer, make sure you’re powering the board using the 5V pin.

I hope this helps.

Regards,
Sara

0 Vote Up Vote Down
EDUARDO ALCOFORADO answered 4 months ago

I’m having this same problem here. The things were going well with my two ESP32-CAM modules, but now when I upload the code and open it on the Serial Monitor of Arduino IDE, I get this error messge.
 
I tryed the solutions above, but none of then changed the situation.
I Believe that is something relted to the configurations because I disn’t change anything in the code.

0 Vote Up Vote Down
Sara Santos Staff answered 4 months ago

Hi Eduardo.
What code are you trying to run in your ESP32-CAM?
Can you share it?
To share your code use a link to github, pastebin, etc…
Regards,
Sara

0 Vote Up Vote Down
David Kosewick answered 4 months ago

Hi There,
Tonight I saw this same issue with a TTGO-Camera board. It is loaded with the code to send an email after PIR detects motion. (Module 3 Unit 2 in Cam course) The camera pin defines I used are right off the package the TTGO came in, and I updated the on board PIR to pin 33, OR SO I THOUGHT! In fact, I had neglected to update the pin # and it was set to the incorrect (for TTGO board) GPIO 13. After correcting and uploading, all seems good.
It is amazing that this handles gmail so well! And, gmail just adds subsequent picture attachments to the same conversation thread.  So far it has been running flawlessly for about 20 minutes, and has sent 6 pictures when triggered.
Very useful project, and now that I have defined the pins properly, no more errors. Apparently the output of the PIR interferes with the camera initialization during wake up. Because even with the incorrect pin defined, the camera would send one picture after hard reset and go to sleep normally. The error appeared during wake up.
Thanks for a great project. Now to see how long my battery will last, then deploy it!
Cheers!
Dave K.

0 Vote Up Vote Down
Sara Santos Staff answered 4 months ago

Hi Dave.
 
I’m glad you found the issue.
Not setting the pins properly for your board will result in “camera not detected” errors.
We have an article about the TTGO-Camera you are using with the pins definition and other information that might be useful: https://makeradvisor.com/esp32-ttgo-t-camera-pir-sensor-oled/
 
We also have another article with pin definitions for other boards: https://randomnerdtutorials.com/esp32-cam-camera-pin-gpios/
 
Regards,
Sara

0 Vote Up Vote Down
David Kosewick answered 4 months ago

I was thrilled the problem was so simple!
I posted it so everyone would go back and check their pin defines if they see this error in the serial monitor.
In my case, the PIR was interfering with #define SIOD_GPIO_NUM 13, causing the error. I assume other mis-defined pins would create the same error.
Keep up the great work!
Dave K.

0 Vote Up Vote Down
Sara Santos Staff answered 4 months ago

That’s great, thank you.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara
 

0 Vote Up Vote Down
EDUARDO ALCOFORADO answered 4 months ago

Hi guys, 
The code that I used is absolutely the same that used to work here in the past. And it’s not working im my two “AI Thinker ESP32-CAM” modules. I’m taking a look on David’s solution, looking for something weird in my code.
 
The code I used is this one below:
 

/*****************************
** Included Header Files    **
*****************************/
#include <Arduino.h>
#include “esp_camera.h”
#include “esp_timer.h”
#include “img_converters.h”
#include “Arduino.h”
#include “fb_gfx.h”
#include “fd_forward.h”
#include “fr_forward.h”
#include “FS.h”                // SD Card ESP32
#include “SD_MMC.h”            // SD Card ESP32
#include “soc/soc.h”           // Disable brownour problems
#include “soc/rtc_cntl_reg.h”  // Disable brownour problems
//#include “dl_lib.h”
#include “driver/rtc_io.h”
#include <EEPROM.h>            // read and write from flash memory
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

/******************************************
** Constants and global scope variables  **  
******************************************/
// define the number of bytes you want to access
#define EEPROM_SIZE 1

// Pin numbers in CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27

#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22

// Other constants
#define INTERVAL 15000 // Time interval (in milliseconds) between each picture

// Global scope variables
camera_config_t config; //Stores the camera configuration parameters
unsigned int pictureNumber = 0; //Picture number

/**************************
** Function prototypes   ** 
**************************/
void config_and_initialize_camera( void );
void init_microSD_card( void );
void take_picture( void );

/******************
** setup()       ** 
******************/
void setup() {
      // Disable the ‘browout detector’
      WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); 

      // Turn off the flash
      pinMode(4, INPUT);
      digitalWrite(4, LOW);
      //rtc_gpio_hold_dis(GPIO_NUM_4);
      
      // Mnitor serial
      Serial.begin(115200);
      delay(10000);
      Serial.println(“Initializing…”);

      Serial.print(“Initializing the camera module…”);
      config_and_initialize_camera();
      Serial.println(“Ok!”);

      //–> Inicializar o cartao MicroSD:
      Serial.print(“Initializing  the MicroSD card module…”);
      init_microSD_card();
      Serial.println(“”);

}

/****************
** loop()      **  
****************/
void loop() {
      // –> Take a picture:
      take_picture();

      // Wait ” milliseconds before taking another picture
      delay(INTERVAL);

}

/**************************
** Auxiliary Functions   **
**************************/
// –> ‘config_and_initialize_camera()’ function
void config_and_initialize_camera( void ){
      // –> Configuracoes da camera
      //camera_config_t config;
      config.ledc_channel = LEDC_CHANNEL_0;
      config.ledc_timer = LEDC_TIMER_0;
      config.pin_d0 = Y2_GPIO_NUM;
      config.pin_d1 = Y3_GPIO_NUM;
      config.pin_d2 = Y4_GPIO_NUM;
      config.pin_d3 = Y5_GPIO_NUM;
      config.pin_d4 = Y6_GPIO_NUM;
      config.pin_d5 = Y7_GPIO_NUM;
      config.pin_d6 = Y8_GPIO_NUM;
      config.pin_d7 = Y9_GPIO_NUM;
      config.pin_xclk = XCLK_GPIO_NUM;
      config.pin_pclk = PCLK_GPIO_NUM;
      config.pin_vsync = VSYNC_GPIO_NUM;
      config.pin_href = HREF_GPIO_NUM;
      config.pin_sscb_sda = SIOD_GPIO_NUM;
      config.pin_sscb_scl = SIOC_GPIO_NUM;
      config.pin_pwdn = PWDN_GPIO_NUM;
      config.pin_reset = RESET_GPIO_NUM;
      config.xclk_freq_hz = 20000000;
      config.pixel_format = PIXFORMAT_JPEG; 

      // –> Frame size:
      if( psramFound() ){
            config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
            config.jpeg_quality = 10;
            config.fb_count = 2;
      } else {
            config.frame_size = FRAMESIZE_SVGA;
            config.jpeg_quality = 12;
            config.fb_count = 1;
      }

      // –> Inicialize Camera
      esp_err_t err = esp_camera_init(&config);
      if (err != ESP_OK) {
            Serial.printf(“Camera init failed with error 0x%x”, err);
            return;
      }
}

// –> ‘init_microSD_card()’ function
void init_microSD_card( void ){
      Serial.println(“Starting SD Card”);
      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;
      }
      Serial.println(“Ok!”);
}

// –> ‘take_picture()’ function
void take_picture( void ){
      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 path = “/pic_” + String(pictureNumber) +”.jpg”;
      
      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();
      esp_camera_fb_return(fb); 
      
      // Turns off the ESP32-CAM white on-board LED (flash) connected to GPIO 4
      digitalWrite(4, LOW);
}

 
Thanks you very much,
Eduardo Alvim

0 Vote Up Vote Down
Sara Santos Staff answered 3 months ago

Hi.
As mentioned previously, it might be a power issue.
Sometimes, you have to press the RST button several times until it finds the camera.
You may also need to disconnect the camera ribbon and connect again.
Regards,
Sara

0 Vote Up Vote Down
EDUARDO ALCOFORADO answered 3 months ago

I tried reconecting the camera and pressing the reset several times here. But nothing different tha the other times. I bought a TTGO ESP Camera here and I hope that I won’t have this issue again…
 
Thank you very much 

0 Vote Up Vote Down
Sara Santos Staff answered 3 months ago

Hi.
That’s weird.
Are you sure you didn’t change anything on the pin definition?
Did those cameras worked before?
Regards,
Sara

0 Vote Up Vote Down
EDUARDO ALCOFORADO answered 3 months ago

Yes, They worked very well before. I used it in july and they were working perfect. When I tried to use then again (by end of august or begining of september) they showed this problem here.
Yes, very very weird, but I’m moving it. 
Thank you very much!
 

0 Vote Up Vote Down
Sara Santos Staff answered 3 months ago

Hi.
I’m sorry, but besides the suggestions I’ve made before in the other issue, I’m out of ideas on how to solve your problem 🙁

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Download Build Web Servers with ESP32 and ESP8266 (2nd Edition) February 8, 2021
  • [eBook Released] Build Web Servers with ESP32 and ESP8266 (version 1.0) October 27, 2020

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2021 · RandomNerdTutorials.com · All Rights Reserved