ESP32-CAM Module Initialization Failure - Seeking Diagnostic Help

I'm working on a project with an ESP32-CAM module and OV7670 camera initialization issues. Despite multiple troubleshooting attempts, I cannot get the camera to initialize or capture frames.
Hardware Setup:
Board: ESP32
Camera Module: OV7670
Development Environment: Arduino IDE
Troubleshooting Attempted

  1. Verified and re-verified physical connections
  2. Tried multiple GPIO pin configurations
  3. Checked power supply
  4. Reinstalled ESP32 board support and camera libraries
  5. Tested multiple scripts
  6. Added Pullup Resistors to SDA & SCL

My Code:

#include "esp_camera.h"
#include "Wire.h"

#define PWDN_GPIO_NUM     17
#define RESET_GPIO_NUM    16
#define XCLK_GPIO_NUM     19
#define SIOD_GPIO_NUM     21
#define SIOC_GPIO_NUM     22

#define Y9_GPIO_NUM       32
#define Y8_GPIO_NUM       33
#define Y7_GPIO_NUM       35
#define Y6_GPIO_NUM       34
#define Y5_GPIO_NUM       14
#define Y4_GPIO_NUM       26
#define Y3_GPIO_NUM        2
#define Y2_GPIO_NUM        4

#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     18

void setup() {
  Serial.begin(115200);
  delay(1000);

  pinMode(SIOD_GPIO_NUM, INPUT_PULLUP); 
  pinMode(SIOC_GPIO_NUM, INPUT_PULLUP); 

  Serial.println("\n--- Starting Camera Diagnostics ---");

  // Step 1: Verify Pin Configuration
  Serial.println("Step 1: Verifying Pin Configuration...");
  bool pinConfigOk = true;
  if (XCLK_GPIO_NUM == -1 || PCLK_GPIO_NUM == -1) {
    Serial.println("Error: Clock pins not set properly.");
    pinConfigOk = false;
  }
  if (!pinConfigOk) {
    Serial.println("Pin configuration failed. Check your wiring.");
    while (true); 
  } else {
    Serial.println("Pin configuration looks good!");
  }

  Serial.println("Step 2: Checking SCCB Communication...");
  if (!testSCCB()) {
    Serial.println("Error: SCCB (I2C) communication failed. Check SIOD/SIOC connections and pull-up resistors.");
    while (true); 
  } else {
    Serial.println("SCCB communication successful!");
  }

  Serial.println("Step 3: Configuring Camera...");
  camera_config_t config;
  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 = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_RGB565; // Adjust if necessary
  config.frame_size = FRAMESIZE_QVGA;     // Use small size for testing
  config.fb_count = 1;

  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x\n", err);
    checkErrorCode(err); 
    while (true); 
  } else {
    Serial.println("Camera successfully initialized!");
  }

  
  Serial.println("Step 4: Testing Frame Capture...");
  camera_fb_t *fb = esp_camera_fb_get();
  if (!fb) {
    Serial.println("Error: Failed to capture a frame.");
    while (true); 
  } else {
    Serial.printf("Frame captured successfully! Size: %d bytes\n", fb->len);
    esp_camera_fb_return(fb);
  }

  Serial.println("--- Camera Diagnostics Complete ---");
}

void loop() {
  // Frame capture test in the loop
  camera_fb_t *fb = esp_camera_fb_get();
  if (fb) {
    Serial.println("Frame capture succeeded in loop!");
    esp_camera_fb_return(fb);
  } else {
    Serial.println("Error: Frame capture failed in loop.");
  }
  delay(2000);
}

bool testSCCB() {
  Serial.println("Testing SCCB...");
  uint8_t addr = 0x42 >> 1;
  Wire.begin(SIOD_GPIO_NUM, SIOC_GPIO_NUM); 
  Wire.beginTransmission(addr);
  uint8_t error = Wire.endTransmission();
  if (error == 0) {
    Serial.println("SCCB test passed!");
    return true;
  } else {
    Serial.printf("SCCB test failed with error code: %d\n", error);
    return false;
  }
}

void checkErrorCode(esp_err_t err) {
  switch (err) {
    case ESP_ERR_NO_MEM:
      Serial.println("Error: Out of memory.");
      break;
    case ESP_ERR_INVALID_ARG:
      Serial.println("Error: Invalid argument.");
      break;
    case ESP_ERR_INVALID_STATE:
      Serial.println("Error: Invalid state.");
      break;
    case ESP_ERR_NOT_FOUND:
      Serial.println("Error: Requested resource not found.");
      break;
    case ESP_ERR_NOT_SUPPORTED:
      Serial.println("Error: Operation not supported.");
      break;
    default:
      Serial.printf("Unknown error: 0x%x\n", err);
  }
}

Monitor:

14:57:41.793 -> --- Starting Camera Diagnostics ---
14:57:41.793 -> Step 1: Verifying Pin Configuration...
14:57:41.793 -> Pin configuration looks good!
14:57:41.793 -> Step 2: Checking SCCB Communication...
14:57:41.793 -> Testing SCCB...
14:57:41.793 -> SCCB test failed with error code: 2
14:57:41.793 -> Error: SCCB (I2C) communication failed. Check SIOD/SIOC  connections and pull-up resistors.

Picture of Wiring of only SDA & SCL (without pullup)

Nice job on the code, and that’s a nice picture, but it doesn’t provide enough detail. Could you post an annotated schematic showing exactly how you’ve connected everything? Be sure to include all connections, power, ground, power sources, and any other components in the setup. This will help in providing more accurate feedback.