How to access SD card using SPI connection from Arduino

Hi,
I wounder could we access SD card content via SPI connection to OPenMV cam from Arduino, is it possible?
if so please show if there are any cautions we could take when doing this, it would be appreciated if there is an example for this!
Thanks.

You have to write your own command parser to do this. I recommend sending the data over the uart and not SPI.

For examples of a command parser see the uart pixy emulation example. It shows how to write a statemachine to parser bytes one at a time and do things based on that.

Anyway, given the serial message the Arduino sends you can then open a file on the OpenMV Cam and send data back to the Arduino.

Thanks kwagyeman, for the quick reply :slight_smile:
I got what you mean, but I was wondering if I can access the SD card attached to the camera board from another external device or board directly!
just like what a computer does (to see the file system contents) when attaching the camera to it?

A computer can. The Arduino is honestly rather unequipped. What do you want to do?

Hi Nyamekye, I thought if we can connect to the SPI pins on OpenMV cam so we can use its SD card like we do on a SD card module attached to an Arduino and then the content of the SD card on OpenMV cam would be accessable to any Arduino project (dont you think it would be an added value to OPenMv cam?).
anyway, what I was trying to do is making the images available online using Arduino and Ethernet Shield, I know I can do stream and send snapshots to a server using Your OpenMv Wifi shield, but I do not have it right now so I will use my Arduino to do so.

accessing SD card directly was a thought!!
I think I am gonna send snapshotfrom OpenMV cam via UART to Arduino then handle it then.

You have to write a command parser on the OpenMV Cam if you want the Arduino to be able to request images. It’s not that difficult.

Anyway, sending a snapshot stream to the Arduino is fine.

Thanks Nyamekye, I already had mad a command parser in Python script to control the cam actions through arduino, but try to make the cam SD card accessible directly for external boards, it would be a great feature to be added in the next cam versions OK :slight_smile:

I don’t know how you’d do this without writing a script yourself on the OpenMV Cam to parse commands from the Arduino and to deliver data. The OpenMV Cam doesn’t really work that well as a SPI slave or I2C slave. So, async serial is the best to use for sending the camera commands and getting responses. This then requires some command parser on the camera that when it receives serial byte it does something like delivering data from a requested file to the Arduino.

I do have plans to make the OpenMV Cam configurable at startup to attach a REPL terminal to UART3 for basically giving you control over it on startup. Not exactly sure yet how this should work.