Direct transfer file from PC to SD card

Hi Arduino group,

my setup here is

PC, Arduino-Uno, Catalex Micro SD adapter with 1gb sd card

and I would like to know if it is possible to directly transfer a file from my PC via arduino-USB connection to my sd card inside the catalex device?

All samples (ReadWrite, DumpFile (which is dumping to arduino serial from arduino world)) do not show any hint on that.

Could you please assist?
Thank you so much!

java99

and I would like to know if it is possible to directly transfer a file from my PC via arduino-USB connection to my sd card inside the catalex device?

Do not know what you mean by directly transfer

If you dump a file to the serial port, the Arduino can read in a byte at a time and can write it to the SD device.
The problem you will encounter is that the PC sends data faster than the Arduino can handle, so you need either implement a start/stop protocol or another handshake mechanism to prevent (input) buffer overflow on the Arduino side.

Another way to handle this buffer overflow is to send the data at a low baud rate (e.g. 9600) so the Arduino has time enough to handle. WHat the max baud rate is without failure I do know but you can try different speeds until it fails and then take 2 steps lower or so.

Note that 9600 baud is about 1KB/second so 1GB takes up to 1 million seconds ~~ 12 days

Thanks for your detailed answer.

My problem here is in fact, that I do not know how to dump a file located on my notebook to the arduino... There is a sample called "DumpFile" which does about the other way round... dumping to the serial port.

The sketch file is transfered to the arduino and executed. How would I just transfer a file (not a program) to the arduino then to upload onto my sd-card?

java99

Having Arduino involved in the transfer would be slow.
Better is to have an intermediate chip involved that can switch between PC controlling the SD and Arduino controlling the SD.
Something like:

I do not know if anyone has come up with a shield that can do that.
I'd be interested in coming up with one, not sure how much Arduino code would need to go with it for the transfer control.

I have to sent a db file generated via sqlite to sd card via arduino and retrieve it back to the sqlite studio.
But through arduino we can send only text or binary file. Now i am trying to convert it into text file.
Now how can i send a sample text file to sd card from pc .
Where datalog.txt in the dump example is situated. I have created a datalog.txt but still it cannot read. i think it is because some directory path should be there to specify it. now where should i put this file?

muhammad_zubair:
I have to sent a db file generated via sqlite to sd card via arduino and retrieve it back to the sqlite studio.
But through arduino we can send only text or binary file. Now i am trying to convert it into text file.
Now how can i send a sample text file to sd card from pc .

You can send any file from a PC to an Arduino using a decent terminal program that allows you to send files from the PC; I use RealTerm under Windows.

You need to be aware of the fact that writing to SD is relatively slow so there is a chance that you loose data if it all goes to fast. Therefore you have to stop the transfer while the data is actually written (usually every 512 bytes) using a protocol or a handshake.

muhammad_zubair:
Where datalog.txt in the dump example is situated. I have created a datalog.txt but still it cannot read. i think it is because some directory path should be there to specify it. now where should i put this file?

I have no idea what this means. Do you have a file on SD and can't read it using Arduino?

I have a similar goal – to send data (files, commands) from PC to MCU and MCU to PC (most data will be stored in external flash).

I'm writing my own serial "protocol" to do that based on "bootloader to host" communication.

My "protocol" sends up to 256bytes Packets:

First byte is a "byte amount in packet" value that lets host or MCU to know how many bytes it should expect.
2nd Byte is "command id"/"ACK"/"NACK" byte to determine packet type.

3-252 bytes actual data to send.

Last 4 bytes CRC error correction value.

As a host I'm using Processing IDE for now (it sucks cuz it interprets byte differently than MCU but it has it's advantages too)... Anyway, I will write my own host APP later...

In my current code state I'm able to send comands and files up to 1packet size and display it on the screen (data, images), but I still need to work on the part when Images are bigger than my packet size. I will get it to work eventually...

Take it as an example cuz I'm not an expert in creating protocols, I'm just going with the info I have...

The point is – it's not easy goal, but it's possible...

P.S. muhammad_zubair wrote: "...But through arduino we can send only text or binary file. ..." – made me chuckle inside – everything that is digital is binary – images, video, your browser history act... The difference is how that data gets interpretated, but beneath it it's all 0 and 1.