Go Down

Topic: [SOLVED] Recovering photos from SD card - Console freezes by big jpeg files (Read 5845 times) previous topic - next topic


I am talking about the way Processing code -who grabs the data from serial- writes them in the .txt file. Maybe there's the problem.

JPEG data is typically not stored in text files. You REALLY need to understand binary vs. ASCII data. Neither end of the serial port should be attempting to understand the data.

Read a byte from the file. Write it to the serial port.

Read a byte from the serial port. Write it to a BINARY file using a BINARY stream writer.

The art of getting good answers lies in asking good questions.


  Thanks a lot for the guidance. I knew there was something wrong with my Processing code so I searched the Processing forum and I found this code that worked for me.

Code: [Select]
import processing.serial.*;

   Serial myPort;
   OutputStream output;

    void setup() {

     size(320, 240);
     myPort = new Serial( this, Serial.list()[0], 115200);

     output = createOutput("formula3.jpg");

   void draw() {

     try {
       while ( myPort.available () > 0 ) {
     catch (IOException e) {

   void keyPressed() {

     try {
       output.flush();  // Writes the remaining data to the file
       output.close();  // Finishes the file

     catch (IOException e) {

In combination with this code I modified for Arduino...
Code: [Select]
#include <SdFat.h>

SdFat sd;
SdFile myFile;
const int chipSelect = 10;

void setup() {
 //Serial.println("Type any character to start");
 //while (Serial.read() <= 0) {}
 if (!sd.begin(chipSelect, SPI_FULL_SPEED)) sd.initErrorHalt();

 if (!myFile.open("DCIM/###D####/_DSC####.JPG", O_READ)) {
   sd.errorHalt("opening file for read failed");

 int data;
 while ((data = myFile.read()) >= 0) Serial.write(data);


void loop() {
 // nothing happens after setup

... I finally managed to recover my 6Mb photos from my almost dead SD card. I only need to add an iteration to just don't do this manually using <CardInfo> photo names.  XD

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131