ESP32-CAM Video Streaming Web Server (works with Home Assistant)

In this project we’re going to build an IP surveillance camera with the ESP32-CAM board. The ESP32 camera is going to host a video streaming web server that you can access with any device in your network.

ESP32-CAM Video Streaming Web Server works with Home Assistant Node-RED

You can integrate this video streaming web server with popular home automation platforms like Home Assistant or Node-RED. In this tutorial, we’ll show you how to integrate it with Home Assistant and Node-RED.

Watch the Video Tutorial

You can watch the video tutorial or keep reading this page for the written instructions.

Parts Required

To follow this tutorial you need the following components:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Introducing the ESP32-CAM

The ESP32-CAM is a very small camera module with the ESP32-S chip that costs less than $10. You can read our getting started guide for the ESP32-CAM and learn how to use the Video Streaming and Face Recognition example.

Introducing the ESP32-CAM camera board AI Thinker module

Video Streaming Server

Follow the next steps to build a video streaming web server with the ESP32-CAM that you can access on your local network. 

1. Install the ESP32 add-on

In this example, we use Arduino IDE to program the ESP32-CAM board. So, you need to have Arduino IDE installed as well as the ESP32 add-on. Follow one of the next tutorials to install the ESP32 add-on, if you haven’t already:

2. Video Streaming Web Server Code

After that, copy the code below to your Arduino IDE.

/*********
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/
  
  IMPORTANT!!! 
   - Select Board "AI Thinker ESP32-CAM"
   - GPIO 0 must be connected to GND to upload a sketch
   - After connecting GPIO 0 to GND, press the ESP32-CAM on-board RESET button to put your board in flashing mode
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*********/

#include "esp_camera.h"
#include <WiFi.h>
#include "esp_timer.h"
#include "img_converters.h"
#include "Arduino.h"
#include "fb_gfx.h"
#include "soc/soc.h" //disable brownout problems
#include "soc/rtc_cntl_reg.h"  //disable brownout problems
#include "esp_http_server.h"

//Replace with your network credentials
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

#define PART_BOUNDARY "123456789000000000000987654321"

// This project was tested with the AI Thinker Model, M5STACK PSRAM Model and M5STACK WITHOUT PSRAM
#define CAMERA_MODEL_AI_THINKER
//#define CAMERA_MODEL_M5STACK_PSRAM
//#define CAMERA_MODEL_M5STACK_WITHOUT_PSRAM

// Not tested with this model
//#define CAMERA_MODEL_WROVER_KIT

#if defined(CAMERA_MODEL_WROVER_KIT)
  #define PWDN_GPIO_NUM    -1
  #define RESET_GPIO_NUM   -1
  #define XCLK_GPIO_NUM    21
  #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      19
  #define Y4_GPIO_NUM      18
  #define Y3_GPIO_NUM       5
  #define Y2_GPIO_NUM       4
  #define VSYNC_GPIO_NUM   25
  #define HREF_GPIO_NUM    23
  #define PCLK_GPIO_NUM    22

#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
  #define PWDN_GPIO_NUM     -1
  #define RESET_GPIO_NUM    15
  #define XCLK_GPIO_NUM     27
  #define SIOD_GPIO_NUM     25
  #define SIOC_GPIO_NUM     23
  
  #define Y9_GPIO_NUM       19
  #define Y8_GPIO_NUM       36
  #define Y7_GPIO_NUM       18
  #define Y6_GPIO_NUM       39
  #define Y5_GPIO_NUM        5
  #define Y4_GPIO_NUM       34
  #define Y3_GPIO_NUM       35
  #define Y2_GPIO_NUM       32
  #define VSYNC_GPIO_NUM    22
  #define HREF_GPIO_NUM     26
  #define PCLK_GPIO_NUM     21

#elif defined(CAMERA_MODEL_M5STACK_WITHOUT_PSRAM)
  #define PWDN_GPIO_NUM     -1
  #define RESET_GPIO_NUM    15
  #define XCLK_GPIO_NUM     27
  #define SIOD_GPIO_NUM     25
  #define SIOC_GPIO_NUM     23
  
  #define Y9_GPIO_NUM       19
  #define Y8_GPIO_NUM       36
  #define Y7_GPIO_NUM       18
  #define Y6_GPIO_NUM       39
  #define Y5_GPIO_NUM        5
  #define Y4_GPIO_NUM       34
  #define Y3_GPIO_NUM       35
  #define Y2_GPIO_NUM       17
  #define VSYNC_GPIO_NUM    22
  #define HREF_GPIO_NUM     26
  #define PCLK_GPIO_NUM     21

#elif defined(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
#else
  #error "Camera model not selected"
#endif

static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";

httpd_handle_t stream_httpd = NULL;

static esp_err_t stream_handler(httpd_req_t *req){
  camera_fb_t * fb = NULL;
  esp_err_t res = ESP_OK;
  size_t _jpg_buf_len = 0;
  uint8_t * _jpg_buf = NULL;
  char * part_buf[64];

  res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
  if(res != ESP_OK){
    return res;
  }

  while(true){
    fb = esp_camera_fb_get();
    if (!fb) {
      Serial.println("Camera capture failed");
      res = ESP_FAIL;
    } else {
      if(fb->width > 400){
        if(fb->format != PIXFORMAT_JPEG){
          bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
          esp_camera_fb_return(fb);
          fb = NULL;
          if(!jpeg_converted){
            Serial.println("JPEG compression failed");
            res = ESP_FAIL;
          }
        } else {
          _jpg_buf_len = fb->len;
          _jpg_buf = fb->buf;
        }
      }
    }
    if(res == ESP_OK){
      size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);
      res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
    }
    if(res == ESP_OK){
      res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
    }
    if(res == ESP_OK){
      res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
    }
    if(fb){
      esp_camera_fb_return(fb);
      fb = NULL;
      _jpg_buf = NULL;
    } else if(_jpg_buf){
      free(_jpg_buf);
      _jpg_buf = NULL;
    }
    if(res != ESP_OK){
      break;
    }
    //Serial.printf("MJPG: %uB\n",(uint32_t)(_jpg_buf_len));
  }
  return res;
}

void startCameraServer(){
  httpd_config_t config = HTTPD_DEFAULT_CONFIG();
  config.server_port = 80;

  httpd_uri_t index_uri = {
    .uri       = "/",
    .method    = HTTP_GET,
    .handler   = stream_handler,
    .user_ctx  = NULL
  };
  
  //Serial.printf("Starting web server on port: '%d'\n", config.server_port);
  if (httpd_start(&stream_httpd, &config) == ESP_OK) {
    httpd_register_uri_handler(stream_httpd, &index_uri);
  }
}

void setup() {
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
 
  Serial.begin(115200);
  Serial.setDebugOutput(false);
  
  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; 
  
  if(psramFound()){
    config.frame_size = FRAMESIZE_UXGA;
    config.jpeg_quality = 10;
    config.fb_count = 2;
  } else {
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 12;
    config.fb_count = 1;
  }
  
  // Camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }
  // Wi-Fi connection
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  
  Serial.print("Camera Stream Ready! Go to: http://");
  Serial.print(WiFi.localIP());
  
  // Start streaming web server
  startCameraServer();
}

void loop() {
  delay(1);
}

View raw code

Before uploading the code, you need to insert your network credentials in the following variables:

const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

Then, make sure you select the right camera module. In this case, we’re using the AI-THINKER Model.

ESP32-CAM camera board AI Thinker module CAMERA_MODEL_AI_THINKER

If you’re using the same camera module, you don’t need to change anything on the code.

#define CAMERA_MODEL_AI_THINKER

Now, you can upload the code to your ESP32-CAM board.

3. Uploading the Code

Connect the ESP32-CAM board to your computer using an FTDI programmer. Follow the next schematic diagram:

Uploading the Code ESP32-CAM camera board new sketch upload code FTDI Programmer

Many FTDI programmers have a jumper that allows you to select 3.3V or 5V. Make sure the jumper is in the right place to select 5V.

Important: GPIO 0 needs to be connected to GND so that you’re able to upload code.

ESP32-CAMFTDI Programmer
GNDGND
5VVCC (5V)
U0RTX
U0TRX
GPIO 0GND

To upload the code, follow the next steps:

1) Go to Tools > Board and select AI-Thinker ESP32-CAM.

2) Go to Tools > Port and select the COM port the ESP32 is connected to.

3) Then, click the upload button to upload the code.

4) When you start to see these dots on the debugging window as shown below, press the ESP32-CAM on-board RST button.

ESP32-CAM camera board upload new Arduino IDE sketch press RESET button

After a few seconds, the code should be successfully uploaded to your board.

Getting the IP address

After uploading the code, disconnect GPIO 0 from GND. Open the Serial Monitor at a baud rate of 115200. Press the ESP32-CAM on-board Reset button.

The ESP32 IP address should be printed in the Serial Monitor.

ESP32-CAM camera board IP address Arduino IDE Serial Monitor

Accessing the Video Streaming Server

Now, you can access your camera streaming server on your local network. Open a browser and type the ESP32-CAM IP address. A page with the current video streaming should load.

ESP32-CAM camera board IP address web Server IP CAM demonstration

Home Assistant Integration

Having just the ESP32-CAM working via IP might be useful for most people, but you can integrate this project with Home Assistant (or with other home automation platforms). Continue reading to learn how to integrate with Home Assistant.

Prerequisites

Adding ESP32-CAM to Home Assistant

Open your Home Assistant dashboard and go to the more Settings menu.

ESP32-CAM camera board IP address web Server IP CAM home assistant integration

Open Configure UI:

ESP32-CAM camera board IP address web Server IP CAM configure UI

Add a new card to your Dashboard:

ESP32-CAM camera board home assistant add new element

Pick a card of the type Picture.

ESP32-CAM camera board home assistant Picture card

In the Image URL field, enter your ESP32-CAM IP address. Then, click the “SAVE” button and return to the main dashboard.

ESP32-CAM camera board home assistant IP Address

If you’re using the configuration file, this is what you need to add.

ESP32-CAM camera board home assistant card configuration

After that, Home Assistant can display the ESP32-CAM video streaming.

ESP32-CAM camera board home assistant demonstration

Taking It Further

To take this project further, you can use one fake dummy camera and place the ESP32-CAM inside.

ESP32-CAM camera board fake camera

The ESP32-CAM board fits perfectly into the dummy camera enclosure.

Fake dummy camera with ESP32-CAM AI Thinker Module Inside IP Camera CAM web server

You can power it using a 5V power adapter through the ESP32-CAM GND and 5V pins.

Fake dummy camera with ESP32-CAM AI Thinker Module Inside powering

Place the surveillance camera in a suitable place.

ESP32-CAM camera board surveillance IP Cam

After that, go to the camera IP address or to your Home Assistant dashboard and see in real time what’s happening. The following image shows us testing the video streaming camera. Sara is taking a screenshot while I’m filming the camera.

ESP32-CAM camera board surveillance IP Cam home assistant

It’s impressive what this little $9 ESP32 camera module can do and it’s been working reliably. Now, we can use the surveillance camera to see in real time what’s happening in my front entrance.

ESP32-CAM camera board surveillance IP Cam home assistant

Tip: Node-RED Integration

The video streaming web server also integrates with Node-RED and Node-RED Dashboard. You just need to create a Template node and add the following:

<div style="margin-bottom: 10px;">
<img src="https://YOUR-ESP32-CAM-IP-ADDRESS" width="650px">
</div>

In the src attribute, you need to type your ESP32-CAM IP address:

<div style="margin-bottom: 10px;">
<img src="https://192.168.1.91" width="650px">
</div>

Troubleshooting

If you’re getting any of the following errors, read our ESP32-CAM Troubleshooting Guide: Most Common Problems Fixed

  • Failed to connect to ESP32: Timed out waiting for packet header
  • Camera init failed with error 0x20001 or similar
  • Brownout detector or Guru meditation error
  • Sketch too big error – Wrong partition scheme selected
  • Board at COMX is not available – COM Port Not Selected
  • Psram error: GPIO isr service is not installed
  • Weak Wi-Fi Signal
  • No IP Address in Arduino IDE Serial Monitor
  • Can’t open web server
  • The image lags/shows lots of latency

Learn how to program and build 17 projects with the ESP32-CAM using Arduino IDE DOWNLOAD »

Learn how to program and build 17 projects with the ESP32-CAM using Arduino IDE DOWNLOAD »

Wrapping Up

In this tutorial we’ve shown you how to build a simple video streaming web server with the ESP32-CAM board to build an IP camera. The web server we’ve built can be easily integrated with your home automation platform like Node-RED or Home Assistant.

We hope you’ve find this tutorial useful. If you don’t have an ESP32-CAM yet, you can grab it here.

If you like this project, you may also like other projects with the ESP32-CAM:

Thanks for reading!



Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our weekly newsletter!

231 thoughts on “ESP32-CAM Video Streaming Web Server (works with Home Assistant)”

  1. I meant completely integrating it in Node-RED – available on the dashboard as a viewable feed, face recognition triggering events, etc.

    Reply
  2. I’d like to create a battery powered version that uses the ESP32’s deep sleep mode (with motion detection to wake it up) and low battery notifications.

    Reply
  3. Dear Sir,
    That’s a lovely project.

    However, I’m not getting the some of the header files used in the arduino sketch. They are esp_camera.h, “esp_http_server.h”,
    esp_timer.h,img_converters.h

    Can you please be kind enough to help me getting these header files?

    Thanks in advance..

    Rgds.

    S. Bera

    Reply
  4. Fantastic! Any suggestions on how to use it to capture video? IE: if it could detect motion with a passive IR added in addition to the ESP32 camera…and that motion could trigger the local PC to record for X minutes, that would be FANTASTIC.

    Reply
      • Hi Sara,

        Most excellent! I look forward to it. Got several of the boards on the way. I’m thinking that instead of putting the board into a security camera housing, I’m going to mount it to the inside of a window facing to the outside. Should work well and not require any environmental sealing. 🙂

        Thanks much,
        ben

        Reply
  5. Hi, I wanted to know if it was possible to reduce the latency of the image, and if it were possible to use an ESP8266. Thank you.

    Reply
  6. Rui,
    My daughter is into Legos and wants me to help her to develop a Lego Sorter.
    How difficult would it be to adapt the face recognition SW to learn to recognize objects?

    Thanks to you and Sara for all the information and work you do to educate people.

    Regards,

    Lloyd

    Reply
    • Hi Lloyd.
      At the moment, I don’t think it is easy to do that with the ESP32-CAM and arduino IDE. It’s a quite new topic and there aren’t many libraries available to do that.
      There are much more support for object recognition using raspberry pi and its camera at the moment.
      Regards,
      Sara

      Reply
  7. HI, I’m using this esp32 camera from M5Stack-Camera-Antenna-Arduino-Raspberry

    When the code executes this line:
    fb = esp_camera_fb_get();
    it never returns. I’ve place a Serial.println() before and after the line, and the line after never prints out.

    The only camera model setting that passes the camera init and probe is this: CAMERA_MODEL_M5STACK_PSRAM.

    Here are the things that I’ve tried:
    — created OV2640 config : fails camera init and probe
    — changed jpeg_quality making from a Min of 1 to a max of 12
    — Changed fb_count numbers 1-3

    What would you suggest?

    Thanks in advance,

    Reply
  8. Hello.
    When I try to upload the sketch to the ESP32 CAM an error mesagge shows “Failed to connect to ESP32: Timed out waiting for packet header”.
    I’ve checked the connections, pressed Reset before and during the upload attempt, connected to 3.3v and 5v, used //#define CAMERA_MODEL_WROVER_KIT and #define CAMERA_MODEL_AI_THINKER.
    Please, I’ll be glad to know if you have any suggestions of something else to try.
    Best wishes.

    Reply
    • Hi Marcelo.
      I’m sorry you’re having trouble with your board.
      Please verify that you have the ESP32 GPIO0 connected to GND during the uploading.
      Also, make sure that in the arduino ide settings, you select Tools > Partition Scheme, select “Huge APP (3MB No OTA)“.
      It this doesn’t work, it is very difficult for me to understand what might be wrong.
      Regards,
      Sara

      Reply
  9. Wow, what a brilliant, inspiring idea !!!

    Just last week I received some of these camera’s. I ordered them from China some time ago, but it took some time before they were shipped.
    (I guess they are very popular)

    Yesterday I assembled and programmed the ESP-CAM and found out that it works well when you use a powerbank, you can just walk around with it !
    (also found out that you can program the board with a USB-to-TTL module model CP2102 and that the CH340 model does NOT work)
    Then I searched the whole house for my old dummy camera’s..
    and found them today, haha. They are not as easy to use as yours,
    but some are ‘workable’.

    Surprisingly enough, I managed to build my first dummy-ESP-CAM today !
    I use it to watch my front door, it’s battery operated (3xAA-rechargable-2000mAh) and it works very well !
    They is some (a few seconds) time-lag (latency ?) between what happens and it showing up on screen, but other than that the camera works fine and I love that I can see who’s at my front door before I open it !
    Now we will have to learn by experience how long these batteries will last…

    Your explanation was very easy to follow and my ESP-CAM was up and running before I knew it…. getting it into my old dummy-cam was (a lot) more work…

    Thank you again, for another inspiration ! I had a great day building it !

    Reply
    • Hi Gerrit.
      Thank you so much for your nice words.
      I’m really happy when I see that our readers can actually make our projects and put them working in a real world scenario.
      Then, let me know how long your batteries last.
      Thank you for your interest and enthusiasm in our projects.
      Regards,
      Sara

      Reply
  10. I ordered the components from Maker Advisor but received an unknown model of the ESP32CAM, with which none of the three camera settings work. Since the serial monitor reports: “[D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled”
    I guessed this must be the M5STACK_PSRAM model, but booting with this setting sends the error message “Camera init failed with error 0x20001”.

    The WROVER_KIT setting als returns these errors: “SCCB_Write [ff]=01 failed; SCCB_Write [12]=80 failed; Camera init failed with error 0x20001”

    And the AI_THINKER setting complains about an illegal instruction, reboots and then gives no more information after the “PSRAM enabled” message.

    Any ideas?

    Pierre

    Reply
  11. I ordered the components from Maker Advisor but received an unknown model of the ESP32CAM, with which none of the three camera settings work. Since the serial monitor reports: “[D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled”
    I guessed this must be the M5STACK_PSRAM model, but booting with this setting sends the error message “Camera init failed with error 0x20001”.

    The WROVER_KIT setting als returns these errors: “SCCB_Write [ff]=01 failed; SCCB_Write [12]=80 failed; Camera init failed with error 0x20001”

    And the AI_THINKER setting complains about an illegal instruction, reboots and then gives no more information after the “PSRAM enabled” message.

    Any ideas?

    Pierre

    (my earlier message about being unable to flash are obsolete now, they were due to a faulty FT232)

    Reply
  12. Rui,

    I purchased three ESP32-CAM modules from Banggood with camera.

    I have tried everything I could find on internet to program anything on them. I keep getting “Timed out waiting for packet header” error. Nothing ever get programmed? Even used an external power supply and nothing works.

    These modules do not say “AI-THINKER” on them. Might be a different module but cannot prove it this way.

    Any more ideas:

    Thanks, Joe L.

    Reply
    • Hi Joseph.
      That error means that your ESP is not in flashing mode.
      Please check that you’ve wire the RX and TX pins properly to the FTDI programmer, and that the ESP32 GPIO0 is connected to GND.
      Regards,
      Sara

      Reply
      • Sara,

        I have TX going to RX etc. and GPI0 going to gnd. I press boot buton before programming and serial says “waiting for download”. How can I know if ESP32 in flashing mode?

        Tried every mode possible and same result.

        The programmer works ok on other standard ESP32 modules.

        Thanks Joe L.

        Reply
  13. Hi Rui,

    I purchased two ESP32-CAM modules from Banggood with camera; they are exactly same than yours.
    I tried everything I found on your kind blog to program on them.
    I keep getting ever “Timed out waiting for packet header” error as follows:

    esptool.py v2.6-beta1
    Serial port COM8
    Connecting…….._____….._____….._____….._____….._____….._____….._____

    A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

    I have TX going to RX etc. and GPI0 going to gnd.
    I pressed boot button before programming.
    Tried every mode possible and same result.
    The programmer works fine on other standard ESP32 modules.

    Any idea Sara/Rui?

    Reply
    • I purchased my esp32-cam from banggood they do not say Ai-Thinker on them.
      Ihave yet to get it to work but was able to get the program loaded.I was getting the same error as you.In the if you are using Windows in the Control Panel check to make sure you have a good Driver for the COM port you are using try updating the driver.

      Reply
      • Hi, I purchased one of these little guys about six months ago, I was playing with it, and suddenly, it stopped working. I have tried to reprogram it, but to no avail, so due to the relativly low price and my love for everything esp related, I ordered another from Banggoods, where I got my first. The second one programs like a dream and works fine, even recognizes me now, so I figured I had the problem licked, I dug out my old one and still no luck. I am guessing some of my playing around probably nuked the board on the first one. It will go in my parts drawer I think for future fun and games as I progress with my knowledge of these little guys, or perhaps till the ESP64 comes out.

        Reply
          • Hi.
            That means the code was successfully uploaded.
            Disconnect GPIO 0 from GND, open the Serial Monitor and press the ESP32-CAM on-board RESET button to get its IP address.
            Then, you just need to open a browser and type the ESP32-CAM IP address.
            Regards,
            Sara

    • I had exactly the same problem. Used another type of FT232 board (bought on Amazon) and the communication problems were solved. But my ESP32 cam boards from Banggood are also of an unknown type that does not work with the software provided in this article…

      Reply
    • I had this problem and it was not enough power through USB source I fed +5 to Vcc pin and that fixed it. It was brown out in my case.

      Reply
    • Hi Domenico.
      That error means that the ESP32 is not in flashing mode.
      You have to follow the exact same instructions we have in our tutorial.
      By what you’re describing, it seems that you’re doing everything right. If you’re doing as we describe in our tutorial and it doesn’t work, I don’t know what can be the problem.

      Also, as Richard said “If you are using Windows in the Control Panel check to make sure you have a good Driver for the COM port you are using try updating the driver.”

      I’m sorry that I can’t help much. Meanwhile, if you find out the problem let us know. We’re planning to write a troubleshooting guide for the ESP32-CAM.
      Regards,
      Sara

      Reply
          • Hi Sara, the flashing is now Okay; but I got this error ; could be it due to cam related. Right?
            PS: I purchased my esp32-cam from banggood they do not say Ai-Thinker on them, but they are exactly same than yours. Any idea to solve in case not exactly the AI-Thinker camera?

            =========================================
            18:46:14.539 -> configsip: 0, SPIWP:0xee
            18:46:14.539 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
            18:46:14.539 -> mode:DIO, clock div:1
            18:46:14.539 -> load:0x3fff0018,len:4
            18:46:14.539 -> load:0x3fff001c,len:1100
            18:46:14.539 -> load:0x40078000,len:10088
            18:46:14.539 -> load:0x40080400,len:6380
            18:46:14.539 -> entry 0x400806a4
            18:46:16.939 -> Guru Meditation Error: Core 0 panic’ed (LoadProhibited). Exception was unhandled.
            18:46:17.059 -> Core 0 register dump:
            18:46:17.059 -> PC : 0x4014284b PS : 0x00060830 A0 : 0x80140b67 A1 : 0x3ffd3150
            18:46:17.059 -> A2 : 0x3ffc8c08 A3 : 0x401417d8 A4 : 0x00000002 A5 : 0x00000005
            18:46:17.059 -> A6 : 0x0000000b A7 : 0x00000003 A8 : 0x80142845 A9 : 0x3ffd3130
            18:46:17.059 -> A10 : 0x4000446c A11 : 0x400041fc A12 : 0x3ffc8c50 A13 : 0x00000007
            18:46:17.059 -> A14 : 0x3ffae0c0 A15 : 0x00000008 SAR : 0x0000001c EXCCAUSE: 0x0000001c
            18:46:17.059 -> EXCVADDR: 0x00000002 LBEG : 0x4008d664 LEND : 0x4008d67c LCOUNT : 0x00000000
            18:46:17.059 ->
            18:46:17.059 -> Backtrace: 0x4014284b:0x3ffd3150 0x40140b64:0x3ffd3180 0x4014105c:0x3ffd31a0 0x400dd8a6:0x3ffd3260 0x400ddb56:0x3ffd3290 0x40115439:0x3ffd32c0 0x4011553c:0x3ffd32f0 0x4011583e:0x3ffd3320 0x401159b3:0x3ffd3350 0x4008b5c8:0x3ffd3370 0x40091b11:0x3ffd33b0
            18:46:17.059 ->
            18:46:17.059 -> Rebooting…
            18:46:17.059 -> ets Jun 8 2016 00:22:57
            18:46:17.059 ->
            18:46:17.059 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
            18:46:17.059 -> configsip: 0, SPIWP:0xee
            18:46:17.059 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
            18:46:17.059 -> mode:DIO, clock div:1
            18:46:17.059 -> load:0x3fff0018,len:4
            18:46:17.059 -> load:0x3fff001c,len:1100
            18:46:17.059 -> load:0x40078000,len:10088
            18:46:17.059 -> load:0x40080400,len:6380
            18:46:17.059 -> entry 0x400806a4
            18:46:18.739 -> SCCB_Write [ff]=01 failed
            18:46:18.739 -> SCCB_Write [12]=80 failed
            18:46:18.859 -> Camera init failed with error 0x20001
            ===============================================

          • After flashing, you need to remove the connection between GND and IO0. If you see the error (below) – that indicates the ESP-32 is in boot mode, try adding a 10K resistor between IO0 and 3.3V to make sure the state of this pin/input isn’t floating. Once I added the resistor, everything worked for me!

  14. I have the same problem as ‘Domenico’ – I ordered 2 ESP32-CAM modules from Banggood and they also do not recognise the camera…they are also not marked AI Thinker…

    Reply
    • I had the same issue Chris Parsons. I bought 2 ESP32-CAM modules from Amazon. I paid a premium to get them quickly. They are from DIYMORE. They do not work with the examples here. I replaced them with 2 from Banggood that are labelled AI Thinker and they work just fine

      Reply
      • I actually bought my modules from Banggood – the advert shows ‘AI Thinker’ but they sent what I suspect is an ‘equivalent’ that doesn’t work – so now I will have to convince them to refund me and send the correct ones – and wait another 2 weeks 🙁

        Guess you must have been lucky?

        Reply
        • I have tried convincing Banggood to refund in another issue that seemed crystal clear (ordered a shutter up/down switch and received a light dimmer 🙂 and got only a fraction of my money back. Trying to get this module to work will probably be easier than claiming a refund

          Reply
  15. I am trying to edit the code of the esp32 on access point mode. But it work. The wifi is up and running. But the website is not loading. Is this code compatible with accesspoint wifi?

    Reply
    • Hi.
      I don’t see why it wouldn’t be compatible, but I haven’t tried it.
      Please note that you can only access the video streaming at one place at a time. Make sure you don’t have the web server opened in another tab.
      Regards,
      Sara

      Reply
  16. Hi Rui..Sara can you make an update on the code to fix the Camera init failed with error 0x20001 ERROR CODE ? Thanks a lot lot lot. 🙂

    Reply
  17. Hello
    It works, but …
    when I run the ip I have a picture every 30 seconds or so.
    Is it possible to block the IP fixed?

    Reply
  18. I too received boards with a different chip from Bang Good, however mine work fine with the AI Thinker selection. I did have issues in the beginning when setting them up and finally figured out they are really picky about their power. They need a lot and are extremely intolerant of noise or low voltage. Try using the 5V pin and the ground next to it rather than the 3.3V. They seem to be happier when using their own onboard voltage converter.

    Reply
  19. I too received a unmarked unit from banggood (also 1 from AliExpress) and had the same error, Camera init failed with error 0x20001. But as an earlier poster said, I too switch the jumpier from 3.3v to 5v and that solved the problem.

    NOTE: both my units, were unmarked (images on websites showed AI-Thinker) but required 5 volts. So that was the problem not anything in the code.
    Ivory

    Reply
    • Unfortunately, this solution doesn’t work for me. After flashing, I switched to 5V, the reset LED now keeps burning faintly and after reset, the serial monitor does not show anything, not even an error message. Scanning the ports on my local network also does not show a new server added…

      Reply
  20. Dear Rui, thanks for the tutorial.
    I would like to be able to turn on a light from my cell phone, a light attached to a relay controlled by the ESP32.
    How would do that?
    Thanks
    Paulo

    Reply
    • Is this when you are programming it? I have a different FTDI programmer with a 3.3v or 5v switch?

      I did wonder if the ESP32 would get enough power via the FTDI programmer which is connected to a USB port on my PC?

      Chris

      Reply
  21. Hi Rui, a quick question not fully understood; can I check the cam (accessing the video streaming server) from outside the house, not using the same IP address????

    Reply
  22. Hi rui…I tried an answer by myself and found the OpenVPN could be a way to reach from outside of the home to inside it the web cam video streaming. Am I wrong?

    Reply
    • Yes. Using a setup like that should definitely make your ESP32-CAM web server available from anywhere.

      Reply
  23. Hi,
    Referring to the this tutorial with the ESP-32 CAM.
    I would like to be able to switch on a lamp while watching the streaming video from the camera.
    How can it be done?
    Thanks
    Paulo

    Reply
  24. bonjour,
    merci pour les infos j’ai bloqué l’IP et l’image est plus fluide avec une bonne antenne.
    Mon souhait serait de pouvoir capturer une image et l’envoyer par mail .
    Une idée ?
    Merci

    Reply
  25. Gave up on using the non ‘AI Thinker’ boards and bought another one that was marked AI Thinker…uploaded the code, and finally got the message showing the IP address in the monitor, but no web server on the same LAN!

    Tried a reboot and even reloading the code but get garbage in the monitor and sometimes a message about ‘Camera init failed with error 0x20002’

    I have tried disconnecting the power to the board and connecting 5v and GND instead but get the same results, reflashing the firmware (with 3.3v connected) but nothing…did you ever produce the help guide?

    Reply
    • Hey, try reflashing with 5V (connect to the 5V pin of course). Programming with 3.3V here has also resulted in tons of error messages. With 5V flashing&running, everything is find.

      Reply
      • I just got one and followed the instructions and had problems programming.
        I connected to the 5v line and it programed ok.
        I since realised that my FTDI programer outputs 5 volts ONLY on the VCC line. It can switch between 3.3v and 5v only on the DATA lines.
        I was therefore pumping 5v directly to the 3.3v line, so was lucky not to damage the EPS32 or camera.
        Actually, I may have as there are lots of moving horizontal lines on the image and both camer and EPS32 get very hot.
        Many people suggest bumping up the power to help remove many of the lines, but I wonder how many tried to program with 5v onto the 3.3v line at the begining!

        Reply
  26. Hi and thanks for the tutorial. Really needed it!
    Took a while to get everything working.
    My main problems were power issues as well.
    I found I could flash the code via USB at 3.3 and 5, but then trying to run the code would constantly crash in different ways.
    So I powered the device with an external 5v power supply, disconnected the USB power (but not the ground). With that, everything worked great.
    Don’t give up on this device … it’s really impressive once you get it going!
    Thanks again for your article!

    Reply
  27. I’ve bought also from aliexpress 3 ESP32-cam non-AI-thinker boards.
    I’ve found out that the boards come with pre-installed fw.
    if you look with phone or PC for WiFi networks, you’ll find an “ESP32_CAM” ssid, which belong to it. just click on connect, no-pwd and go to :

    http://192.168.4.1/jpg_stream

    that’s all. i’m figuring out how to connect to the board and flash another fw.
    I’ll keep you update.

    Reply
  28. I found the problem. I had upgraded the boards to Version 1.0.2 and no ESP32 code would compile.

    Thanks to a post by stankusaudrius on the ESP32 Github, I looked in
    C:\Users\steve\AppData\Local\Arduino15\packages\esp32\hardware\esp32
    and found a folder for the older version (1.0.1). Deleting the folder for 1.0.1 fixed the problem.

    Reply
  29. Your stuff is great as usual!
    Worked first try… Unfortunately I bought mine off Alliexpress and of course the quality of the image is poor. But – it did work first try and still fun to play with.
    Thanks for your great work.

    Reply
  30. Hi, Once again another fantastic tutorial which help me enormously. I got it working after changing to the 5v connections and was a little disappointed with the picture lag. I managed to overcome this by changing the: ‘config.frame_size = FRAMESIZE_UXGA;’ to: VGA (config.frame_size = FRAMESIZE_VGA;). The picture quality is not as sharp but it is much more responsive. Also, this camera works with the motion eye os setup. A much cheaper alternative to the pi-zero option with camera. Thanks.

    Reply
    • Hi guy, the cam works perfect at 5 voltages; also, I tried successfully to streaming out using ngrok.com service. On my application the port 80 is fine. Thanks rui and Sara.

      Reply
  31. Hi Sara and Rui
    I too got an unmarked ESP32 cam board from China and set it up as an AI Thinker following your excellent tutorial. I was originally running it on 3.3 volts via the USB adaptor board and although it flashed and worked just fine, it was a bit iffy at connecting to the wifi network and there was a lot of latency and coloured lines across the picture. I have now changed to a stand alone 5 volt supply and it is much much better, so it would seem that these unbranded Chinese boards want to run at 5 volts. On a slightly different note, I would really like one of my external camera viewer apps to be able to ‘see’ this camera. I should be able to integrate it manually from the network IP address, port numbers involved and if I know the format of the video stream. Do you happen to know what it is and what port I would need to be looking for / forwarding ?

    Reply
      • Thanks Sara. I’m going away for a few days so won’t get an opportunity to try anything for a while. Is it possible to have more than one of these camera modules loaded with the tutorial software, running at once ? The router would presumably issue a different IP address to each module but would it just produce a conflict on port 80 ? Sorry if these are dumb questions, but I’m very new to all this. I have several remote viewer apps that I have tried to use with this module but I have been unable so far to get any of them to ‘see’ the module. The apps all seem to have settings for ‘generic’ IP cameras, but there are a lot of them. Is there anything else about the format of the data other than “MJPEG” that’s known that would help me find a setting that allowed the camera to be recognised ? Aircam is the app I would like to use as this works fine with my existing USB cameras and is able to operate with IP cameras as well if you can get them recognised. Thanks again for the excellent tutorials and taking the time to help old dinosaurs like me ! 🙂

        Reply
  32. Hi, I’ve just got my esp32-cam and managed to make it work in no time, thanks to your explantion – thanks!
    Just wondering about the camera – the picture quality is pretty low – it needs lots of light and I have blue and yellow horizontal lines, flickering all over the image. Is it just my camera, or is it a known problem?

    Reply
    • Hi Danny.
      The quality of the picture is low, but I didn’t get horizontal lines.
      Some readers reported that powering the ESP32 with 5V through the 5V pin can help solve that issue.
      Regards,
      Sara

      Reply
  33. What do I wrong?
    Wn10 environment
    RPI 3B
    No pblm with the installation of the ESP. It works and gives me the IP address.
    But impossible to install Home assistant.
    I’ve loaded the file “hassos_rpi2-2.12.img.gz”. Extracted it gives me he file “hassos_rpi2-2.12.img”.
    I load this file with Etcher on a (new) 64GB SD card.
    Etcher comes back with “all fine” after a few minutes.
    But the SD card is empty and asks to be formatted…
    Nothing has been copied on the SD card…
    I’ve also used “Win32DiskImager” with same results.
    Tested several times.
    Any idea?

    Reply
  34. Unlike most of your projects, this one was a disaster…I have bought three ESP32-CAM boards and none of them have yet to produce an image. I have tried running them off both 3.3v and 5v and can get a wireless connection but no image is displayed. I have also tried the ESP32 WebCameraServer example and this didn’t work either (‘camera not supported’ message)

    Bit disappointed I have wasted my money but I guess perhaps the boards and cameras vary although they all advertised as the same!

    I did manage to get one board where the chip was marked ‘AI Thinker’ but this didn’t work either 🙁

    Reply
    • Chris.
      The camera not supported message could be an indication that the camera ribbon cable is not connected correctly. On the ribbon cable should be a line, when connected if you can see that line, the cable is not pushed in far enough.
      I had the same problem, and fixed it with reconnecting the ribbon cable correctly.
      Please try reconnecting again and see if this fixes the problem.
      Hope this helps.

      Reply
    • I had similar problems initially using just a cheap Chinese version from an eBay seller. I have found that it definitely needs to be be powered from 5v not 3.3v and you need to have a good wifi connection. If necessary, configure the antenna link and use an external antenna – dirt cheap from eBay sellers. The camera connects every time now for me with no “camera not supported” error messages and stays reliably connected. I have to say that the picture quality is very good – easily as good as other cameras that I have that were much more expensive. The second issue that I had was with the browser that I tried to use to look at the camera output. Under Windows 10, my preferred IE v10 will have none of it. Although it connects and all looks to be well, the picture window is just blank. However, both Chrome under W10 and Safari under IOS on my iPhone produce an excellent picture as soon as “Start Stream” is clicked

      Reply
  35. Hi Rui and Sara,
    I like your website a lot. I love your Raspberry Pi 20 Easy Projects book, very useful and easy to follow!
    I wanted to try this project with the ESP32 and the camera, but I need some help. I am having issues uploading the programm using the Arduino IDE. I get this error:

    Arduino: 1.8.9 (Windows 7), Board: “ESP32 Wrover Module, Huge APP (3MB No OTA), QIO, 80MHz, 921600, None”

    Sketch uses 774606 bytes (24%) of program storage space. Maximum is 3145728 bytes.
    Global variables use 47912 bytes (14%) of dynamic memory, leaving 279768 bytes for local variables. Maximum is 327680 bytes.
    esptool.py v2.6
    Serial port COM6
    Connecting…….._____….._____….._____….._____….._____….._____….._____

    A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

    Reply
    • Hi again,
      It is working! I just forgot to set the jumper from the FTDI programmer to 3V3 (it was on 5V). Thanks for this tutorial! 🙂

      Reply
      • I’m glad you’ve found out the problem.
        Thank you for following our work, specially our Raspberry Pi book.
        Regards,
        Sara

        Reply
  36. Hi,
    I have been able to install everything. Not as easy as described…
    Now I’ve a pblm to retrieve the images taken with the OV2640 and put them in HomeAssistant.
    You write simply to add the url (http://192.168.1.91/ in your ex.) but this is no working in my case.
    If I want to get an image in HA, I’ve to use the complete url like found in the image source file of OV2640 application.
    This is what I’ve to use: “http://192.168.0.162/capture?_cb=1559298840529”
    BUT this is not working automatically. I’ve to update the address manually.
    Not the best solution.
    Do you have a idea how to improve?
    Thanks in advance for any help

    Reply
    • Hi Jean.
      I’m sorry for the delay in our response.
      We receive lots of comments, questions and emails every day. It is very difficult to keep track of everything. I hope you understand.

      Regarding your question.
      We’ve got everything working fine by just copying the URL. So, I don’t know what can be the issue in your case.
      If you go to the IP address, outside Home Assistant, can you see the video streaming properly?

      Regards,
      Sara

      Reply
      • Most Home Assistant users are not using the Lovelace UI, so I don’t know if the yaml code is any different. This works in my cameras.yaml file:

        # ESP32-CAMERA
        – platform: mjpeg
        mjpeg_url: http://192.168.1.54
        name: ESP32-CAM

        Of all my WiFi cameras, this one interfaces with my Home Assistant easier than all others.

        Reply
      • Hi Sara,
        Thanks!
        We all have the same prblm… time.
        Let me a few time to test it again, I’m in an other (of your) project actually.

        Reply
    • Jean-Luc

      Not sure it is relevant anymore, but I had the same problem. I fixed it by typing “http://:81/stream”. Maybe this can help someone else with the same problem

      Reply
  37. I got this working on a chinese no-brand ESP-CAM – works well, though lots of latency and the occasional vertical line – but running at 5v has helped somewhat.

    I think the latency is due to the sheer size of the image – 1600×1200. Is there any way to get a reduced image size from the CCD – or maybe force a slower refresh rate of 1 frame per second.

    Thanks!

    Reply
    • Solved:

      config.frame_size = FRAMESIZE_SVGA;

      This makes it 800×600. A bit better, but still a bit wobbly. I suspect there isn’t enough CPU there to handle lots of movement.

      Reply
      • Hi Aris.
        Thanks for sharing that information.
        Yes, the ESP32 may not have enough CPU to process movement.
        Regards,
        Sara

        Reply
  38. Hi Sara,
    I have two questions. When I install the program and run it, everything works fine. However, if I detach it from the programmer and power it with the 5V powersupply, I cannot seem to connect to it anymore. Do you have any suggestions? Another questions is regarding Octoprint. It has a feature to use a camera stream to monitor 3D prints. I was wondering if you could use this setup as a stream in Octoprint in stead of the fixed Raspberry Pi camera?

    Cheers,
    Peter

    Reply
    • Hi Peter.
      What external power supply are you using? I’ve experimented with a phone portable charger and it worked fine.
      You can have just one client at a time, so if you have a previous tab open, when you try to connect again, it won’t show anything in the new tab. You need to close the previous tab.
      Also, make sure that when you are powering it with the external power supply, the ESP32 is within the wi-fi range of your router.
      If the octoprint software provides the option to add an ip cam, it would probably be compatible. You just need to pass the streaming URL.
      Regards,
      Sara

      Reply
    • You can monitor it via FTDI while being powered by external cable.
      Just do not connect power line from ftdi to camera, leave it unconnected.
      Then connect external power supply to either 5V or 3V depending on your external power supply voltage (probably 5). And then make a common ground. Just connect gnd from ftdi to one of the ground pins, while also connecting ground from your external supply to some other gnd pins. And voila, the ftdii is able to monitor it and display the output in terminal. You can then check, what is happenning.

      Reply
  39. Thank you for this tutorial! I recently purchased two of these boards with cameras and am anxious to get them up and running. I believe I’ve installed everything correctly for the IDE but when I go to compile the sample code I get this error message:

    Board esp32doit-devkit-v1 (platform esp32, package esp32) is unknown
    Error compiling for board DOIT ESP32 DEVKIT V1.

    Thank you for any help and guidance…

    Reply
  40. Hi Sara

    My ESP camera worked a treat whilst I was away and provided a good security picture of my house. Couple of questions that I hope you might be able to answer. First, where is the user interface located ? Is it a piece of software built into the camera that the Arduino sketch interacts with, or is it part of one of the Arduino libraries that is used in the sketch ? Can the “Start Stream” button effectively be ‘pressed’ in software i.e. without having to click on the button so that the camera is streaming immediately from when it connects ? Also, where is the post number that it is outputting on defined ? Can it be changed from 80 so that more than one ESP 32 cam module can be active on different IP addresses. I’m sure others must want to do this as more than one camera would be really useful. These are probably dumb questions but I’m pretty new to all this and am just pleased that I have gotten as far as I have already with your tutorial and help 🙂

    Reply
  41. Great tutorial – I was able to upload the code just fine to my AI-Thinker esp32, however when I disconnect the GPIO0 connected to GND and reset, if I watch it in Serial Monitor it never connects to the WiFi.

    I’ve tried three different WiFi’s that I have here, all different SSIDs, but none of them ever connect.

    This is what I get, looks like it’s just fine, but that last row of ……. dots just go on forever!

    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0018,len:4
    load:0x3fff001c,len:1100
    load:0x40078000,len:9232
    load:0x40080400,len:6400
    entry 0x400806a8
    ………………………………………….

    Any ideas?

    Reply
    • Hi Don.

      Some of our readers reported that if your network credentials have more than 11 characters, it will not work.

      Also, I’ve recently discovered through one of our readers, that some ESP32-CAM boards come connected to the external antenna instead of the internal antenna. Here’s what he said that might be useful:

      “Check the jumper 0K resistor by the antenna connector is in the proper position for the antenna desired. There are 3 little white squares laid out like a “<" with the middle position being common. With board turned so the the pcb antenna up, to use the pcb antenna, the resistor must be on the top position, like this: / For the antenna connector, the resistor must be on the bottom position, like this: \ " The board provides a connector for an external antenna and has an onboard antenna as well. If your ESP32 comes with the external connector enabled, you can try adding an external antenna. Or solder/unsolder to use the internal antenna. I hope this helps. Regards, Sara

      Reply
  42. Hey. Hope this might help someone. The ESP32 cam units cannot connect to a WiFi hotspot where the SSID has more than 11 characters in the name. Mine had 12 and I was tearing my hair out trying to work out what was wrong, as everything else seemed perfect. Found this snippet on another forum, I hope it aids someone.

    Reply
      • Hi Sara,

        If this the case, do you have a suggestion?
        I’m not able to change the SSID.
        And even if I could do it I should have to change all the systems connected…

        Reply
        • Hi Berrier.
          Some of our readers have done that, but I don’t know how to do that. Maybe a google search can help with that.
          Some routers also provide the option to create guest networks. That can be a better alternative because you won’t have to change the systems that are already connected (if your router allows that).
          Bur before trying it, take a look at our troubleshooting guide to ensure that you’ve done all the steps to make it work: https://randomnerdtutorials.com/esp32-cam-troubleshooting-guide/
          Regards,
          Sara

          Reply
          • Hi Sara,
            I’ve exploited your guide already (excellent!). but w/o help.
            I’ll try Google and keep you informed.

            BR, jean-Luc

  43. My board looks just like the AI Thinker, but it is an HW-297 which I got from Amazon for $12.99. I followed the instructions and got the code loaded OK but it wouldn’t work. Just gave lots of errors. When I powered it with 5V (on the 5V pin) instead of 3.3V (on the 3.3V pin), it began to work. Amazing little thing!

    Reply
  44. For anyone having “Camera init failed with error 0x20004” try for flash and power up the board using 5v pin instead 3v, its worked for me.

    Reply
  45. Excellent tutorial!! I really want to thank you for posting this. As always, you do an excellent job of explaining all the steps. Thank you so much for your hard work and for sharing your knowledge with the community.

    Reply
    • I got it working already under Domoticz. If you have ESP tools installed in the Arduino IDE, there will be a CameraWebServer sketch that has more options under File > Examples > ESP32 > Camera. Edit this just like the sketch mentioned in this post and flash it. Setup a new camera in Domoticz Settings > More Options > Cameras, give it a name, enter the IP address of the ESP32CAM, leave the Port number blank and enter ‘capture’ as the imageURL.

      Reply
      • Hi Pierre. Thanks for your instructions on getting the cameras to view in Domoticz. I now have this running on a Widows 10 PC and it’s the first application that I have been able to get to see multiple instances of the ESP 32 cam board each on a different local address.

        Can I now set this up on my iPhone so that I can view the cameras remotely from anywhere in the world ? Please bear with me. I’m very new to all this !

        Reply
        • You can remotely view the cams directly by setting up port forwarding on your router, however since they have no security at all, anyone can access them, so I wouldn’t do that.

          Reply
        • In stead, I suggest you install Domoticz on a Raspberry Pi that will act as a server and can stay on permanently. This way, the camera’s are only connected to your local network, but you can access them from outside through the Domoticz server, which is protected.

          Reply
          • Hi Pierre. Thanks for your input. I have a Pi that I may well set up as you say. At the moment, the W10 machine whose network they are connected to, runs continuously and already has the router set up for forwarding. I now have two ESP32 cam boards set up and visible in a copy of Domoticz running on that Win10 machine. I have a copy of Domoticz now installed on my iPhone, and would like to be able to view the cameras on that phone, either via a 4G connection or any other wifi network that I might be connected to with the phone, for instance when I am away. However, I don’t know what I have to do to set up that remote viewing for the cameras – or any other device – on the iPhone copy. I just have a page with “HTTPS” and a port number on it, an empty field called “Directory”, “username” and “password” and a couple of other bits. Do I need to fill some parameters in here or go straight to “next”. As I said, I’m very new to all this, although very experienced in electronic service work. Thanks for your time and feel free to contact me direct if you would rather

          • You can Just open a browser window on your phone and from there, see Domoticz and the camera’s. I do that on my Android phone since the Domoticz app (which is also available for iPhone) for some unknown reason doesn’t show the camera streams at all.

          • OK. Pity that the app doesn’t work in that respect. I was rather hoping that it would. So what URL do I use in the browser to get to my data through Domoticz ? I’m starting to get a bit confused now …

          • Add a port forwarding rule in your browser in which your public ip address with a port of your choice will be forwarded to the local address of your Domoticz server. There are numerous guides about port forwarding available on the internet.

  46. Hi, I loaded the script in my newly arrived ESP32-CAM but the video fps seems to be very low.
    I started ping -t 192.168.99.100 (ip acquired by my ESP32-CAM) and the response time rums at 1000ms, 1300ms, some times 18ms, etc

    Can I make the size of the picture on screen half its current size?

    If I want to have a button to activate an external light how could I put this button at the same screen as the image?

    Thanks a lot
    Paulo

    Thanks
    Paulo

    Reply
  47. Hi Rui and Sara,

    I’am having problems with my camera to expose it’s ip-address.
    This is what I get from the serial monitor:

    ets Jun 8 2016 00:22:57

    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0018,len:4
    load:0x3fff001c,len:1100
    load:0x40078000,len:9232
    load:0x40080400,len:6400
    entry 0x400806a8
    Camera init failed with error 0x20004

    Reply
  48. I could not program mine yet I have exactly the same FTDI as you link to.
    I looked at your trouble shooting section and one was to use 5v, so I connected the FTDI direct to the 5v line and worked fine.
    In hindsight, the FTDI supply output IS 5v not 3.3v, only the data lines (RX/TX) are switchable between 3.3v and 5v, but the supply is always 5v volts.
    This means I put 5v directly onto the ESP32 bypassing the onboard regulator which could have damaged the ESP32.
    May I suggest that you re-draw you diagram to show a connection to 5v as currently using that FTDI you are connecting 5v to a 3.3v input even though you have labeled the supply on the diagram as 3.3v, it is actually 5v.
    Hope I have saved someone from destruction.
    Great article.
    Thanks

    Reply
    • Hi Martin.
      Thank you for following our work.
      My FTDI programmer outputs around 3.4V on the VCC pin when it is switched to 3.3V with the jumper cap. So, I didn’t have any problem powering the ESP32-CAM through the 3.3V pin using the VCC output of the FTDI programmer (outputs 3.4V). Maybe yours isn’t exactly like ours…
      Regards,
      Sara

      Reply
  49. Great article.
    I see various people have trouble with the “Banggood model”
    Obviously I am not sure which model they got, but I presume it is the dirt cheap Geekcreit model (6 euro’s or something).
    I got one and didnt really have much trouble with it. It has an AI-Thinker chip on it, and that setting seems to work for me.
    If you freshly get that model, you may be in luck that it already has a working camera program in it, which is a good way to check if your model is actually working.
    What you need to do is to go to your WiFi AP list and select the camera AP (I forgot the exact name, but you will recognize it) connect to that. Subsequently go to 192.168.4.1/jpg_stream and or /jpg to get either streaming or stills.
    That way you know your camera works fine or not.
    I reflashed mine, simply because I found the built in program a bit limited, mainly because it was on its own network.
    For the reflashing many good tips are given already:
    connect GPIO0 to ground and then reset.
    Use 5 Volt Vcc (but 3V3 FTDI module).
    Make sure you operate it with a decent PSU, decent in terms of current it can supply and cleanliness of the powerlines

    Reply
    • Hi Ed.
      Thanks for sharing that tip. It is a great way to check if the camera is operating properly. However, we don’t know if all cameras come with a program in it.
      We have some ESP32-CAM boards from Banggood and they all work well.
      Regards,
      Sara

      Reply
      • That is totally correct. I checked again and the AP to show up (if a program is provided with it is ESP32_CAM
        And the webpages to go for are indeed 192.168.4.1/jpg_stream, for streaming video and 192.168.4.1/jpg for stills.
        Do not expect a WiFimanager on 192.168.4.1 (too bad)
        Thanks for all yr excellent articles, going to get some more ESP32-cams

        Reply
  50. The one I got was this one: banggood.com/Geekcreit-ESP32-CAM-WiFi-bluetooth-Camera-Module-Development-Board-ESP32-With-Camera-Module-OV2640-p-1394679.html
    but I see it is no longer on sale for 6 Euro, but now costs a bit over 11 euro.
    Ofcourse I cannot garantee that on delivery it will be exactly the same model I got

    Reply
  51. Correction, the above model still available for 6 Euro’s till end juli……if you select CN rather than UK as the sender

    Reply
  52. I found that increasing the size of part_buf to 256 bytes greatly improved the speed of JPEG streaming. Just two lines to change:

    char * part_buf[64]

    if(res == ESP_OK){
    size_t hlen = snprintf((char *)part_buf, 256, _STREAM_PART, _jpg_buf_len);
    res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);

    Reply
  53. I’ve finally found an easy to use free app that connects to multiple instances of the ESP32 cam board without issue, and allows remote viewing over the internet on a smartphone. It has all sorts of useful features like zoned motion detection that I haven’t had time to investigate yet.

    netcamstudio.com/ to download the desktop part of the app.

    Add cameras using the “Custom URL” tab in the “Add Source” window. Format is

    “http://192.168.xx.xx:80/capture”

    where the address is whatever your router has assigned to each ESP32 cam board.

    Hope that’s useful to others

    Reply
    • Hi Geoff.
      Thank you for sharing. This is definitely something that our readers are looking for and are interested in.
      Regards,
      Sara

      Reply
  54. As always, great work! I have a comment and a question. There is an option under the board manager for AI Thinker ESP 32 Cam. When I used that instead of the ESP32 Wrover Module my camera worked. Before that I was getting an error message. The question I have is that I can view the camera from Home Assistant only when I am connected in my network at home. If I am away, I can’t see the camera. Any ideas? Thanks again for all that you do. Great work!

    Reply
    • Hi John.
      You can only access the web server on your local network.
      I think home assistant has some options to access the dashboard from anywhere in the world.
      However, at the moment I don’t have any tutorial about that subject.
      Thank you for following our work
      Regards,
      Sara

      Reply
  55. I really appreciate all the effort you invest into these tutorials and videos. I tried this and I followed all your instructions and it worked after I selected the AI Thinker ESP 32 Cam option under the board manager. With this option you can only view the camera within your network and only one viewer at a time. Since this was not a solution what I wanted to implement, I look further into this and I found that you can easily integrate the same camera into Home Assistant using the Esp32 Cam node in EspHome. It’s much easier and now I can view my camera from anywhere and several people can access it at the same time. Thanks again for all your work.

    Reply
  56. Edit: I just outcommented the dl_lib.h and the Webserver with Accesspoint is working fine.

    Kind regards and greetings from Switzerland 🙂

    delf

    Reply
  57. I decided to buy one of this modules after reading the email from 13 June, but only today got a change to try it.

    I’ve bought my board on Ebay and it is not labeled as an “AI-Thinker” module.

    I’m working under Linux, just because Arduino IDE compile’s “years light” faster then under Windows.

    As usual there was a some troubles:
    1) The example did not compile, because “esp_camera.h” was missing. Solution: update the “esp32 by Espressif Systems version” (under Tools, Board, Boards Manager…) from version 1.0.0 to 1.0.2.
    2) When trying to upload there was an error message saying: “a fatal error occurred: Timed out waiting for packet content”. That one was hard to solve! I just solved it changing the “Upload Speed” (under Tools menu) from 921600 to 115200 (later I tried upper speeds and could got it at 460800); the one to blame it’s, maybe, my ftdi…?

    Finally it all worked as expected!

    Two final notes:
    1) Upload problems can be solved changing the “Upload Speed”.
    2) As John wrote on July 12, changing the Board to “AI Thinker ESP32-CAM” works very well and it removes the “Upload Speed” option from the Tools menu.

    Reply
  58. Thanks for the tutorial, very useful, got it working after fiddling around a bit with the FTDI and things.

    About the code, I would like to set a lower resolution, say VGA because the default 1600×1200 is too much for the camera, fps is very low and image lagging
    How can I do that?

    Regards

    Reply
    • I figured it out, you have to change the FRAMESIZE_ parameter like this:
      config.frame_size = FRAMESIZE_VGA;

      Maybe it helps someone else

      Reply
  59. I have non AIThinker cam module. There’s AP soft in it, under IP 192.168.4.1/jpg_stream video works, but i can’t upload other soft. Serial monitor says “rst… waiting for upload” and “Failed to connect to ESP32: Timed out waiting for packet header”. I use 3,3V, 5V, Arduino IDE, esp idf, FTDI, CH340, CP2102, Windows 7 x64, Linux mint, IO0+GND, breadboard, female conectors, RST button hold or press … nothing. Serial monitor works on settings: 115200, 40MHz, DIO.
    I read that unplugging the camera or IO2+GND could help. Someone tried? I haven’t tested yet.

    Reply
  60. Hi Sara
    Thank you for your projects
    Could you make a video tutorial for making a static IP address and post the video stream through it?

    Cheers
    Saman

    Reply
  61. Hi,
    Wonderful tutorials here. I followed one to connect my ESP32 Cam with Home Assistant. Is it possible to keep camera in deep sleep mode with a switch (software) to turn it on manually on need basis within Home Assistant? Appreciate any help.

    Reply
    • Hi.
      I don’t think so.
      At least, at the moment I have no idea how to do that with a software switch. Because it needs to be awake to receive something from Home Assistant (via MQTT for example).
      Regards,
      Sara

      Reply
  62. I have a different issue. I get the sketch to upload then it stops with an error message. Same in 3v or 5v

    Chip is ESP32D0WDQ6 (revision 1)
    Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
    MAC: cc:50:e3:95:22:64
    Uploading stub…
    Running stub…
    Stub running…
    Changing baud rate to 921600
    Changed.
    Configuring flash size…
    Warning: Could not auto-detect Flash size (FlashID=0x0, SizeID=0x0), defaulting to 4MB
    Compressed 8192 bytes to 47…

    Writing at 0x0000e000… (100 %)
    Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 2048.0 kbit/s)…

    A fatal error occurred: Timed out waiting for packet header
    A fatal error occurred: Timed out waiting for packet header

    Reply
  63. Dear Sara and Rui,

    please, do you know, why i cant connect to wifi ? I can see again just this in window. And again, again…

    ————-
    Brownout detector was triggered

    ets Jun 8 2016 00:22:57

    rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0018,len:4
    load:0x3fff001c,len:1100
    load:0x40078000,len:9232
    load:0x40080400,len:6400
    entry 0x400806a8
    ————–

    Thanks so much
    Jiri

    Reply
  64. Thanks for the great tutorial, I am looking at using my current build of MotionEyeOS on Raspberry Pi, and a cluster of 4 of these ESP32-cam’s and an old wifi router, to create a low power and dirt cheap backyard wildlife monitor. I will use the ESP32-CAM (x4) simply as wifi/IP cameras, I will probably remove the IR filters, and use some PIR’s with some IR Floodlights to illuminate the area at night. All of the ESP32-cams will connect to the router and the router will feed from the raspberry pi near the back yard. The raspberry pi will also have a Wifi dongle and connect to my home router, for accessing the MotionEyeOS. Then MotionEyeOS on the Raspberry Pi will do the motion detection, image/video storage, and can even do notifications and code executions based on the motion detection algorithm configurations in the software, no PIR’s needed for image or video recording based on motion in the video stream, and it is all accessible in one location.

    Reply
  65. Hello,
    Super tutorial.
    I wish I could attach an infrared detector (IR) with a remote control, to be able to put the ESP32-CAM dormant and wake up when I want it remotely.
    Do you think it’s possible?
    I tried, but I can not
    Thank you

    Reply
    • Hello I may have been poorly expressed because I write from France with a machine translation …
      Here, I would like to power my esp32-cam with 4 batteries of 1.2v and to save power, I would like to put the esp32-cam in sleep (deep sleep) with an infrared remote control, but I can not do the .ino program to achieve this, maybe this is not possible.
      My wish :
      Watch the streaming video, then put the esp32-cam on standby when I want, and later be able to put the streaming, all with a remote control and an infrared detector.
      You can tell me if this is possible and also how to do it, please?
      thank you in advance

      Reply
  66. Hello
    May you have a sample using a esp32-cam to build a web server and take a photo in the microsd card without using the sample?
    Thank You

    Reply
  67. After a fresh Arduino install (1.8.10) and loading of https://dl.espressif.com/dl/package_esp32_index.json I got this:

    error: dl_lib.h: No such file or directory

    Upon searching I found someone saying that that library had been eliminated in an recent release, and the sketch would probably compile if the include was removed.

    I commented out the include line and the sketch did compile and download and run properly, with camera streaming.

    Thanks for this tutorial.

    Reply
  68. Hello,

    I would like to have a fix IP address using my cellphone as personal hostpot. I’ve read the link you sent to me before “https://randomnerdtutorials.com/esp32-static-fixed-ip-address-arduino-ide/” but I’m still not able to make it work..

    Do you have any hints? Its impossible to know my gateway, since its 4G internet

    Reply
  69. I am using ESP Eye v2.1 which is very similar to this camera module and flashed the camera_web_server app that came with the examples folder from esp-who repo. The camera streamed very well. However, one issue I noticed with this streaming is that if you open the URL from multiple clients (i.e. from your computer and from your smartphone) at the same time, it only streams to one client and the other client do not display anything. When I close one client, then the other one picks up the stream. Seems like the streaming server can’t handle multiple client at once. Can you test from your end if this happens to you also. If so, is there any workaround for that?

    Reply
  70. Hi!

    I’ve tried the tutorial and is ok, but when i try to do the step in home assistant (Picture card), doesnt show any picture. If i acces with the ip with my browser the picture is ok.
    What could be do?

    Thanks a lot!

    Reply
    • Hi Again!
      I know what was happening. It was that it had open in the browser and it seems that it only serves a client as you have commented previously. Can it be done to make it visible to several clients?

      Reply
      • Hi Carlos.
        Yes, it only serves a client at a time.
        I don’t know if it is possible to make it visible to several clients.
        Streaming video is a very “heavy” task, so I’m not sure if the ESP32 is able to talk with several clients. We need to search a bit more about this.
        Regards,
        Sara

        Reply
  71. i just recived a replacemet for the faulty esp32cam i tried this sketch on a few months ago. but i get same error

    13:43:22.503 -> Camera init failed with error 0x20004

    i have tried uncommenting each model and re-uploading but i get the same error.
    this is the module i ordered
    ebay.com/itm/ESP32-ESP32-CAM-WiFi-Bluetooth-Module-Camera-Module-Development-Board-OV2640-NU/233172198639?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

    Reply
  72. Is it possible to use solar panels for the ESP32 cam powered by batteries?
    Is it possible that the live local streaming only starts when triggered by motion?

    Reply
    • Hi Malcom.
      Yes, that should be possible, but we don’t have any tutorial about those subjects.
      Maybe you can have the ESP32-CAM in deep sleep with external wake-up – it is awakened when there’s motion: https://randomnerdtutorials.com/esp32-external-wake-up-deep-sleep/
      When it wakes up, it streams video for a determined number of seconds (use timers to defined the number of seconds) and then, goes back to sleep again. That’s just a suggestion.
      Regards,
      Sara

      Reply
  73. Hello,
    Well, I used Rui’s codes about a year ago, and they worked correctly (both web server and face recognition)
    The web server is currently working and streaming, right now.

    I’m trying to upload again, without success.

    I’ve checked everything:

    Code is clean, settings as described
    #define CAMERA_MODEL_AI_THINKER,
    Wifi credentials are ok

    On Arduino IDE:
    – Board Manager: esp32 version 1.4 installed (also tried 1.2)
    – Board set to “AI-Thinker ESP-CAM”
    – Port set to the FTDI pgmr
    – FTDI set to 5V

    Wiring:
    – FTDI 5V -> ESP-cam “5V”
    – FTDI GND -> ESP-cam “GND”
    – FTDI TXD -> ESP-cam “UnR”
    – FTDI RXD -> ESP-cam “U0T” (also tried swapping them)
    – On ESP-cam, “IO0” and “GND” connected
    – Pressed the ESP “RST” button (also tried without)

    Upload sketch from IDE gives: (hidden the mac address below)
    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    ketch uses 770530 bytes (24%) of program storage space. Maximum is 3145728 bytes.
    Global variables use 48704 bytes (14%) of dynamic memory, leaving 278976 bytes for local variables. Maximum is 327680 bytes.
    esptool.py v2.6
    Serial port /dev/cu.usbserial-A9I7XDCI
    Connecting…….
    Chip is ESP32D0WDQ6 (revision 1)
    Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
    MAC: (((the_mac_address_of_my_ESP_board)))
    Uploading stub…
    Running stub…
    Stub running…
    Changing baud rate to 460800
    Changed.
    Configuring flash size…

    A fatal error occurred: Timed out waiting for packet header
    A fatal error occurred: Timed out waiting for packet header
    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

    No matter what I tried (reboot the computer, relaunch arduino IDE, changed to another USB port…), I always get the same result.

    Any Clue / hint / suggestion?

    thx in advance

    Reply
    • Ok never mind, I just found a workaround:

      Board: “ESP Wrover module”
      Partition scheme: “Huge APP (3MB, No OTA/1MB SPIFSS)

      => magic trick: I changed Upload Speed to “115200”
      *ANY* other value (incl. the default setting) gives the error

      Maybe that can help others with the same problem…

      Reply
  74. Dear Sara!
    I worry that esp32 cam has a compatibility issue with severa web browsers: My goal is not record the video, just broadcasting live picture – occassionally.

    I’ve tried to watch live stream with several browser while many couldn’t display. Hereby i enlisting:

    Google Chrome 80.0 . : Error message: Header fields are too long for server to interpret

    Microsoft Edge 20.1 .: start to download the stream to file, but not showing…

    Internet explorer 11.0 : start to download the stream to a file, but not showing…

    Firefox 72.2 : works perfectly, but i don’t dare to update, as i worry that will cause malfunctionality on show the camera stream.

    So, i think the camera HTTP header does not contain proper informations about the streaming to the webclients…

    What do you think? what browsers could you offer for live stream watch, and/or is there any bugfix available for the camera program?
    (I ve tried both of your projects, another one is directly start to streaming, and doesn’t have setting page, both are doing the same)

    Thanks for your response in advance!

    Reply
    • Hi.
      I’ve tested the project again, and it works well for me. I’m using Google Chrome.
      I don’t know what may be causing the issue.
      Please note that you can only have one tab opened with the video streaming at the time.

      I’ve found this discussion that addresses that problem but I don’t know if you’ll find an answer: https://github.com/espressif/arduino-esp32/issues/2983
      I hope you find it useful.
      Regards,
      Sara

      Reply
  75. Hi Rui and Sara,

    when i used the code with the video stream i have an issue, the default code works great.
    But if i add #include which i want to use as a second server with on a different port, just adding this statement make the compiler go crazy, just try it yourself and you will see.

    Seem to be a compatibility issue between libraries.

    What do you think ?

    Kind regards
    Otto

    Reply
  76. Hi,
    I have successfully completed the project and it is running fine. What I noticed though is that the device can’t handle multiple instances, i.e. access camera from multiple sources. Can we overcome this. I’m running on 5V.
    Rgds
    Dick

    Reply
    • Hi.
      At the moment, we don’t have any solution for that. The ESP32-CAM can’t handle multiple clients at the same time.
      Regards,
      Sara

      Reply
    • Hi Dick,
      I was just about to ask the same qustion…
      I am running Home Assistant on my Raspberry Pi and quite often have Home Assistant on my computer which means I can’t look at the Camera via my Mobile Phone or via HA on my phone or if I try looking at the IP address directly.
      Have you found a work around yet?
      (I have noticed the comment from Sara)
      Regards Adrian

      Reply
  77. I enjoyed your articular on ESP32-CAM Video Streaming Web Server the problem I have is I am setting up 4 and the cameras have different orientations and I cannot find any way in the code to Vflip or Hmirror the video any suggestions would be appreciated
    Thank You
    Paul

    Reply
  78. Hi I have this problem with my esp32-cam and my web server can’t start 🙁

    19:26:52.246 -> [E][sccb.c:154] SCCB_Write(): SCCB_Write Failed addr:0x30, reg:0x35, data:0xda, ret:263
    19:26:52.280 -> [E][sccb.c:154] SCCB_Write(): SCCB_Write Failed addr:0x30, reg:0xff, data:0x00, ret:263
    19:26:52.488 -> [E][sccb.c:154] SCCB_Write(): SCCB_Write Failed addr:0x30, reg:0x05, data:0x01, ret:-1
    19:26:52.488 -> [E][camera.c:1215] camera_init(): Failed to set frame size
    19:26:52.488 -> [E][camera.c:1270] esp_camera_init(): Camera init failed with error 0x20002

    Reply
  79. HI~
    How can I turn the internal-flashlight on and off? (ESP32-CAM Video Streaming Web Server)
    homeassistant

    Thank you.

    Reply
    • Hi.
      The flashlight is connected to GPIO 4.
      So, you control it like any other GPIO.
      Here’s an example:

      // ledPin refers to ESP32-CAM GPIO 4 (flashlight)
      const int ledPin = 4;
      void setup() {
      // initialize digital pin ledPin as an output.
      pinMode(ledPin, OUTPUT);
      }
      void loop() {
      digitalWrite(ledPin, HIGH);
      delay(2000);
      digitalWrite(ledPin, LOW);
      delay(2000);
      }
      Regards,
      Sara

      Reply
  80. Just a note to everyone using the node red example, in src use “http://” instead of “https://”, it doesnt work with the s version

    Reply
  81. Works great – thanks!

    In case it helps anyone, with the KeeYees kits from amazon.de (amazon.de/gp/product/B07S83X9NM/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&language=en_GB&psc=1) the default settings in this tutorial/sketch worked for me:

    • ESP32 dev module in the Arduino IDE
    • AI Thinker camera module in the code

    Be careful as the connection diagram showing how to connect the ESP32 to the FTDI board (near the start of this tutorial) is a bit confusing: the connections shown on the FTDI board are reversed, so be careful and read the (tiny) text on the FTDI board before connecting the boards.

    Reply
  82. Hi
    I have problm with my ESP32-CAM. Can someone help me understand what im doing wrong.

    Sketch uses 724094 bytes (23%) of program storage space. Maximum is 3145728 bytes.
    Global variables use 48640 bytes (14%) of dynamic memory, leaving 279040 bytes for local variables. Maximum is 327680 bytes.
    esptool.py v2.6
    Serial port COM4
    Connecting……..__
    Chip is ESP32D0WDQ6 (revision 1)
    Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
    MAC: 3c:71:bf:f1:ac:cc
    Uploading stub…
    Running stub…
    Stub running…
    Configuring flash size…
    Auto-detected Flash size: 4MB
    Compressed 8192 bytes to 47…
    Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 6553.6 kbit/s)…
    Hash of data verified.
    Compressed 17392 bytes to 11186…
    Wrote 17392 bytes (11186 compressed) at 0x00001000 in 1.0 seconds (effective 139.8 kbit/s)…
    Hash of data verified.
    Compressed 724208 bytes to 430586…
    Wrote 724208 bytes (430586 compressed) at 0x00010000 in 38.2 seconds (effective 151.7 kbit/s)…
    Hash of data verified.
    Compressed 3072 bytes to 119…
    Wrote 3072 bytes (119 compressed) at 0x00008000 in 0.0 seconds (effective 1445.7 kbit/s)…
    Hash of data verified.

    Leaving…
    Hard resetting via RTS pin…

    Thank you

    Ardi

    Reply
  83. Thank you for some great tutorials, really enjoyed them and they have been very helpful. However I have a problem with this one. I have installed this on two different ESP32-cam cards but both suffer from the same issue. At the outset it works as expected, but after some hours (12-20 hours) the server seem to crash and become unresponsive. If I unplug power and reconnect it will work for hours again before the same happens. As mentioned behaviour is the same with two different cards. I have also tried several different power sources to rule out unstable power supply as the reason. So I am a little lost here. Any ideas?
    As a work around I was contemplating implementing an hourly reboot, but not sure how to do so through software. Any pointers?

    Reply
  84. Hey guys!

    I’ve been trying to get this code running on my ESP32-CAM module for a few days and I just can’t get it to work.

    My module is an AI-Thinker (the same you have on the photos). It works fine with an ESPHOME generated code or the basic webserver demo code.

    After uploading the code provided on this page, it enters an endless reboot cycle and I can’t get anything on the serial monitor.

    Since I know this is a power-hungry module, I’ve also tried powering it with my lab power supply. Same behavior of endless reboot cycles.

    I noticed you mentioned selecting the Huge app partition profile in a previous post. On a fresh install of the Arduino IDE, these options aren’t available in the tools menu when selecting the AI Thinker board. They are when other ESP32 boards are selected.

    Just in case, I also tried to compile using the ESP32dev and wrover boards profiles (which do have the partitioning options available). Obviously, these didn’t work either.

    Just to be sure, I’ve also tried programming it with both 3v and 5v logic.

    I’m running out of things to try to make this code work on my board. Any ideas of what else I could try?

    Thanks!

    Reply
      • Hello Sara!

        I tried programming 2 ESP32-CAM boards with the ESP32 Wrover profile.

        Both end up with the same endless reboot problem.

        Reply
        • Hi Richard,

          The endless reboot problem may be related to the Wifi portion of the project. I suggest building a sketch with the WiFi ONLY to test. See below. If you can get this working with no issues then move on to include the camera.

          //Wireless for ESP 32
          #include <WiFi.h>
          char ssid[] = “yourSSID”; // your network SSID (name)
          char pass[] = “yourpassword”; // your network password

          void setup()
          {
          Serial.begin(115200);Serial.println(); Serial.println(“Power Up”);
          Serial.print(“Connecting to “); Serial.println(ssid);
          WiFi.begin(ssid, pass);
          while (WiFi.status() != WL_CONNECTED)
          {
          delay(500);
          Serial.print(“.”);
          }
          Serial.println(“”); Serial.println(“WiFi connected”);
          Serial.println(“IP address: “);Serial.println(WiFi.localIP());
          Serial.println(“End of Setup.”);
          }

          void loop() {
          }

          Reply
          • Hello again!

            I finally got it to work. I ended up reinstalling Arduino and the required board definitions.

            Thanks for taking the time to help me out with this troubleshooting.

            😀

  85. Richard, Thanks for sharing your solution.
    For other users with similar issues, I suggest to re-install the “board definitions” before re-install Arduino. I experienced similar situations in the past. The “board definitions” were not “stable”. When I switched between ESP 32 and ESP 8266. In most cases, the “board definitions” need to be re-installed – very odd with Arduino 1.8.11!

    Reply

Leave a Reply to Rick Cancel reply

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.