I have an Arducam Mini 2mp and an SD Card (and mega 2560).
The camera will capture an image and will save it to the SD Card. The jpg file starts with an FF,D8 and ends with an FF,D9 and the data inside appears to be roughly normal for a jpg, but I can't read the file using paint or photoshop.
I can send the capture only via the serial port, capture it from a serial capture program and the resulting file is a jpg that opens just fine in paint. It's perfect. I've compared the two files (the one via serial and the one via the SD Card) and there are only slight differences. File sizes are similar and as I said, they start with an FF, D8 and end with an FF, D9.
I've tried different cards too.
I'm using IDE 1.69, and the example below is from the ArduCam_OV2640_DIgital_Camera.ino - unchanged except the cs pins - it's the same thing - something is wrong inside the completed jpg file.
Anyone else had this issue?
I've used in addition to my own code - just straight examples. Here is the relevant section - basically it's just right out of the examples..
Serial.println("Capture Done!");
byte buf[256];
uint8_t temp,temp_last;
int total_time = 0;
File myFile;
char str[8];
static int k = 0;
//Construct a file name
k = k + 1;
itoa(k, str, 10);
strcat(str,"_JJ.jpg");
//Open the new file
myFile = SD.open(str,O_WRITE | O_CREAT | O_TRUNC);
if (! myFile)
{
Serial.println("open file failed");
return;
}
total_time = millis();
int i = 0;
temp = myCAM1.read_fifo();
//Write first image data to buffer
buf = temp;
-
i++;*
-
//Read JPEG data from FIFO*
-
while( (temp != 0xD9) | (temp_last != 0xFF) )*
-
{*
-
temp_last = temp;*
-
temp = myCAM1.read_fifo();*
-
//Write image data to buffer if not full*
-
if(i < 256)*
-
{*
_ buf = temp;_
* i++;*
* }*
* else*
* {*
* //Write 256 bytes image data to file*
* myFile.write(buf,256);*
* i = 0;*
_ buf = temp;
* i++;
}
}
//Write the remain bytes in the buffer*
* if(i > 0)
{
myFile.write(buf,i);
}
//Close the file*
* myFile.close();_
total_time = millis() - total_time;
_ Serial.print("Total time used:");_
Serial.print(total_time, DEC);
_ Serial.println(" millisecond");
//Clear the capture done flag*_
* myCAM1.clear_fifo_flag();*