The ESP32-CAM is one of the most incredible bargains in the maker world. For just a few dollars, you get a powerful Wi-Fi microcontroller slapped together with a tiny camera module. We are going to build a standalone IP surveillance camera. It will host its own web server and stream live video to your phone. Now you can finally figure out which cat is destroying the couch.

The Gear You Need

(Links above are affiliate links. As an Amazon Associate, we earn from qualifying purchases.)

Setting Up the ESP32-CAM for Programming

Because the ESP32-CAM lacks a USB port, wiring it to an FTDI programmer can be slightly tricky the first time.

Wiring to the FTDI Programmer:

CRITICAL STEP: The Flash Jumper To put the ESP32-CAM into “programming mode,” you must connect GPIO 0 to GND before you plug the FTDI adapter into your computer.

  1. Use a jumper wire to connect IO0 to GND on the ESP32-CAM.
  2. Plug the USB into your PC.
  3. Upload the code.
  4. Unplug the USB, remove the IO0 to GND jumper wire, and plug it back in to run normally!

Installing ESP32 Board Support

If you haven’t used an ESP32 in the Arduino IDE before, you need to add the board manager URL:

  1. Go to File > Preferences.
  2. Add this URL to the “Additional Boards Manager URLs” field: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  3. Go to Tools > Board > Boards Manager, search for “esp32”, and click Install.
  4. Select AI Thinker ESP32-CAM from the board list.

The Code (CameraWebServer)

The code to stream video is actually built right into the ESP32 Arduino core examples! It is highly optimized and includes face detection/recognition libraries.

  1. Go to File > Examples > ESP32 > Camera > CameraWebServer.
  2. Comment out all the camera models except the AI Thinker:
    // #define CAMERA_MODEL_WROVER_KIT
    // #define CAMERA_MODEL_ESP_EYE
    // #define CAMERA_MODEL_M5STACK_PSRAM
    // #define CAMERA_MODEL_M5STACK_WIDE
    #define CAMERA_MODEL_AI_THINKER
  3. Enter your Wi-Fi credentials:
    const char* ssid = "YOUR_WIFI_SSID";
    const char* password = "YOUR_WIFI_PASSWORD";
  4. Click Upload. (Don’t forget to have GPIO 0 tied to GND!). If the IDE says “Connecting…”, press the small reset button on the bottom of the ESP32-CAM board.

Viewing the Stream

Once the upload is done:

  1. Unplug the USB cable.
  2. Remove the jumper wire between GPIO 0 and GND.
  3. Plug the USB cable back in to power the board.
  4. Open the Arduino Serial Monitor at 115200 baud.
  5. Press the reset button on the ESP32-CAM again.
  6. The Serial Monitor will print out an IP Address (e.g., http://192.168.1.150).
  7. Open a web browser on a device connected to the same Wi-Fi network and go to that IP address.

Click “Start Stream” at the bottom of the web interface, and you will see live video from your new DIY surveillance camera!

Next Steps