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
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.
- Not enough power through USB source
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
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.
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
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.
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
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.
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
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
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
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
Hi.
That’s weird.
Are you sure you didn’t change anything on the pin definition?
Did those cameras worked before?
Regards,
Sara
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!