The ESP 32 eye camera is a development board by the Espressif system which is based on the ESP32-S chip. It is a low-cost development board with an in-built camera. ESP 32 eye camera can be used as an ideal solution for many IoT applications, construction of prototypes,s and many DIY(Do It Yourself) projects.
The board is integrated with WiFi and low-power BLE along with two high-performance 32-bit LX6 CPUs. ESP 32 eye camera board is also capable of streaming low latency video while maintaining low power consumption. The development of the ESP 32 eye camera board has created a huge impact on the AI and IoT sector by providing ideal solutions for most of the issues.
That is all in the introduction of the ESP 32 eye camera development board, Let us discuss about the onboard components of the ESP 32 eye camera board.
On board Components of ESP 32 eye camera
2 MP camera – The board has an onboard OV2640 2 MP(megapixel) camera which is capable of capturing VGA resolution images and videos.
ESP32-WROVER-B Module – The board features the ESP32 dual-core microcontroller with Wi-Fi and Bluetooth connectivity.
Antennas – The ESP 32 eye camera board has built-in antennas for both Wi-Fi and Bluetooth communication. It allows wireless connectivity for data transmission.
Micro USB Port – There is a Micro USB port available on the board which is used for power supply as well as for programming the ESP32 module. The Micro USB port also provides a convenient way for flashing the firmware.
MicroSD Card Slot – There is a Micro SD card slot available which is used for expansion of storage by using a MicroSD card.
Reset and Boot Buttons – RESET and Boot Buttons are used for resetting the device as well as for entering into the boot mode for flashing the firmware.
Voltage Regulators – Voltage regulators are available on the board for regulating the voltage supply to the board which protects the board from getting damaged.
Power LED – There is an inbuilt power LED present in the ESP 32 eye camera board which is red in color and it will start blinking when the board is connected to a power supply.
PSRAM – Additional RAM on ESP 32 eye camera board which is integrated onto the board for enhancing the capabilities of the board like image and video processing.
Board Features
Board | ESP 32 eye camera board |
Processor | ESP32-WROVER-B |
Antenna | Inbuilt |
Board Dimension | 41 x 21 mm |
I/O Port | 10 |
ADC | 7 |
Interfaces | UART, SPI, I2C |
Flash Memory | 8MB |
PWM | 10 |
Power Consumption of ESP 32 eye camera
Power supply | 2.2-3.6v |
Current Consumption | 70 – 100mA |
I/O voltage | 0-3.3v |
Modem sleep | 20mA |
Light sleep | 6.7mA |
Deep sleep | 6mA |
Now let us have a look at the pinout of the ESP 12E board.
Pinout OF ESP 32 eye camera
Power Pins
There are two power pins available on the board which are a 3.3v pin and a 5v pin. These pins are used for power supply to the board. It is reported that connecting the power supply of the board to the 3.3v pin generates an error so it is recommended to use a 5v pin for the power supply to the board.
S.no | Type | Pin name |
1 | Input | 5V |
2 | Input | 3.3v |
Power Output Pin
There is a power output pin available on the board which is labeled as VCC and you should never connect it as an input pin for the ESP 32 eye cam board as this pin is used to output 5V or 3.3V.
S.no | Type | Pin name |
1 | Output | VCC |
GPIO 0 pin
The most important pin on the board is the GPIO 0 pin. This pin determines whether the ESP32 is in flashing mode or not.
The GPIO 0 must remain at HIGH during boot and LOW during flashing and for this purpose, we use a 10K resistor to pull it internally. Whenever we connect the GPIO 0 pin to the GND, the ESP32 eye cam board enters into flash mode, and now we can upload the code to the board. After we complete this task we must disconnect this connection.
S.no | Type | Pin name |
1 | I/O | GPIO 0 |
Input Output Pins
There are a total of 10 digital input/output pins available on the ESP 32-eye camera board. The digital pins are used as an input or output according to the requirement. The digital pins are only able to read two values which are:-
- High
- Low
However, we can use 1 for high state and 0 for low state. When these pins receive 0V they are in a LOW state and when they receive 5V they are in the HIGH state.
The digital pins on the ESP 32-eye camera board are
S.no | Type | Pin name |
1 | I/O | GPIO 0 |
2 | I/O | GPIO 1 |
3 | I/O | GPIO 2 |
4 | I/O | GPIO 3 |
5 | I/O | GPIO 4 |
6 | I/O | GPIO 12 |
7 | I/O | GPIO 13 |
8 | I/O | GPIO 14 |
9 | I/O | GPIO 15 |
10 | I/O | GPIO 16 |
PWM Pin
There are a total of 10 pins available on the ESP 32 eye camera board which are also known as Pulse Width Modulation pins. The work of these PWM pins is to convert the digital inputs to analog output. These pins provide 8-bit PWM output with the analogWrite () function.
The PWM pins of the board are
S.no | Type | Pin name |
1 | Input | GPIO 0/PWM |
2 | Input | GPIO 1/PWM |
3 | Input | GPIO 2/PWM |
4 | Input | GPIO 3/PWM |
5 | Input | GPIO 4/PWM |
6 | Input | GPIO 12/PWM |
7 | Input | GPIO 13/PWM |
8 | Input | GPIO 14/PWM |
9 | Input | GPIO 15/PWM |
10 | Input | GPIO 16/PWM |
ADC Pin
There are a total of 7 ADC pins available on the board which are used to convert the analog signal to digital signal. The ADC pins of the ESP 32 eye camera board are as follows
S.no | Type | Pin name |
1 | I/O | ADC2_0 |
2 | I/O | ADC2_1 |
3 | I/O | ADC2_2 |
4 | I/O | ADC2_3 |
5 | I/O | ADC2_4 |
6 | I/O | ADC2_5 |
7 | I/O | ADC2_6 |
Micro SD Card Pins
These pins are used to interface the Micro SD card. If you are not using any SD card then you should use these pins as regular input and output pins.
S.no | Type | Pin name |
1 | I/O | GPIO 2 |
2 | I/O | GPIO 4 |
3 | I/O | GPIO 12 |
4 | I/O | GPIO 13 |
5 | I/O | GPIO 14 |
6 | I/O | GPIO 15 |
Touch Pins
The ESP32-CAM has 7 capacitive touch-sensing GPIOs which detects change in capacitance when a capacitive load is close to the GPIO.
S.no | Type | Pin name |
1 | I/O | GPIO 0 |
2 | I/O | GPIO 2 |
3 | I/O | GPIO 4 |
4 | I/O | GPIO 12 |
5 | I/O | GPIO 13 |
6 | I/O | GPIO 14 |
7 | I/O | GPIO 15 |
RTC GPIO Pins
RTC GPIO pins are nothing but the regular GPIO pins which are routed to the RTC low-power subsystem. These pins are generally used for waking up the ESP32 eye-cam board from deep sleep when the ULP(Ultra Low Power) co-processor is running. There are 7 RTC GPIO pins available on the board which are as follows
S.no | Type | Pin name | Pin Mapping |
1 | I/O | RTC_GPIO 10 | GPIO 0 |
2 | I/O | RTC_GPIO 11 | GPIO 2 |
3 | I/O | RTC_GPIO 12 | GPIO 4 |
4 | I/O | RTC_GPIO 13 | GPIO 12 |
5 | I/O | RTC_GPIO 14 | GPIO 13 |
6 | I/O | RTC_GPIO 15 | GPIO 14 |
7 | I/O | RTC_GPIO 16 | GPIO 15 |
Communication Pins of ESP 32 eye cam board
SPI Pins
The ESP 32 eye cam board supports the “Semi-peripheral Communication Protocol” or SPI. The SPI protocol is used to develop communication between the controller device and its peripheral devices. In the ESP 32 eye cam board 6 pins are needed for SPI communication protocol which are:-
S.NO | Type | Pin Name |
1 | I/O | HSPI_Q |
2 | I/O | HSPI_ID |
3 | I/O | HSPI_CS0 |
4 | I/O | HSPI_CLK |
5 | I/O | HSPI_WP |
6 | I/O | HSPI_HD |
UART Pins
The ESP 32 eye cam board has 2 UART interfaces which are UART 0 and UART 2 however only the RX pin of the UART 2 is broken out which makes UART 0 only usable UART. The pin mapping of the UART pins are as follows
S.NO | Type | Pin Name |
1 | I/O | U0_TXD/GPIO 1 |
2 | I/O | U0_RXD/ GPIO 3 |
3 | I/O | U2_RXD/GPIO 16 |
Camera Connector Pins
The description of camera connector pins are as follows
OV2640 CAMERA | ESP32 | Variable name in code |
---|---|---|
D0 | GPIO5 | Y2_GPIO_NUM |
D1 | GPIO18 | Y3_GPIO_NUM |
D2 | GPIO19 | Y4_GPIO_NUM |
D3 | GPIO21 | Y5_GPIO_NUM |
D4 | GPIO36 | Y6_GPIO_NUM |
D5 | GPIO39 | Y7_GPIO_NUM |
D6 | GPIO34 | Y8_GPIO_NUM |
D7 | GPIO35 | Y9_GPIO_NUM |
XCLK | GPIO0 | XCLK_GPIO_NUM |
PCLK | GPIO22 | PCLK_GPIO_NUM |
VSYNC | GPIO25 | VSYNC_GPIO_NUM |
HREF | GPIO23 | HREF_GPIO_NUM |
SDA | GPIO 26 | SIOD_GPIO_NUM |
SCL | GPIO 27 | SIOC_GPIO_NUM |
POWER PIN | GPIO 32 | PWDN_GPIO_NUM |
Programming of the ESP 32 eye cam board
Unlike any other development boards, the ESP 32 eye cam does not have any built-in programmer to burn the code to the ESP32-S chip hence for uploading the code we have to use an external USB to UART Converter or an FTDI Programmer. In this article, we are going to upload the code for setting up the camera and capturing an image when a button is pressed.
Connections
The connection of ESP 32 cam and FTDI programmer is illustrated below
ESP32-CAM | FTDI Cable |
---|---|
GND | GND |
5V | VCC (5V) |
U0RX/GPIO3 | TX |
U0TX/GPIO1 | RX |
GPIO0 | GND |
Set up of Arduino IDE
Step 1 – Before moving further make sure that you have the latest version of Arduino IDE installed on your system.
Step 2 – Then we have to install the ESP 32 add-on in Arduino IDE.
Step 3 – Installation of library & resources
- #include <WiFi.h> – This library allows the ESP32 to connect to Wi-Fi networks and manage network connections.
- #include <WiFiClient.h> – This library provides functionality for creating and managing client connections over Wi-Fi and allowing the ESP32 to communicate with other devices over a network.
- #include <ESPAsyncWebServer.h> – This library helps us create a web server on the ESP32 that can handle HTTP requests asynchronously.
- #include <ESPAsyncWiFiManager.h> – This library provides an easy way to manage Wi-Fi network configuration by allowing us to create a captive portal.
- #include “esp_camera.h” – This library is specific to the ESP32-CAM module. It provides the functions and configurations for working with the camera. It allows us to initialize and control the camera module to capture images and videos.
That is all in the setup of Arduino IDE Now let us have a look at the code
Code
#include <WiFi.h>
#include <WiFiClient.h>
#include <ESPAsyncWebServer.h>
#include <ESPAsyncWiFiManager.h>
#include "esp_camera.h"
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Pin for the button
const int buttonPin = 0; // GPIO0
bool takePicture = false;
// Initialize the camera
camera_config_t config;
void initCamera() {
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 = -1;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_VGA;
config.jpeg_quality = 10;
config.fb_count = 2;
// Initialize the camera
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
ESP.restart();
}
}
// Function to take a picture
void takePhoto() {
camera_fb_t* fb = NULL;
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
return;
}
Serial.println("Picture taken!");
// Do something with the captured image, e.g., send to a server or save to SD card
esp_camera_fb_return(fb);
}
// Callback function for capturing a photo when the button is pressed
void buttonCallback() {
if (digitalRead(buttonPin) == LOW) {
takePicture = true;
}
}
void setup() {
Serial.begin(115200);
pinMode(buttonPin, INPUT_PULLUP);
// Connect to Wi-Fi
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Initialize the camera
initCamera();
// Start the server
AsyncWebServer server(80);
server.begin();
// Initialize the WiFi manager
AsyncWiFiManager wifiManager(&server);
wifiManager.autoConnect("ESP32-CAM");
// Attach button interrupt
attachInterrupt(digitalPinToInterrupt(buttonPin), buttonCallback, FALLING);
}
void loop() {
if (takePicture) {
takePhoto();
takePicture = false;
}
// Other loop code here
}
Frequently Asked Questions
Q1 – Can I use the camera without Wi-Fi?
Ans – Yes, you can use the camera without WiFi as it can capture images and videos locally without an internet connection
Q2 – Can I stream video using the ESP32-CAM?
Ans – Yes, you can stream the video using the ESP 32 cam by using the “ESPAsyncWebServer” and the camera library.
What pins used for build in leds?