Pages: [1]   Go Down
Author Topic: Suggestions on how to move a file from SD card to the PC  (Read 2024 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I’m using the Arduino to log data on to an SD card and I would like to be able to transfer that file on the card to my Windows PC for further use.

The Arduino is connected through the USB cable but I don’t have enough experience to devise this next step so any suggestions would be greatly appreciated.

Thanks,

Tom
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8070
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Usually the easiest way is to take the SD card out of the Arduino and attach it to your PC through an SD card reader.  Some PCs come with SD slots and if your's doesn't you can buy a USB SD card reader for well under $20.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16517
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Usually the easiest way is to take the SD card out of the Arduino and attach it to your PC through an SD card reader.  Some PCs come with SD slots and if your's doesn't you can buy a USB SD card reader for well under $20.

Yes I would say well under $20, try $1 on E-bay all day with free shipping.

http://www.ebay.com/itm/Mini-USB-2-0-Micro-SD-Writer-TF-Memory-Card-Reader-Blue-/160891950476?pt=US_Memory_Card_Readers_Adapters&hash=item2575e8558c

The one I have came free with the purchase of a SD module.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem with moving the card to the PC is that the Arduino and SD card are on the roof recording solar data which is why I'm looking for something more convenient.

Tom
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since you have a USB serial connection to a PC, why not add a feature to your sketch to send the data from the file over the serial port and capture it on the PC side using your favorite terminal program?

-br
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

billroy,

I'm not sure how to take the data from the terminal program and make it into a useful file.

Tom
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Silly question, I suppose... but couldn't you put the sensor(s) on longer wires... have the Arduino in an upstairs room, to make SD card available for "sneakernetting" data to PC?

Having it (Arduino) outdoors, even in enclosure, is asking for trouble, anyway!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Too many sensors, too many wires.

The Arduino is in an enclosure, temp and moisture controlled box and has been working fine for almost a year. I currently remove the card monthly and transfer the data but with the snow it's a lot more difficult to make the trip onto the roof.

But thanks for the suggestion.
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since you are writing your logs on the SD card you should already know how to write (and read) from it. My understanding is that you have a USB connection. So, in principle, you may transfer the file by repeatedly reading the file and calling serial.write(). The process would be started by the PC sending some message to the Arduino over the serial port.

A basic "protocol" could be:
- send a command (e.g., GET) from the PC to start the transmission (no need to specify a file name, the PC will save the data under a local file name of your choice);
- answer by sending your data divided in small binary chunks (same length, may even contain a checksum);
- for each chunk of data sent, wait for the PC to send an ACK (and define what to do if no ACK is received within a certain amount of time);
- send an EOF when you have sent the last chunk of data.

This would be pure serial transmission so you shouldn't interpolate the usual debugging messages.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok,

It seems like communicating through the USB to the PC is the answer but I have a couple of questions.

I understand what spatula is suggesting but was wondering if I can use the log file that I can create using the terminal program "Putty" and just appending to it for each cycle would work. If so, I'm not sure how to designate the serial.write be directed to Putty (com1) and not the serial monitor in the Arduino user interface (com5).

Thanks,

Tom
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
... was wondering if I can use the log file that I can create using the terminal program "Putty" and just appending to it for each cycle would work. If so, I'm not sure how to designate the serial.write be directed to Putty (com1) and not the serial monitor in the Arduino user interface (com5).

I'm a bit confused, maybe missing something. I understand that you have been able to configure two COM ports on your PC, both can listen for messages from the Arduino and (maybe) send messages to it. Is it a Mega? Anyway, if you already receive data on putty... well, I don't have putty (on Mac) but I believe you can configure it to append new data to an existing file. You'll need to have putty running forever, but this solution is undoubtedly faster than implementing a file transmission protocol, however small.

As for sending data to com1 instead of com5, the answer is in your code. If you decide to write a function to send data on different ports you'll have to post the relevant parts of your existing code -- one cannot guess what is currently sent to com1 vs com5 and where and how the code needs to be changed.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Didn't mean to be confusing.

I didn't necessarily configure 2 com ports. I have Putty installed from another project having nothing to do with this Arduino project and I just noticed it was on com 1. com 5 is the port that the PC set the Arduino to, nothing I did. I don't know how to direct the serial.write to com1. The com 5 I am refering to is the com port the Arduino is connected to and as such, the Arduino serial monitor.

As for Putty running forever that is not a problem since it's a dedictaed PC just for this project and as long as I need to collect the data.

Right now I'm only using some test code to get this thing working. When I write to the SD card I also wrote to the Arduino serial monitor to verify the data that's passing through. How do you modify the code to write to Putty through com1 rather than the Arduino serial monitor through com 5?

I hope that clarifies things.

I really appreciate the help.

Tom
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, now I understand. But no, the Arduino cannot communicate with the PC using a different com port than the one assigned by Windows, com5 in your case. You can, however, open a new putty session and configure it to listen on com5 instead of com1. Just don't do it when the Arduino serial monitor is open because there would be a conflict (and close putty before using the Arduino IDE to upload a new sketch). Once you have configured putty (look especially at the baud rate, it must match the one used by the sketch) it will work as the serial monitor, allowing you to save the log to a file.

Then, in your sketch, you'll need to comment out (i.e., prefix with //) all the debugging statements you print to Serial, and add the Serial.print() instructions for the data you want to log.

This is not an optimal solution, it's tedious to implement and leaves you without the information that the debugging statements can provide. On the other hand it's relatively quick and less likely to introduce bugs that would require time to be fixed, disrupting your data collection. Anyway, make a copy of your original sketch so you can quickly revert to a working condition.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Things are working.

I got Putty working on com5 and the data logging into a file which is on the PC so I'm just about there.

To make it more complicated I spent the day getting Xbees working so now I can go from the roof wirelessly to the other Xbee on an Arduino next to the slave PC. It may not be the most elegant solution but it does what I need. The whole Arduino setup on the roof is solar powered so no  power worries there. The other Arduino is USB powered.

Thanks for all the help.
Logged

Pages: [1]   Go Up
Jump to: