MakerLab
ESP32ESP32-CAM

ESP32-CAM: Your Gateway to Vision Projects on a Budget

This compact, low-cost module combines an ESP32 microcontroller with a camera, enabling Wi-Fi and Bluetooth enabled image capture and processing for embedded vision applications.

ESP32-CAM

The ESP32-CAM is a highly integrated development board designed for embedded vision applications. It features the popular ESP32-S chip, which is a dual-core Tensilica LX6 microprocessor with integrated Wi-Fi and Bluetooth connectivity. This makes it a powerful and versatile platform for projects that require both computation and wireless communication, especially those involving image capture and processing.

At its heart is the ESP32-S SoC, a System-on-Chip that packs significant processing power into a small footprint. It boasts two Xtensa LX6 cores running at up to 240 MHz, ample SRAM, and a host of peripherals including I2S, SPI, I2C, UART, and ADC. The ESP32-CAM specifically adds an interface for an OV2640 camera module, making it ideal for projects like remote surveillance, time-lapse photography, or even basic object recognition.

Released around 2019 by AI-Thinker, the ESP32-CAM quickly gained popularity among makers and hobbyists due to its incredibly low cost and the integration of camera functionality directly onto the development board. While other ESP32 boards offer more GPIO pins or specific features, the ESP32-CAM's primary focus is on camera-centric projects, making it a go-to choice for anyone looking to add visual capabilities to their IoT projects without breaking the bank.

This board is particularly well-suited for makers, students, and embedded engineers who are interested in exploring the world of computer vision and image processing on a microcontroller. Its ease of use with the Arduino IDE, combined with its powerful features, makes it accessible to beginners while still offering enough depth for more advanced projects. If you want to build a smart doorbell, a remote monitoring system, or experiment with AI on the edge, the ESP32-CAM is an excellent starting point.

Watch

Related video, embedded from YouTube.

Specifications

Microcontroller / SoCESP32-S (ESP32-WROOM-32E module, often with integrated flash)
ArchitectureDual-core Tensilica Xtensa LX6
Clock speedUp to 240 MHz
Flash / Storage4MB (on-board module)
RAM / SRAM520 KB SRAM
Operating voltage3.3V
Digital I/O pins16 (exposed, but many used internally for camera/flash)
Analog / ADC2x 12-bit SAR ADCs (shared with other functions)
PWM8 channels (software configurable)
ConnectivityWi-Fi 802.11 b/g/n, Bluetooth v4.2 BR/EDR and BLE
USBNone (requires external USB-to-Serial adapter for programming)
Power input5V via micro-USB or VIN pin
DimensionsApprox. 27 x 40.5 x 4.5 mm (PCB only, excluding headers)

Pinout & pin functions

PinFunction
5VInput voltage (typically from USB or VIN)
GNDGround
3V33.3V output (regulated)
VINInput voltage (typically 5V)
GPIO0Boot mode selection (low during boot for flashing)
GPIO2LED Flash (often connected to onboard LED), also used for camera
GPIO4Camera data line (D4)
GPIO5Camera clock line (XCLK)
GPIO12Camera data line (D12)
GPIO13Camera data line (D5)
GPIO14Camera data line (D6)
GPIO15Camera data line (D7)
GPIO16 (RX2)UART2 RX (used for serial communication)
GPIO17 (TX2)UART2 TX (used for serial communication)
GPIO18Camera data line (D0)
GPIO19Camera data line (D2)
GPIO21I2C SDA
GPIO22I2C SCL
GPIO23Camera data line (D3)
GPIO25Camera data line (D8)
GPIO26Camera data line (D9)
GPIO27Camera data line (D10)
GPIO32Camera data line (D11)
GPIO33Camera data line (D13)
VSYNCCamera Vertical Sync
HREFCamera Horizontal Reference
PCLKCamera Pixel Clock
AI_0ADC1_CH0 (also GPIO36)
AI_2ADC1_CH3 (also GPIO39)
AI_3ADC1_CH6 (also GPIO34)
AI_6ADC1_CH4 (also GPIO33)
AI_9ADC2_CH3 (also GPIO4)

Wiring & circuit basics

Powering the ESP32-CAM requires careful attention to voltage levels. The board operates at 3.3V, but it can be powered via a micro-USB port or the VIN pin, which typically accepts 5V. An onboard voltage regulator steps this down to 3.3V for the ESP32-S chip and other components. It's crucial to avoid applying more than 5V to the VIN pin or the micro-USB port, as this could damage the board. Ensure a stable power supply, especially when the camera is active, as it can draw significant current spikes. A current of at least 500mA is recommended for reliable operation.

All GPIO pins on the ESP32-CAM operate at 3.3V logic levels. Connecting 5V devices directly to these pins can cause permanent damage. If you need to interface with 5V components, such as many common LEDs or sensors, you must use a level shifter. For example, to connect a 5V LED, you would connect the ESP32-CAM's 3.3V output to the LED's anode, the LED's cathode to a current-limiting resistor (e.g., 220-330 ohms), and the other end of the resistor to a GND pin on the ESP32-CAM.

For connecting sensors, such as an I2C-based sensor like the BME280, you would use the dedicated I2C pins. Connect the sensor's VCC to the ESP32-CAM's 3.3V pin, the sensor's GND to a GND pin, the sensor's SDA to GPIO21 (SDA), and the sensor's SCL to GPIO22 (SCL). Remember that if the sensor operates at 5V, you will need a level shifter between the ESP32-CAM's I2C pins and the sensor's I2C pins.

Programming & getting started

The ESP32-CAM is most commonly programmed using the Arduino IDE, thanks to excellent community support and readily available libraries. To get started, you'll need to add the ESP32 board support to your Arduino IDE via the Board Manager. Once installed, select the 'AI Thinker ESP32-CAM' board from the Tools > Board menu. You will also need an external USB-to-Serial adapter (like an FTDI or CP2102 based module) connected to the UART pins (GPIO16 for RX, GPIO17 for TX) and GPIO0 to GND during boot for flashing.

To upload your first sketch, connect the USB-to-Serial adapter to your computer and the ESP32-CAM. Ensure GPIO0 is pulled low (connected to GND) before powering the board or resetting it. Open a simple sketch, like the 'Blink' example, modified to toggle an onboard LED (often connected to GPIO2). Select the correct COM port for your USB-to-Serial adapter and click the Upload button. Once uploaded, disconnect the USB-to-Serial adapter, remove the jumper from GPIO0 to GND, and reset the board to run your program. For more advanced development, you can also use ESP-IDF or PlatformIO.

Project ideas

Wi-Fi Connected Security CameraCapture images or video streams from the OV2640 camera and stream them over Wi-Fi to a web browser or a mobile app. This project uses GPIO pins for camera interface, Wi-Fi for connectivity, and teaches about streaming protocols and basic image handling.
Motion-Activated Alert SystemSet up the ESP32-CAM to detect motion using image differencing or a PIR sensor, and send an email or push notification when motion is detected. This utilizes the camera for image capture, Wi-Fi for communication, and introduces concepts of event-driven programming.
Time-Lapse Photography DeviceProgram the ESP32-CAM to take photos at regular intervals and store them on an SD card (if available) or upload them to cloud storage. This project explores timer-based operations, file system interaction, and efficient image storage.
QR Code ScannerUse the ESP32-CAM to read QR codes from its environment and decode the information, then transmit it over Wi-Fi or display it. This involves using a QR code decoding library and understanding camera calibration and image processing techniques.
Remote Object Detection (Basic)With sufficient processing power and libraries, experiment with basic object detection models running on the ESP32-CAM to identify simple objects. This is an entry into edge AI, requiring careful optimization and understanding of machine learning frameworks.
Smart Doorbell with Image CaptureCombine the ESP32-CAM with a button and potentially a PIR sensor to capture an image of visitors when the button is pressed or motion is detected, and send it to your phone. This integrates multiple peripherals and communication protocols for a practical IoT application.

Buying tips & gotchas

When purchasing an ESP32-CAM, be aware that many low-cost versions come without a USB-to-Serial converter, requiring you to buy one separately. Also, ensure you get a model with the ESP32-S module, as older versions might use different ESP32 variants. The OV2640 camera is common, but quality can vary. Some ESP32-CAM boards include a microSD card slot, which is highly recommended for storing images and firmware updates. Be mindful of pin conflicts, as many GPIOs are used by the camera interface; consult pinout diagrams carefully. Always use a stable 5V power supply, and consider adding a heatsink if running demanding image processing tasks.