How to access SD card using SPI connection from Arduino

Discussion related to "under the hood" OpenMV topics.
Mustafa
Posts: 8
Joined: Wed Nov 15, 2017 6:34 am

How to access SD card using SPI connection from Arduino

Postby Mustafa » Sat Dec 23, 2017 9:22 pm

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.
User avatar
kwagyeman
Posts: 2198
Joined: Sun May 24, 2015 2:10 pm

Re: How to access SD card using SPI connection from Arduino

Postby kwagyeman » Sat Dec 23, 2017 9:29 pm

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.
Nyamekye,
Mustafa
Posts: 8
Joined: Wed Nov 15, 2017 6:34 am

Re: How to access SD card using SPI connection from Arduino

Postby Mustafa » Sat Dec 23, 2017 9:47 pm

Thanks kwagyeman, for the quick reply :)
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?
User avatar
kwagyeman
Posts: 2198
Joined: Sun May 24, 2015 2:10 pm

Re: How to access SD card using SPI connection from Arduino

Postby kwagyeman » Mon Dec 25, 2017 1:37 am

A computer can. The Arduino is honestly rather unequipped. What do you want to do?
Nyamekye,
Mustafa
Posts: 8
Joined: Wed Nov 15, 2017 6:34 am

Re: How to access SD card using SPI connection from Arduino

Postby Mustafa » Mon Dec 25, 2017 6:49 pm

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.
User avatar
kwagyeman
Posts: 2198
Joined: Sun May 24, 2015 2:10 pm

Re: How to access SD card using SPI connection from Arduino

Postby kwagyeman » Mon Dec 25, 2017 8:12 pm

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.
Nyamekye,
Mustafa
Posts: 8
Joined: Wed Nov 15, 2017 6:34 am

Re: How to access SD card using SPI connection from Arduino

Postby Mustafa » Tue Dec 26, 2017 6:05 am

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 :)
User avatar
kwagyeman
Posts: 2198
Joined: Sun May 24, 2015 2:10 pm

Re: How to access SD card using SPI connection from Arduino

Postby kwagyeman » Tue Dec 26, 2017 11:49 pm

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.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests