GPIO Pinout
The ESP32-CAM (AI-Thinker) has severe GPIO constraints. The OV2640 camera claims 15 pins, the SD card claims 6, and PSRAM uses GPIO16.
Camera pins (OV2640)
Section titled “Camera pins (OV2640)”| GPIO | Function | Notes |
|---|---|---|
| 0 | XCLK | Also BOOT pin — pull LOW to enter flash mode |
| 5 | VSYNC | |
| 18 | PCLK | |
| 19 | D7 | |
| 21 | D6 | |
| 22 | D5 | |
| 23 | D4 | |
| 25 | D3 | |
| 26 | D2 | |
| 27 | D1 | |
| 32 | PWDN | Camera power down control |
| 34 | D0 | Input only |
| 35 | HREF | Input only |
| 36 | SIOC (SCL) | Input only |
| 39 | SIOD (SDA) | Input only |
SD card pins (4-bit mode)
Section titled “SD card pins (4-bit mode)”| GPIO | Function | Notes |
|---|---|---|
| 2 | DATA0 | Also affects boot (must be LOW or floating) |
| 4 | DATA1 | Also connected to onboard LED flash |
| 12 | DATA2 | Must be LOW during boot |
| 13 | DATA3 | |
| 14 | CLK | |
| 15 | CMD |
| GPIO | Function | Notes |
|---|---|---|
| 16 | PSRAM CS# | Not available — connected to PSRAM chip select |
Available pins for LoRa UART
Section titled “Available pins for LoRa UART”| GPIO | Default Function | Availability |
|---|---|---|
| 1 | U0TXD (Console TX) | Available if serial console is sacrificed |
| 3 | U0RXD (Console RX) | Available if serial console is sacrificed |
| 13 | SD DATA3 | Available if SD card uses 1-bit mode or is disabled |
| 14 | SD CLK | Available if SD card is disabled |
LoRa UART: Option 1 — GPIO 1/3 (recommended for production)
Section titled “LoRa UART: Option 1 — GPIO 1/3 (recommended for production)”Repurpose the programming/console UART for LoRa communication.
#define LORA_UART_NUM UART_NUM_0#define LORA_UART_TX_PIN GPIO_NUM_1#define LORA_UART_RX_PIN GPIO_NUM_3Pros:
- Pins are already wired and physically accessible
- Keeps PSRAM and SD card fully available
- Clean hardware design
Cons:
- No serial console output for debugging
- Must disconnect LoRa module to flash via UART
- Requires OTA for field updates
LoRa UART: Option 2 — GPIO 13/14 (development alternative)
Section titled “LoRa UART: Option 2 — GPIO 13/14 (development alternative)”Use SD card pins for UART.
#define LORA_UART_NUM UART_NUM_1#define LORA_UART_TX_PIN GPIO_NUM_13#define LORA_UART_RX_PIN GPIO_NUM_14Pros:
- Keeps serial console for debugging
- Can still flash normally via UART
Cons:
- Loses SD card functionality (or must use 1-bit mode, losing GPIO13)
- GPIO14 shared with SD CLK
Wiring diagram (Option 1)
Section titled “Wiring diagram (Option 1)”ESP32-CAM RYLR896/998───────── ───────────GPIO1 (TX) ──────▶ RXDGPIO3 (RX) ◀────── TXD3.3V ──────────── VDDGND ───────────── GND