Wrong JPEG header when using Arducam Mini Module camera shield 5MP plus ov5642

Hello

I am using an Arducam Mini module camera shield 5MP plus OV5642 with ESP8266 UNO board. I am trying to capture an image and write to SD card in JPEG mode.

Attached is the sketch that I am using. I added the "camera_debug" function to debug the issue. Here are the list of items I checked.

a.) SPI interface - ok. Using SPI_CS 16
b.) SD card SD_CS is 0. Checked that I can write and read a simple pattern to the SD card
c.) OV5642 module is getting detected based on the messages on the serial monitor. However, no image is written to the SD card. When I tried to print the JPEG header bytes on the serial monitor, they were 0xBFD8 instead of 0xFFD8.

I am using Arduino IDE 1.8.5. Any pointers greatly appreciated. Thanks..

ArduCAM_Shield_V2_Capture2SD.ino (9.09 KB)

Provide a link to the schematics of that "ESP8266 UNO" board as it isn't a standard Arduino board.

It says that it is the same form factor and pinout as the standard Arduino UNO R3 board

It says that it is the same form factor and pinout as the standard Arduino UNO R3 board

That may be true for simple digital I/O pins but definitely not for stuff like SPI.

Anyway, it looks like the SD card library provided by the ESP8266 core doesn't correctly handle the CS line, at least it is not handled separately for every call to the library. You may activate/deactivate the CS line yourself for all SD card activities otherwise it will collide with the ArduCAM access to the SPI bus. It's best to use the provided chipSelectLow/chipSelectHigh methods of the Sd2Card class to handle that as this already includes the SPITransaction calls.