The AI-Thinker ESP32-CAM exposes 16 physical header pins, but due to the OV2640 camera interface routing and PSRAM memory allocation, only 9 GPIOs are safely available for general-purpose I/O. Below is the definitive hardware reference for mapping these pins without triggering boot failures or brownouts.
The Complete ESP32-CAM Pinout Reference Table
Read this table left-to-right corresponding to the physical 2x8 header layout on the AI-Thinker board. The 'Safe for I/O' column indicates whether you can use the pin for arbitrary sensors, relays, or PWM without interfering with the camera or boot sequence.
| Physical Pin | GPIO | Primary Function | Voltage / Type | Safe for I/O? | Hardware Notes |
|---|---|---|---|---|---|
| Left 1 | N/A | 5V Input | 5.0V DC In | No | Feeds AMS1117 LDO. Use for main power. |
| Left 2 | N/A | GND | 0V | No | Common ground reference. |
| Left 3 | GPIO 1 | U0T (TX0) | 3.3V UART | Yes (Post-boot) | Debug TX. Outputs boot logs. |
| Left 4 | GPIO 3 | U0R (RX0) | 3.3V UART | Yes (Post-boot) | Debug RX. Used for flashing. |
| Left 5 | N/A | GND | 0V | No | Common ground reference. |
| Left 6 | GPIO 2 | SD Card Data / LED | 3.3V I/O | Conditional | Tied to onboard red LED and SD MISO. |
| Left 7 | GPIO 4 | SD Card Data / Flash | 3.3V I/O | Conditional | Drives onboard white flashlight LED. |
| Left 8 | GPIO 12 | SD Card CLK / MTDI | 3.3V I/O | No | Strapping pin. Do not pull HIGH at boot. |
| Right 1 | N/A | 3.3V Output | 3.3V DC Out | No | LDO output. Max 500mA, practically less. |
| Right 2 | N/A | GND | 0V | No | Common ground reference. |
| Right 3 | GPIO 13 | SD Card CMD / MTCK | 3.3V I/O | Yes | Safe for I2C or general input. |
| Right 4 | GPIO 14 | SD Card CLK / MTMS | 3.3V I/O | Yes | Safe for I2C SDA or general output. |
| Right 5 | GPIO 15 | SD Card CMD / MTDO | 3.3V I/O | Yes | Safe for I2C SCL. Boot log output. |
| Right 6 | GPIO 16 | UART 2 RX / PSRAM | 3.3V I/O | No | PSRAM Chip Select on 8MB variants. |
| Right 7 | GPIO 0 | BOOT | 3.3V Input | No | Must be HIGH to run. LOW to flash. |
| Right 8 | N/A | Reset (EN) | 3.3V Input | No | Active LOW reset. Pull to GND to reboot. |
Rows People Get Wrong (And How to Avoid Bricking Your Board)
Beginners frequently treat the ESP32-CAM like a standard ESP32 DevKit, assuming all exposed headers are free to use. This leads to three specific hardware failures documented across Espressif's official hardware design guidelines.
GPIO 12 is a critical strapping pin that determines the internal flash voltage. If GPIO 12 is pulled HIGH during power-on, the ESP32 configures its internal voltage regulator to 1.8V for the SPI flash. Because the AI-Thinker module uses a 3.3V flash chip, the board will fail to boot, outputting a continuous 'flash read err' over UART. Always ensure GPIO 12 is LOW or floating when power is applied.
The GPIO 16 PSRAM Collision
On standard 4MB PSRAM AI-Thinker boards, GPIO 16 is technically available as UART2 RX. However, many 2024-2026 production batches and third-party clones ship with 8MB PSRAM. On 8MB modules, GPIO 16 is permanently routed to the PSRAM Chip Select (CS) line. If you attempt to use GPIO 16 as a digital output to drive a relay or read a sensor, you will interrupt the memory bus, causing the camera driver to throw a psram init failed error or triggering a watchdog reset. Treat GPIO 16 as strictly off-limits for user I/O.
The GPIO 4 Flashlight Current Draw
GPIO 4 is wired directly to the onboard high-intensity white LED. If you configure GPIO 4 for I2C communication or as a PWM input for a sensor, the internal pull-up resistors will cause the LED to flicker dimly, and the LED's forward voltage drop will distort your I2C logic levels. If you need GPIO 4 for a sensor, you must physically desolder the white LED or its current-limiting resistor from the PCB.
Power Pin Misinterpretation: 5V vs 3.3V
The 5V pin is an input. The 3.3V pin is an output from the onboard AMS1117-3.3 linear voltage regulator. A common mistake is back-feeding 3.3V from a bench supply into the 3.3V pin while also connecting a USB cable, or attempting to power a 5V micro-servo from the 3.3V rail. The AMS1117 on this specific board lacks adequate heatsinking; drawing more than 300mA continuously from the 3.3V pin will cause thermal throttling and brownouts.
Module Variants and Peripheral Wiring Standards
While silicon pinouts are dictated by Espressif, the physical implementation varies by manufacturer, and wiring color standards for peripherals differ by region and application.
AI-Thinker vs. Generic Clones
The reference table above applies to the genuine AI-Thinker ESP32-CAM. Generic clones (often sold in bulk without branding) sometimes omit the PSRAM chip entirely to cut costs. On these boards, the camera will only work at lower resolutions (QVGA) because there is no external memory to buffer higher-resolution frames. Additionally, some clones replace the AMS1117 LDO with a cheaper ME6211, which alters the maximum current you can safely draw from the 3.3V pin (often dropping the safe limit to 200mA).
Wiring Color Standards: IEC vs. Hobbyist DC
When wiring external sensors or power harnesses to the ESP32-CAM headers, be aware of conflicting color codes:
- IEC 60446 (AC Mains & Industrial): Brown (Line), Blue (Neutral), Green/Yellow (Earth). Never use these colors for low-voltage DC signal wires to avoid catastrophic cross-wiring if the project is later integrated into a mains-powered enclosure.
- Hobbyist DC Standard: Red (VCC/5V), Black (GND), Yellow/White (Signal). This is the standard for servo and JST connectors.
- OV2640 FPC Ribbon: The 24-pin flexible printed circuit (FPC) cable for the camera does not follow standard color codes. Pin 1 is typically marked with a blue stripe or a red dot on the connector. Always verify Pin 1 alignment before latching the FPC connector; reversing it shorts the 3.3V camera rail to ground, instantly destroying the camera module.
Safe Interpretation of Faded Silkscreen
Clone boards frequently suffer from poor silkscreen printing that rubs off after a few insertion cycles. If your pin labels are missing, do not guess. Use a multimeter in continuity mode:
- Identify GND by probing for continuity with the metal shield of the micro-USB port or the large copper ground pour on the back of the PCB.
- Identify the 5V pin by checking continuity with the input leg of the AMS1117 LDO (the middle surface-mount component near the headers) and the large 100µF electrolytic capacitor.
- Identify the 3.3V pin by checking continuity with the output leg of the LDO.
ESP32-CAM Pinout FAQ
Can I use the ESP32-CAM pinout for I2C sensors like the BME280?
Yes, but you must choose your pins carefully to avoid camera conflicts. The safest I2C mapping for the AI-Thinker ESP32-CAM is GPIO 14 for SDA and GPIO 15 for SCL. Do not use GPIO 4 (flashlight LED interference) or GPIO 12 (bootstrapping pin). Remember that the ESP32-CAM does not have hardware I2C pins routed to the headers, so you must use software I2C (Wire.begin(SDA, SCL)) in your Arduino or ESP-IDF code, explicitly defining GPIO 14 and 15.
Why does my ESP32-CAM brownout when I use the 3.3V pin for the camera and a servo?
The OV2640 camera draws up to 160mA during image capture, and the ESP32's WiFi radio spikes to 240mA during transmission. Combined, the board can peak at over 400mA. If you add a micro-servo or external sensor drawing another 100mA, you exceed the thermal and current limits of the onboard AMS1117 LDO, triggering a brownout detector (BOD) reset. To fix this, power the board via the 5V pin using a 5V 2A (or higher) wall adapter, and power high-current peripherals directly from an external 5V buck converter rather than the board's 3.3V rail.
How do I flash code if the GPIO 0 BOOT pin is inaccessible in my enclosure?
GPIO 0 must be pulled to GND during the exact moment power is applied to enter UART download mode. If your enclosure blocks the header, wire a momentary push-button switch between GPIO 0 and GND, and a second switch between the Reset (EN) pin and GND. To flash: hold the GPIO 0 button, press and release the Reset button, then release the GPIO 0 button. This sequence forces the bootloader into flash mode without needing to unplug the board from your custom wiring harness.






