ESP32-CAM Camera Boards: Pin and GPIOs Assignment Guide

ESP32 development boards with camera are becoming popular with the maker community. There are different models of ESP32 Camera boards with different features. Each ESP32 Camera dev board uses different GPIOs to connect to the camera. In this guide we’ll show you the pin definition to include in your code for each board.

ESP32-CAM Camera Boards Pin and GPIOs Assignment Guide

This guide covers the pin/GPIOs assignment for the following ESP32 Camera Development boards:

For a detailed comparison of the different ESP32 Camera Boards, read:

ESP32-CAM AI-Thinker Pin Assignment

The following image shows the pinout diagram for the ESP32-CAM AI-Thinker.

ESP32-CAM AI-Thinker Module Board Pins GPIO

This is the OV2640 camera pin assignment for the ESP32-CAM AI-Thinker board:

#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27
#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22

The ESP32-CAM AI-Thinker comes with 10 exposed GPIOs. Learn how to use those GPIOs with this ESP32-CAM Pinout Reference Guide.

Review: ESP32-CAM with OV2640 Camera

Freenove ESP32-Wrover CAM Board

Pin definition for the ESP32-Wrover CAM board (Freenove brand). In some of the examples, this pin definition is under the CAMERA_MODEL_WROVER_KIT.

#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    21
#define SIOD_GPIO_NUM    26
#define SIOC_GPIO_NUM    27

#define Y9_GPIO_NUM      35
#define Y8_GPIO_NUM      34
#define Y7_GPIO_NUM      39
#define Y6_GPIO_NUM      36
#define Y5_GPIO_NUM      19
#define Y4_GPIO_NUM      18
#define Y3_GPIO_NUM       5
#define Y2_GPIO_NUM       4
#define VSYNC_GPIO_NUM   25
#define HREF_GPIO_NUM    23
#define PCLK_GPIO_NUM    22

TTGO T-Journal Pin Assignment

TTGO T-Journal ESP32-CAM Camera Pins GPIO

Pin assignment for the TTGO T-Journal board.

#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM     27
#define SIOD_GPIO_NUM     25
#define SIOC_GPIO_NUM     23
#define Y9_GPIO_NUM       19
#define Y8_GPIO_NUM       36
#define Y7_GPIO_NUM       18
#define Y6_GPIO_NUM       39
#define Y5_GPIO_NUM       5
#define Y4_GPIO_NUM       34
#define Y3_GPIO_NUM       35
#define Y2_GPIO_NUM       17
#define VSYNC_GPIO_NUM    22
#define HREF_GPIO_NUM     26
#define PCLK_GPIO_NUM     21

Review: TTGO T-Journal ESP32 Camera Development Board

M5-Camera Model A Pin Assignment

There are two similar models: M5-Camera Model A and M5-Camera Model B. The model A looks as shown in the following figure.

M5-Camera Model A Pins GPIO

Pin assignment for the M5-Camera Model A.

#define PWDN_GPIO_NUM     -1
#define RESET_GPIO_NUM    15
#define XCLK_GPIO_NUM     27
#define SIOD_GPIO_NUM     25
#define SIOC_GPIO_NUM     23
#define Y9_GPIO_NUM       19
#define Y8_GPIO_NUM       36
#define Y7_GPIO_NUM       18
#define Y6_GPIO_NUM       39
#define Y5_GPIO_NUM        5
#define Y4_GPIO_NUM       34
#define Y3_GPIO_NUM       35
#define Y2_GPIO_NUM       32
#define VSYNC_GPIO_NUM    22
#define HREF_GPIO_NUM     26
#define PCLK_GPIO_NUM     21

M5-Camera Model B Pin Assignment

The M5-Camera Model B looks as follows:

M5-Camera Model B Pins GPIO

Pin assignment for the M5-Camera Model B.

#define PWDN_GPIO_NUM     -1
#define RESET_GPIO_NUM    15
#define XCLK_GPIO_NUM     27
#define SIOD_GPIO_NUM     22
#define SIOC_GPIO_NUM     23
#define Y9_GPIO_NUM       19
#define Y8_GPIO_NUM       36
#define Y7_GPIO_NUM       18
#define Y6_GPIO_NUM       39
#define Y5_GPIO_NUM        5
#define Y4_GPIO_NUM       34
#define Y3_GPIO_NUM       35
#define Y2_GPIO_NUM       32
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     26
#define PCLK_GPIO_NUM     21

M5-Stack ESP32-Camera (without PSRAM) Pin Assignment

M5-Stack ESP32-Camera (without PSRAM) Pins GPIO

Pin assignment for the M5-stack ESP32 camera without PSRAM.

#define PWDN_GPIO_NUM     -1
#define RESET_GPIO_NUM    15
#define XCLK_GPIO_NUM     27
#define SIOD_GPIO_NUM     25
#define SIOC_GPIO_NUM     23
#define Y9_GPIO_NUM       19
#define Y8_GPIO_NUM       36
#define Y7_GPIO_NUM       18
#define Y6_GPIO_NUM       39
#define Y5_GPIO_NUM        5
#define Y4_GPIO_NUM       34
#define Y3_GPIO_NUM       35
#define Y2_GPIO_NUM       17
#define VSYNC_GPIO_NUM    22
#define HREF_GPIO_NUM     26
#define PCLK_GPIO_NUM     21

ESP-EYE Pin Assignment

ESP-EYE Pins GPIO

Pin assignment for the ESP-EYE camera.

#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    4
#define SIOD_GPIO_NUM    18
#define SIOC_GPIO_NUM    23
#define Y9_GPIO_NUM      36
#define Y8_GPIO_NUM      37
#define Y7_GPIO_NUM      38
#define Y6_GPIO_NUM      39
#define Y5_GPIO_NUM      35
#define Y4_GPIO_NUM      14
#define Y3_GPIO_NUM      13
#define Y2_GPIO_NUM      34
#define VSYNC_GPIO_NUM   5
#define HREF_GPIO_NUM    27
#define PCLK_GPIO_NUM    25

Review: ESP-EYE: ESP32-based board for AI

TTGO T-Camera Plus Pin Assignment

T-Camera Plus Pins GPIO

Pin assignment for the TTGO T-Camera Plus.

#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    4
#define SIOD_GPIO_NUM    18
#define SIOC_GPIO_NUM    23
#define Y9_GPIO_NUM      36
#define Y8_GPIO_NUM      37
#define Y7_GPIO_NUM      38
#define Y6_GPIO_NUM      39
#define Y5_GPIO_NUM      35
#define Y4_GPIO_NUM      26
#define Y3_GPIO_NUM      13
#define Y2_GPIO_NUM      34
#define VSYNC_GPIO_NUM   5
#define HREF_GPIO_NUM    27
#define PCLK_GPIO_NUM    25

Review: TTGO T-Camera Plus ESP32 Development Board

TTGO T-Camera with PIR Sensor Pin Assignment

TTGO T-Camera with PIR Sensor Pins GPIO

Pin definition for the T-Camera with PIR sensor (without microphone and without BME280):

#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 32
#define SIOD_GPIO_NUM 13
#define SIOC_GPIO_NUM 12
#define Y9_GPIO_NUM 39
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 23
#define Y6_GPIO_NUM 18
#define Y5_GPIO_NUM 15
#define Y4_GPIO_NUM 4
#define Y3_GPIO_NUM 14
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 27
#define HREF_GPIO_NUM 25
#define PCLK_GPIO_NUM 19

Learn how to program and build 17 projects with the ESP32-CAM using Arduino IDE DOWNLOAD »

Learn how to program and build 17 projects with the ESP32-CAM using Arduino IDE DOWNLOAD »

Wrapping Up

Having the right pin definition for your ESP32 camera board is very important. Otherwise, your code won’t work or your board will not initialize the camera.

We have several tutorials for the ESP32-CAM that may also be compatible with other ESP32 camera boards as long as you use the right pin definition in your code.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

10 thoughts on “ESP32-CAM Camera Boards: Pin and GPIOs Assignment Guide”

  1. I have an ESP32-S (original ESP32CAM based board) which I’m swapping over to an ESP32-S3. Are there any restrictions on which pins are assigned to the camera? It will be my PCB layout but it seems any examples I’ve found of the S3 use totally different pinouts to the original – I’d like to keep the board layout mostly the same, so can I just assign them back to the old version in the sketch, with the new module? I’m worried that the peripherals have all rearranged and just assigning them back won’t work! Thanks, Paul.

    Reply
    • Hi.
      GPIO 0 is a strapping pin.
      You can use it after uploading the code to the board. You must disconnect all peripherals connected to that GPIO at the time of uploading.
      Regards,
      Sara

      Reply
  2. salut,
    je veux ajouter un bouton poussoir pour mon ESP 32 CAM dont le but est pour capter une image et le visualiser sur mon écran de l’ordinateur

    Reply
  3. These RandomNerdTutorial ESP guides are excellent, they are my ‘go to’ reference about which pins to use. I have spent some time with various memory issues with generic AIThinker clone ESP32Cam boards, learning how to set up jtag debugging to understand why and I have now got to the root cause of my problems: I was using GPIO16 as an input pin for a PIR sensor. On the AIThinker boards, and I assume other ESPCam boards, GPIO 16 is used to communicate with the external PSRAM chip on the board. It can’t be used as an input for your own purposes, if PSRAM is to be used. The standard example ESP32 cam project does use PSRAM, as the camera code needs to assign large buffers in memory to process the incoming frame information. RandomNerdTutorials does have an example of using a PIR sensor with an ESP32Cam board, which uses GPIO13. However I have a JTAG connector for debugging attached to that GPIO13, so GPIO16 seemed to me like the best remaining pin to use. It would be good to call out in this article that GPIO16 is used for PSRAM access on some/many ESP32Cam boards and should be avoided.

    Reply
    • Hi Donald.
      Thank you so much for providing such detailed information.
      I’m sure this will be useful for our readers.
      Regards,
      Sara

      Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.