I need help recieving RGB565 data from the OV5642 Plus

1.Which seller did you purchase the product(s) from?
Uctronics
2.The Model number of the product(s) you have purchased?
https://www.arducam.com/product/arducam-5mp-plus-spi-cam-arduino-ov5642/
3.Which Platform are you using the product(s) on?
Arduino UNO R3
4.Which instruction are you following?
Various Sketches from Github.
5.Has your product ever worked properly?
I did at one point with a test pattern, but I haven’t been able to recreate that before.
6.What problems are you experiencing?
I want to simply take a single photo and then collect the RGB565 data from it. I am currently pushing the data I receive onto the Serial Monitor of the Arduino IDE. After that, I have my own way to display the photo. The problem is that this method worked with the test patterns and then when I stopped using the test patterns, it won’t show the photo taken; it only shows purple lines. I also cannot recreate the test patterns either.I just receive purple and red lines now. As seen below.

I would like help on this matter because my college is interested in using this camera for a few major future project.

 

 

 

 

Code:

#include <Arduino.h>
#include <Wire.h>
#include <ArduCAM.h>
#include <SPI.h>
#include “memorysaver.h”

#define CS_Cam 7

#define BMPIMAGEOFFSET 66
const unsigned int bmp_header[BMPIMAGEOFFSET] PROGMEM =
{
0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00,
0x00, 0x00
};

ArduCAM myCAM(OV5642, CS_Cam);

bool is_header = false;

//Important Arrays
uint8_t VH_[320];
uint8_t VL_[320];
//
//Functions
void take_photo();
void arduCam_setup();
void print_values();

//–

void setup() {

Wire.begin();

Serial.begin(115200);
pinMode(CS_Cam, OUTPUT);
digitalWrite(CS_Cam, 0);
Serial.println(“Here”);
delay(100);

arduCam_setup();

take_photo();

Serial.print("\nDone\n");
}

void loop() {
}

void arduCam_setup(){
uint8_t vid, pid;
uint8_t temp;

Serial.println(F(“ArduCAM Start!”));

SPI.begin();

myCAM.write_reg(0x07, 0x80); // RESET the CPLD
delay(100);
myCAM.write_reg(0x07, 0x00);
delay(100); //–

while(1){
//Check if the ArduCAM SPI bus is OK
myCAM.write_reg(ARDUCHIP_TEST1, 0x55);
temp = myCAM.read_reg(ARDUCHIP_TEST1);
if (temp != 0x55)
{
Serial.println(F(“SPI interface Error!”));
delay(1000); continue;
} else{
Serial.println(F(“SPI interface OK”));break;
}
}

while(1){
//Check if the camera module type is OV5642
myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid);
myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid);
if ((vid != 0x56) || (pid != 0x42)){
Serial.println(F(“Can’t find OV5642 module!”));
delay(1000);continue;
} else{
Serial.println(F(“OV5642 detected.”));break;
}
}

//Change to JPEG capture mode and initialize the OV5642 module
myCAM.set_format(MCU2LCD_MODE);
myCAM.InitCAM();
myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH
myCAM.OV5642_set_JPEG_size(OV5642_320x240);
myCAM.clear_fifo_flag();
delay(500);
}

void take_photo(){

myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU, freeze the screen

myCAM.flush_fifo();

myCAM.start_capture();

//Polling the capture done flag
while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK));

delay(100);

uint8_t VH,VL;

myCAM.read_fifo();

for (int i = 0; i < 240; i++){
for (int j = 0; j < 320; j++){
VH = myCAM.read_fifo();
delayMicroseconds(12);
VL = myCAM.read_fifo();
delayMicroseconds(12);
VH_[j] = VH;
VL_[j] = VL;

}
print_values();
}

myCAM.clear_fifo_flag();

}

void print_values(){
uint16_t num;
for (int count = 0; count < 320; count++){

//VH_[count]; = R4, R3, R2, R1, R0, G5, G4, G3
//VL_[count]; = G2, G1, G0, B4, B3, B2, B1, B0
num = (VH_[count] << 8) | (VL_[count] & 0xff);
Serial.print(num);
if (count == 319) {
Serial.println();
}
else {
Serial.print(",");
}
}
delay(10);
}
7.What attempts at troubleshooting have you already made?
The host app does work with the recommended Github code.
8.How would you like us to help you?
I would like help on this matter because my college is interested in using this camera for a few major future project.

The results

I’m sorry that the forum failed to respond to your question in time. Have you solved the problem now?

Sorry for the late reply. I tried my same code on another OV5642 but was equally unsuccessful. I already ordered a OV2640 for a separate project and tried it on there. It works perfectly. I can only assume that this is a problem of the OV5642 model I have for capturing bit map data.

I finished a small part of my project by creating a demo. I now use a esp8266 to collect bit map data and send it through serial to a python script to display the captured photo.

Here is my GitHub: https://github.com/TylerW-Robotics/OV2640_ESP8266_pythonApp