Without a doubt, the ESP32-CAM is a powerful device with built-in camera and WiFi support. Unfortunately, the ESP32-CAM has fewer I/O pins, some of which are shared with the SD card and thus cannot be used when the card is present, making it difficult to design a project around it.
There are a few things you should be aware of, so please read the pinout carefully.
Please note that the following pinout reference is for the popular ESP32-CAM board from AI-Thinker.
The ESP32-CAM has 16 pins in total. For convenience, pins with similar functionality are grouped together. The pinout is as follows:
Delving a little further into which pins do what…
ESP32-CAM 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, by programming the appropriate registers.
Which ESP32-CAM GPIOs are safe to use?
Although the ESP32-CAM has 10 GPIO pins with various functions, some of them may not be suitable for your projects. The table below shows which pins are safe to use and which pins should be used with caution.
- – Your top priority pins. They are perfectly safe to use.
- – Pay close attention because their behavior, particularly during boot, can be unpredictable. Also, some GPIOs are shared with the microSD card. So use them with caution.
- – It is recommended that you avoid using these pins.
|Label||GPIO||Safe to use?||Reason|
|D0||0||must be HIGH during boot and LOW for flashing|
|TX0||1||Tx pin, used for flashing and debugging|
|D2||2||must be LOW during boot, cannot be used when microSD card is present|
|RX0||3||Rx pin, used for flashing and debugging|
|D4||4||Connected to the on-board Flash LED, cannot be used when microSD card is present|
|D12||12||must be LOW during boot, cannot be used when microSD card is present|
|D13||13||cannot be used when microSD card is present|
|D14||14||cannot be used when microSD card is present|
|D15||15||must be HIGH during boot, prevents startup log if pulled LOW, cannot be used when microSD card is present|
The image below shows which GPIO pins can be used safely.
GPIO 0 Pin
GPIO 0 is the most important pin. It determines whether or not the ESP32 is in flashing mode.
This GPIO must be HIGH during boot and LOW during flashing, so it is internally pulled up by a 10K resistor. When you connect GPIO 0 to GND, the ESP32 enters flash mode, and you can upload code to the board. Once you have finished programming the board, you must disconnect this connection.
Remember! You’ll have to make this connection every time you want to upload a new code.
GPIO 33 – Built-in Red LED
There is a small red LED on the back that can be used as a status indicator. It is user-programmable and connected to GPIO33.
This LED works with inverted logic, so to turn it on, you send a LOW signal and to turn it off, you send a HIGH signal.
GPIO 4 – Camera FLASH
The ESP32-CAM has a very bright white LED. It is intended to be used as a camera flash, but it can also be used for general illumination. This LED is internally connected to GPIO 4.
ESP32-CAM MicroSD Card Pins
The following 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.
ESP32-CAM 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.
ESP32-CAM Touch Pins
The ESP32-CAM has 7 capacitive touch-sensing GPIOs. When a capacitive load (such as a human finger) is in close proximity to the GPIO, the ESP32 detects the change in capacitance.
You can make a touch pad by attaching any conductive object to these pins, such as aluminum foil, conductive cloth, conductive paint, and so on. Because of the low-noise design and high sensitivity of the circuit, relatively small pads can be made.
Additionally, these capacitive touch pins can be used to wake the ESP32 from deep sleep.
ESP32-CAM SPI Pins
The ESP32-CAM features only one SPI (VSPI) in slave and master modes. It also supports the general-purpose SPI features listed below:
- 4 timing modes of the SPI format transfer
- Up to 80 MHz and the divided clocks of 80 MHz
- Up to 64-Byte FIFO
ESP32-CAM 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.
ESP32-CAM PWM Pins
The board 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.
The PWM controller consists of PWM timers, the PWM operator and a dedicated capture sub-module. Each timer provides timing in synchronous or independent form, and each PWM operator generates a waveform for one PWM channel. The dedicated capture sub-module can accurately capture events with external timing.
ESP32-CAM RTC GPIO Pins
The GPIOs that are routed to the RTC low-power subsystem are referred to as RTC GPIOs. These pins are used to wake the ESP32 from deep sleep when the Ultra Low Power (ULP) co-processor is running. The GPIOs highlighted below can be used as external wake up sources.
ESP32-CAM 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.
GND is the ground pin.