Download a File from a FTP Server and Save on SD Card?

Hello to all,

I'm trying make a simple project, with the objective of making download of a file from an FTP Server trough a GSM/GPRS modem and save that file on an SD Card.

For the GSM/GRPS Modem: LoNet - GSM/GPRS Breakout, and for the SD Card: Adafruit MicroSD card breakout board+.

For communication Serial/SoftSerial with the GSM/GPRS modem it is done through the AT commands.
My big doubt is how to save this file downloaded from the FTP Server to the SD Card.

How to save the content obtained by the command AT+FTPGET=2,1024 and record it as a file on the SD card.

All the examples I have seen is using the Ethernet Shield that contains a slot for SD CARD.

Can someone help me or give some tips?

All the examples I have seen is using the Ethernet Shield that contains a slot for SD CARD.

The process is exactly the same. The source of the data to be saved is the only difference. What have you tried? What happened?

All the examples I have seen is using the Ethernet Shield that contains a slot for SD CARD.

So, does your board contain the SD card slot?

Just I do not understand how to do, I'm a bit stuck.

I'm using Arduino Uno Rev 3 with a SD Card Breakout.

Just I do not understand how to do, I'm a bit stuck.

If you don't post your code, and a link to the hardware you are actually trying to use, you can't really expect us to help get you unstuck.

http://playground.arduino.cc/Code/FTP

Paul, thank you for your patience.

here is, in relation to the hardware, already mentioned in the first post, but here is again the names and respective links:

In relation to the code, here it is:

/*
 
*/

#include <SoftwareSerial.h>

SoftwareSerial sim800(7, 8);

int x;
char data[1024];

void setup(){
  Serial.begin(9600);
  sim800.begin(19200);
  Serial.println("Starting FTP Download...");

  delay(5000);

  sim800.println("AT"); //check AT
  sim800Reply();
  sim800.println("AT+CSQ");
  sim800Reply();
  sim800.println("AT+CGATT?");
  sim800Reply();
  /*
  sim800.println("AT+CSTT");
  sim800Reply();
  sim800.println("AT+CIICR");   
  Serial.flush();
  sim800Reply();
  sim800.println("AT+CIFSR");   
  Serial.flush();
  sim800Reply();
  */
  sim800.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  sim800Reply();
  sim800.println("AT+SAPBR=3,1,\"APN\",\"UMTS\"");
  sim800Reply();
  sim800.println("AT+SAPBR=1,1");
  sim800Reply();
}

void loop() {
  sim800.println("AT+FTPCID=1");
  sim800Reply();
  sim800.println("AT+FTPMODE=1");
  sim800Reply();
  sim800.println("AT+FTPTYPE=\"I\"");
  sim800Reply();
  sim800.println("AT+FTPSERV=\"<ip>\"");
  sim800Reply();
  sim800.println("AT+FTPUN=\"<username>\"");
  sim800Reply();
  sim800.println("AT+FTPPW=\"<password>\"");
  sim800Reply();
  sim800.println("AT+FTPGETNAME=\"README\"");
  sim800Reply();
  sim800.println("AT+FTPGETPATH=\"/\"");
  sim800Reply();
  sim800.println("AT+FTPGET=1");
  sim800Reply();
  delay(5000);
  //sim800.println("AT+FTPGET=2,1024");                        // gets 1024 bytes of data
  sim800Reply();
}

void sim800Reply() {
  x=0;
  do{
    //Serial.println("in here");  //testing
    while(sim800.available()==0);
    data[x]=sim800.read();
    Serial.print(data[x]);
    x++;
  } while(!(data[x-1]=='K'&&data[x-2]=='O'));
}

In that code, Sim800Reply() is called after each send of a command to the GSM. You need to modify that function to perform differently when the reply is the FTP of data from the server. When it is, you need to save the data to a file.