Reading the Arduino SD Card

Here is the project, I have a raspberry connected via GPIO to the arduino. The arduino is compiling a list of data via a text file on the sd card (sensors and what not). I can send data TO the arduino. But once the text file is created on the sd card, I can not then see the sd card (on the arduino) from the raspberry to copy it or even SEND the text file to the raspberry.

Solutions: 1: (Preferred) to be able, from the raspberry, to see the arduino sd card and copy/move the text file to the raspberry for processing. 2: send the text file from the arduino (via gpio) to the raspberry sd card into a protected directory for processing after XX time.

We have been fighting this for some time and are hitting a brick wall. Does anyone have a suggestion?

Thanks.

1: (Preferred) to be able, from the raspberry, to see the arduino sd card and copy/move the text file to the raspberry for processing.

Not going to happen. The Arduino can’t allow the PI to access it’s file system, because it doesn’t have one.

2: send the text file from the arduino (via gpio) to the raspberry sd card into a protected directory for processing after XX time.

So, what’s the problem?

The problem is we do not know the command on the arduino side to be able to send the text file from the arduino back to the raspberry. If there is a code to try, we are more than willing to try at this point. Going on 3 months now of investigation and trial and error.

We have tried both the standard arduino uno and the alamode.

Thanks

The problem is we do not know the command on the arduino side to be able to send the text file from the arduino back to the raspberry.

How is the PI communicating with the Arduino? Serial? I2C? SPI?

The same process can be used in the other direction.

The pi is communicating via serial. We can send commands TO the arduino, but we cannot get a text file to flow from the Arduino to the Pi.

Can you send "hello world" kind of things using Serial.print and receive them on the Pi?

We can send it and see it in a serial window on the Pi. But we are trying for a text file from the arduino's SD card to the pi. That is where we are getting stuck

We can send it and see it in a serial window on the Pi.

That's good.

But we are trying for a text file from the arduino's SD card to the pi.

Hoping looks more like it. I don't see any code where you actually try to open a file on the SD card, where you actually try to read from the file, or where you actually Serial.print() the data that you read.

That is where we are getting stuck

I'm not sure I agree that that is where you are stuck.

We are not trying to read the file, we are trying to move it, via serial, from the arduino to the pi.

Once the text file is generated on the SD card on the arduino, we have yet to be successful in moving it from there. If we remove the SD card and put it into a pc, we can see it and work with it. But we need it to be moveable from the arduino (SD Card) to the pi via programming.

jdannels: We are not trying to read the file, we are trying to move it, via serial, from the arduino to the pi.

There is no file system on the Arduino. It isn't a PC and there isn't an operating system. So there is no "command" to manipulate files.

You must write code on the Arduino that opens the file, reads it, and transmits it. On the Pi side you need code that can receive that data in whatever pre determined format you use.

jdannels:
We are not trying to read the file, we are trying to move it, via serial, from the arduino to the pi.

Once the text file is generated on the SD card on the arduino, we have yet to be successful in moving it from there. If we remove the SD card and put it into a pc, we can see it and work with it. But we need it to be moveable from the arduino (SD Card) to the pi via programming.

Right. And the way to move a file from any one physical storage medium to another storage medium is something needs to read from one and write to the other. In this case, the Arduino needs to read the file, transmit what it has read to the pi, and then the pi needs to write what it heard from the Arduino. Note, this is copying. If you want to complete the move, then delete the file on the Arduino side.

Even on your computer. If you cut and paste or drag and drop to move a file from a USB stick to your HDD, the computer reads the file as a strings on ones and zeros from the USB stick, and then writes that same string of ones and zeros to the HDD. Then to complete the “move” the computer will delete the file on the USB stick by writing the the file index that the space taken by that file is now available for other things to use.

Ok... I think we are getting off track here. I don't want you to think that this is our first time around here. Or that we aren't grateful for any help that you or anyone is attempting to provide.

Here is the direct question, Do you know how to get, via serial, a text file off of the SD card on the arduino to the Pi?

Going over the symantecs of what the copy process is is not helping anyone as I'm sure explaining the intricacies of pasting on a windows machine would be tedious to you since I would assume you already know it. So let's just get to the brass tacks here and in reality, try to work together for this specific goal.

What we have been able to do is send commands to the Arduino that initiates and reads the different leads and writes their results to a text file.

Now, as is the question, is there a piece of code that can assist in writing/ copying/ moving the file, via serial, from the arduino to the pi?

Now, as is the question, is there a piece of code that can assist in writing/ copying/ moving the file, via serial, from the arduino to the pi?

What part of this are you having problems with? Telling the Arduino to stream the file back? Making the Arduino open the file on the SD card? Making the Arduino read the file? Making the Arduino write the contents of the file to the serial port? Making the PI collect the data and write it to a file?

What you want to do seems trivial, if you can send info to the Arduino via the serial port, and get info from the Arduino via the serial port.

Help us understand what part of the process you need help with.

The only way you're going to get your file to the Pi is to read it and send it to the serial port - there's no built in facility on the Arduino to do it for you. You'll need some software on the receiving end too. However, I did notice this in the playground: http://playground.arduino.cc//Code/FTP

Disclaimer - I've never used it, nor did I give the code more than a brief perusal. Check it out; might give you some clues at least.

is there a piece of code that can assist in writing/ copying/ moving the file, via serial,

Somebody may have written something but unless they come forward or you can find it with google the answer is essentially "no"

So let's just get to the brass tacks

In a nutshell you need to do as follows on the Arduino

do {
    read byte from SD
    write byte to serial
} until (end of file)

Rob

@jdannels:

Which SD Card library are you using? The pre-installed SD lib referenced here: http://arduino.cc/en/Reference/SD ??

If so, under File Class, you will note there is a read() function. AFter the Arduino has closed out the last write and the SD card has the file, you will need to SD.open() the filename again and then use the read() to accomplish your send. This also implies that you are opening a Serial Connection (physical USART or Software Serial) on the Arduino to the outside at a particular BAUD rate. The Pi must open the same physical TTL connection as read with the appropriate BAUD rate.

I think that the confusion is in all the semantics changes when you change from write mode to read mode. This should clear up the Arduino end of things:

http://www.ladyada.net/products/microsd/

To simplify the process, just take the Pi out of the equation for a while and concentrate reading a TEXT file from the SD card to the Arduino terminal. At that point, you are 99% there. The Pi end will simply read this Arduino text stream and write it where ever you want to put it... eeprom, Flash Card, another terminal, etc.

Ray

For real code, there's the DumpFile example that ships with the IDE:

File -> Examples -> SD -> DumpFile

You also need a program on the PC side to catch the data and store it in a file, as has been mentioned. Easily found with a forum search.

-br

Thanks guys, I will start testing this as soon as I get home tonight to see if I can get this to work. I really appreciate all your efforts in helping me with this problem and hope someday I can return the favor.