ESP32 OV5640 black spots

Hello Guys,
I am using ESP32 camera module. I replaced OV2640 (2Mp Camera sensor) with OV5640 (5Mp Camera Sensor). Unfortunately the image appears with some black spots.
I use the 2.0.2 version of esp board.

here is my code

#include "esp_camera.h"
#include <WiFi.h>  
#include <WebSocketsServer.h> 
#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
WebSocketsServer webSocket = WebSocketsServer(8888); // Websocket

const char* ssid = "ESP32-OV5640";            // Websocket
const char* password = "123456789";                // Websocket
bool isClientConnected;

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {                // Websocket

    switch(type) {                                                                                    // Websocket
        case WStype_DISCONNECTED:                                                                     // Websocket
            Serial.println("Disconnected!");                                                          // Websocket
            break;                                                                                  // Websocket
        case WStype_CONNECTED:                                                                    // Websocket
            {
                IPAddress ip = webSocket.remoteIP(num);                                         // Websocket
                Serial.print("Connected IP address:");                                          // Websocket
                Serial.println(ip);                                                           // Websocket
                isClientConnected = true;                                             // Websocket
            }
            break;                                                                     // Websocket
    case WStype_TEXT:                                                                   // Websocket
    case WStype_BIN:                                                                  // Websocket
    case WStype_ERROR:                                                                // Websocket
    case WStype_FRAGMENT_TEXT_START:                                              // Websocket
    case WStype_FRAGMENT_BIN_START:                                             // Websocket
    case WStype_FRAGMENT:                                                       // Websocket
    case WStype_FRAGMENT_FIN:                                                   // Websocket
      break;                                                                    // Websocket
    }                                                                         // Websocket

}  


void cameraInit(){
  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_JPEG;
  config.frame_size = FRAMESIZE_SVGA; //QVGA320x240 edo VGA
  config.jpeg_quality = 12;
  config.fb_count = 2;

  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  delay(1000);                                      // Websocket
  WiFi.softAP(ssid, password);                     // Websocket
  IPAddress IP = WiFi.softAPIP();                 // Websocket
  Serial.print("AP IP address: ");               // Websocket
  Serial.println(IP);                           // Websocket

  webSocket.begin();                                 // Websocket
  webSocket.onEvent(webSocketEvent);                // Websocket

  
}
void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println();  
  cameraInit();  
}
void loop() {
  webSocket.loop();
  if(isClientConnected){
    camera_fb_t *fb = NULL;
    esp_err_t res = ESP_OK;
    fb = esp_camera_fb_get();
    if(!fb){
      Serial.println("Camera capture failed");
      esp_camera_fb_return(fb);
      return;
    }
  
    size_t fb_len = 0;
    if(fb->format != PIXFORMAT_JPEG){
      Serial.println("Non-JPEG data not implemented");
      return;
    }
  
    webSocket.broadcastBIN((const uint8_t*) fb->buf, fb->len);
    esp_camera_fb_return(fb);    
  }
  
}

The spots also appear when I am using the ESP 32 Camera Example code.
Any suggestions??

How is the camera connected to the controller? No breadboard I hope. Any decoupling caps used on Vcc?
Does the previous camera work fault free if You change back?

The camera is directly connected with the board. I have tried to power the esp32 module both by using 5V USB and using 5V external power. The result is the same. When I change it back the previous camera works perfectly.

Defective camera?

1 Like

That looks reliable. Maybe as jremington suspects, defective camera.
There is a pattern in the black dots..... I don't really suppose a defective soldering on the camera, or poor contact somewhere. Does that ribbon cable carry camera signals? Was that ribbon used when You tested the old camera?
Does the pattern change if You take a hair blower and warms it up slightly?

The ribbon cable is attached to the camera. The old camera has its own ribbon cable. When I heated up with blower some dots start blinking but the pattern doesn’t change.

Okey. Is the ribbon cable soldered to the camera or connected via a connector? Would it be replaceable?

It connects directly with the camera. Unfortunately its not replaceable.
What does the blinking but not changeable pattern mean?

One camera does the baddies the other camera does not. The camera is defective. The camera is welded to the ribbon cable.

2 Likes

Some kind of a poor connection, bad contact somewhere.

One alternative is to return the camera together with the documentation You've shown here. Ask them and see what they say.
Rewelding the cable to the camera is surely difficult and would be a gamble. The fault can also be between the ribbon cable and the connector. That calls for expertise.
Better to check the return alternative.

1 Like

Thank you for your help. I will try to return it.

You can buy those cameras for $0.99 plus shipping:

1 Like

Thank you for your help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.