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!
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 🙁
I bought another OV640 camera module and tested in my ESP32-CAM. Yes, now they are working as it should (and used to work)!
The problem is related to the camera model XRZ00D1. I don’t have any ideia why it used to work perfectly and suddenly stoped.
The OV2640 camera module which worked fine I bought here: https://pt.aliexpress.com/item/4000035639017.html?spm=a2g0s.9042311.0.0.f1c3b90a9OTV0o
Well, thank you!
Hi Eduardo.
I’m glad everything is working now.
Thanks for the follow-up.
Regards,
Sara
Not an answer but another question, I used the code from the 4th module on streaming, loaded it up, but always get a camera fail init fail 20004 (surmised its related to the probe). when I started I was using a fisheye lens, changed to the stock lens and it worked, but when I switched back to the fish eye again same fail. When I compared the code to other code found on the website, there seemed to be bits missing about the init. is there different code I need for the fisheye?’
Hi.
I don’t think you need a different code for the fisheye. The cameras are the same in terms of hardware, only the lens is different (at least when I tried a fish eye lens, it was like that). Unless you have a different camera…
What bits of code do you think are missing?
Regards,
Sara
Hello,
I am now waiting for my new cameras to be sure, but it does appear the cameras I have are in fact the wrong ones. I bought them before I got the bundle and was only looking for cameras compatible with the ESP32CAM, turns out I bought the ov5640 cameras. There wasn’t any identifying info on the bags they came in, but there was info on the mini ribbon cable. The code I thought was missing was
sensor_t * s = esp_camera_sensor_get()
s->set_brightness(s, 0); // -2 to 2
s->set_contrast(s, 0); // -2 to 2
s->set_saturation(s, 0); // -2 to 2
s->set_special_effect(s, 0); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia)
s->set_whitebal(s, 1); // 0 = disable , 1 = enable
s->set_awb_gain(s, 1); // 0 = disable , 1 = enable
s->set_wb_mode(s, 0); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
s->set_exposure_ctrl(s, 1); // 0 = disable , 1 = enable
s->set_aec2(s, 0); // 0 = disable , 1 = enable
s->set_ae_level(s, 0); // -2 to 2
s->set_aec_value(s, 300); // 0 to 1200
s->set_gain_ctrl(s, 1); // 0 = disable , 1 = enable
s->set_agc_gain(s, 0); // 0 to 30
s->set_gainceiling(s, (gainceiling_t)0); // 0 to 6
s->set_bpc(s, 0); // 0 = disable , 1 = enable
s->set_wpc(s, 1); // 0 = disable , 1 = enable
s->set_raw_gma(s, 1); // 0 = disable , 1 = enable
s->set_lenc(s, 1); // 0 = disable , 1 = enable
s->set_hmirror(s, 0); // 0 = disable , 1 = enable
s->set_vflip(s, 0); // 0 = disable , 1 = enable
s->set_dcw(s, 1); // 0 = disable , 1 = enable
s->set_colorbar(s, 0); // 0 = disable , 1 = enable
Hi.
That piece of code is optional and it changes the settings of the camera.
ov5640 cameras are not compatible with the codes we have, that are for OV2640 cameras.
Regards
Sara
Well, it’s my experience here Jon Ullom: when you face the 0x20004, it means that you camera is gonne. When it happened to me, I tried everything, change the ESP, disconnect and reconnect the camera, test the same camera in onther ESP etc. Nothing worked to me, except try a new OV2640 camera. Unfortunately.
I wish I could tell some better news here.