ESP32 CAM
ESP32 CAM
Processor
The ESP32-S contains a Tensilica Xtensa® LX6 microprocessor with two 32-
bit cores operating at a staggering 240 MHz! This is what makes the ESP32-S
suitable for intensive tasks like video processing, facial recognition, and even
artificial intelligence.
The Memory
Memory is paramount for complex tasks, so the ESP32-S has a full 520
kilobytes of internal RAM, which resides on the same die as the rest of the
chip’s components.
It may be inadequate for RAM-intensive tasks, so ESP32-CAM includes 4 MB
of external PSRAM (Pseudo-Static RAM) to expand the memory capacity.
This is plenty of RAM, especially for intensive audio or graphics processing.
All these features amount to nothing if you don’t have enough storage for your
programs and data. The ESP32-S chip shines here as well, as it contains 4
MB of on-chip flash memory.
The Camera
The OV2640 camera sensor on the ESP32-CAM is what sets it apart from
other ESP32 development boards and makes it ideal for use in video projects
like a video doorbell or nanny cam.
The OV2640 camera has a resolution of 2 megapixels, which translates to a
maximum of 1600×1200 pixels, which is sufficient for many surveillance
applications.
The Storage
The addition of a microSD card slot on the ESP32-CAM is a nice bonus. This
allows for limitless expansion, making it a great little board for data loggers or
image capture.
The Antenna
LEDs
Technical Specifications
Processors:
o CPU: Xtensa dual-core 32-bit LX6 microprocessor, operating at 240
MHz and performing at up to 600 DMIPS
o Ultra low power (ULP) co-processor
Memory:
o 520 KB SRAM
o 4MB External PSRAM
o 4MB internal flash memory
Wireless connectivity:
o Wi-Fi: 802.11 b/g/n
o Bluetooth: v4.2 BR/EDR and BLE (shares the radio with Wi-Fi)
Camera:
o 2 Megapixel OV2640 sensor
o Array size UXGA 1622×1200
o Output formats include YUV422, YUV420, RGB565, RGB555 and 8-bit
compressed data
o Image transfer rate of 15 to 60 fps
o Built-in flash LED
o Support many camera sensors
Supports microSD card
Security:
o IEEE 802.11 standard security features all supported, including WFA,
WPA/WPA2 and WAPI
o Secure boot
o Flash encryption
o 1024-bit OTP, up to 768-bit for customers
o Cryptographic hardware acceleration: AES, SHA-2, RSA, elliptic curve
cryptography (ECC), random number generator (RNG)
Power management:
o Internal low-dropout regulator
o Individual power domain for RTC
o 5μA deep sleep current
o Wake up from GPIO interrupt, timer, ADC measurements, capacitive
touch sensor interrupt
Schematic and Datasheets
It ranges from 80 mAh when not streaming video to around 100~160 mAh
when streaming video; with the flash on, it can reach 270 mAh.
ESP32-CAM Pinout
The ESP32-CAM has 16 pins in total. For convenience, pins with similar
functionality are grouped together. The pinout is as follows:
Power Pins There are two power pins: 5V and 3V3. The ESP32-CAM can be
powered via the 3.3V or 5V pins. Since many users have reported problems
when powering the device with 3.3V, it is advised that the ESP32-CAM always
be powered via the 5V pin. The VCC pin normally outputs 3.3V from the on-
board voltage regulator. It can, however, be configured to output 5V by using
the Zero-ohm link near the VCC pin.
GPIO Pins The ESP32-S chip has 32 GPIO pins in total, but because many of
them are used internally for the camera and the PSRAM, the ESP32-CAM
only has 10 GPIO pins available. These pins can be assigned a variety of
peripheral duties, such as UART, SPI, ADC, and Touch.
UART Pins The ESP32-S chip actually has two UART interfaces, UART0 and
UART2. However, only the RX pin (GPIO 16) of UART2 is broken out, making
UART0 the only usable UART on the ESP32-CAM (GPIO 1 and GPIO 3).
Also, because the ESP32-CAM lacks a USB port, these pins must be used for
flashing as well as connecting to UART-devices such as GPS, fingerprint
sensors, distance sensors, and so on.
MicroSD Card Pins are used for interfacing the microSD card. If you aren’t
using a microSD card, you can use these pins as regular inputs and outputs.
ADC Pins On the ESP32-CAM, only ADC2 pins are broken out. However,
because ADC2 pins are used internally by the WiFi driver, they cannot be
used when Wi-Fi is enabled.
SPI Pins The ESP32-CAM features only one SPI (VSPI) in slave and master
modes.
PWM Pins The ESP32-CAM has 10 channels (all GPIO pins) of PWM pins
controlled by a PWM controller. The PWM output can be used for driving
digital motors and LEDs.
To program this device, you’ll need either a USB-to-serial adapter (an FTDI
adapter) or an ESP32-CAM-MB programmer adapter.
Many FTDI programmers have a jumper that lets you choose between 3.3V
and 5V. As we are powering the ESP32-CAM with 5V, make sure the jumper
is set to 5V.
Please note that the GPIO 0 pin is connected to Ground. This connection is
only necessary while programming the ESP32-CAM. Once you have finished
programming the module, you must disconnect this connection.
Remember! You’ll have to make this connection every time you want to
upload a new sketch.
Using the FTDI Adapter to program the ESP32-CAM is a bit of a hassle. This
is why many vendors now sell the ESP32-CAM board along with a small add-
on daughterboard called the ESP32-CAM-MB.
You stack the ESP32-CAM on the daughterboard, attach a micro USB cable,
and click the Upload button to program your board. It’s that simple.
The highlight of this board is the CH340G USB-to-Serial converter. That’s
what translates data between your computer and the ESP32-CAM. There’s
also a RESET button, a BOOT button, a power indicator LED, and a voltage
regulator to supply the ESP32-CAM with plenty of power.
To use the ESP32-CAM, or any ESP32, with the Arduino IDE, you must first
install the ESP32 board (also known as the ESP32 Arduino Core) via the
Arduino Board Manager.
If you haven’t already, follow this tutorial to install the ESP32 board:
After installing the ESP32 Arduino Core, restart your Arduino IDE and
navigate to Tools > Board > ESP32 Arduino and select AI-Thinker ESP32-
CAM.
Now connect the ESP32-CAM to your computer using a USB cable. Then,
navigate to Tools > Port and choose the COM port to which the ESP32-CAM
is connected.
That’s it; the Arduino IDE is now set up for the ESP32-CAM!
Once you’ve finished the preceding steps, you are ready to test your first
program with your ESP32-CAM! Launch the Arduino IDE. If you disconnected
your board, plug it back in.
This sketch uses the on-board Camera Flash LED. This LED is connected to
GPIO 4.
Copy
int flashPin = 4;
void setup() {
pinMode(flashPin, OUTPUT);
}
void loop() {
digitalWrite(flashPin, HIGH);
delay(1000);
digitalWrite(flashPin, LOW);
delay(1000);
}
Now, press the upload button. If you are using the FTDI adapter, disconnect
GPIO 0 from GND after uploading the code. To execute the sketch, you may
need to press the Reset button on your ESP32-CAM.
You will see a selection of example sketches. You can choose any of them to
load the sketch into your IDE and start experimenting with it.
ESP32-CAM Example 2 : Live Video Streaming Server
Let’s try running the CameraWebServer sketch. This sketch transforms the
ESP32-CAM into a full-featured webcam, complete with features like face
detection and a ton of customization options. This is a very impressive
example of what the ESP32-CAM can do!
You can find this example under File > Examples > ESP32 > Camera >
CameraWebServer.
We’ll need to make a few changes to get this to work with your ESP32-CAM.
You must choose the appropriate camera model. Because we’re using the AI-
THINKER model here, uncomment it and comment all the other models.
Copy
// ===================
// Select camera model
// ===================
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera
version B Has PSRAM
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
// ** Espressif Internal Boards **
//#define CAMERA_MODEL_ESP32_CAM_BOARD
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
Next, you need to tell the ESP32-CAM about your wireless network. Fill in the
following variables with your network credentials:
Copy
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";
Launch a browser and enter the IP address shown on the serial monitor.
Ensure that the web browser is on the same network that the ESP32-CAM is
connected to.
The ESP32-CAM should display a web page. To begin video streaming, press
the Start Stream button.
You can play around with various camera settings in the left pane. For
instance, you can alter the video’s resolution and frame rate, as well as its
brightness, contrast, saturation, and the like.
Simply hit the Get Still button to take a picture. Note that images are
downloaded to the computer rather than being saved to the microSD card.
If you are too far away from your router, you may experience slow video
streaming and other connectivity issues, in which case you should use a
2.4GHz external antenna with an IPX connector. For this, you need to change
the antenna jumpers around to enable the u.FL connector.
A trio of solder pads are located next to the u.FL connector and between the
on-board antenna and the ESP32-S’s metal case. A zero-ohm resistor
connects the top two pads. Simply remove this resistor and place it between
the bottom pads.