I have connected a SD card to arduino mega board using a seperate connector at the SS, MISO, MOSI and SCK pins of the mega. I have used a function file.read() to read an jpg file from the SD card. I want to serially transmit this file to a PC using the command serial.println. The data i received is very complicated. I don't know what it is and how can i convert it back to the original jpeg file. Please help.
What do you have on the PC ?
Windows or Linux ? Which version ?
What kind of serial monitor software ?
The serial monitor of the Arduino IDE can not be used for file transfer.
Are you able to use scripting, like Python ?
This dumps a file via the serial port, but it doesn't explain the software on the PC,
Why can't you take the microSD card out, and put it in the PC ?
I want to serially transmit this file to a PC using the command serial.println.
that will be the Serial.write(byte(data) ) ; command to send a single byte of "data" to the PC.
Transferring an image is going to take a long time or else it has to be a small image.
The data i received is very complicated.
Yes it is.
I don't know what it is and how can i convert it back to the original jpeg file.
It should be a jpeg file, what converts it into anything else?
If you really care about speed you do not want to use the arduino library. Instead set this up manully. Here is code for 0.5M baud the fastest I could get out of my uno faster misses bytes.
To enable serial do
UBRR0H=0;
UBRR0L=3;//3 = 0.5M 2M baud rate = 0 7 = 250k 207 is 9600 baud rate
UCSR0A|=2;//double speed aysnc
UCSR0B = (1<<RXEN0)|(1<<TXEN0);//Enable receiver and transmitter
UCSR0C=6;//async 1 stop bit 8bit char no parity bits
To write a byte do
UDR0=dat;
while ( !( UCSR0A & (1<<UDRE0)) ) {} //wait for byte to transmit
Also do not use the SD library that comes with the arduino IDE that one is HORRIBLE. Use sdfatlib instead. Google Code Archive - Long-term storage for Google Code Project Hosting.
The SD library that comes with the arduino IDE can wear out your card overtime as writes are not buffered and it is very slow sdfatlib is much faster and better coded.