SD Card to FTP: Arduino Uno + Icomsat 1.1

hi..

i'm working on a project that needs to send CSV file (which has some data in it) from SD Card to FTP Server.. i'm using Icomsat V1.1 GSM Shield with Uno R3.. so far, i manage to communicate with the SD Card Shield and GSM Shield.. but, my problem is, after sending file to FTP Server, the file is empty.. i'm using GSM_Shield library, with Tx jumper is at 2 and Rx jumper is at 3.. noted that i have connected my GSM shield to 9VDC supply.. my code is as below:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include <SD.h>

int numdata;
char inSerial[10];
int i=0;
const int chipSelect = 4;
char file_name [100]="2014627.csv";
char ftpputname [100];

File dataFile;

void setup()
{
  Serial.begin(9600);
  gsm.begin(9600);
  
  pinMode(chipSelect, OUTPUT);
  pinMode(10, OUTPUT);  
  if (!SD.begin(chipSelect))
  {
    Serial.println("Card failed, or not present");
    return;
  }
  
  Serial.println("card initialized");
  dataFile = SD.open("2014627.csv", FILE_READ);
    if (dataFile)
    {
      Serial.println(" datalog.txt is opened in read mode.");
    }
}


void loop()
{
     
      gsm.SimpleWriteln("AT");
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+CREG?");
     delay(150);
     gsm.WhileSimpleRead();
    
     gsm.SimpleWriteln("AT+SAPBR=2,1");
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+SAPBR=1,1");
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+FTPCID=1");
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+FTPSERV=\"ftpaddress\"");
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+FTPUN=\"ftpusername\"");
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+FTPPW=\"ftppassword\"");
     delay(150);
     gsm.WhileSimpleRead();

     
     gsm.SimpleWriteln("AT+FTPPUTPATH=\"/ftpfolder/\"");
     delay(150);
     gsm.WhileSimpleRead();
     
   dataFile = SD.open(file_name, FILE_READ);    
        
     sprintf(ftpputname, "AT+FTPPUTNAME=\"%s\"", file_name);
     Serial.println(ftpputname);
     gsm.SimpleWriteln(ftpputname);
     delay(150);
     gsm.WhileSimpleRead();
     
     gsm.SimpleWriteln("AT+FTPPUT=1");
     delay(30000);
     gsm.WhileSimpleRead();     
        
     gsm.SimpleWriteln("AT+FTPPUT=2,0");
     delay(3000);
     gsm.WhileSimpleRead();
     delay (30000);
}

please advise.. thanks .. :slight_smile:

char file_name [100]="2014627.csv";
char ftpputname [100];

Aren't those sizes excessive?

hi Paul..

although i resize the size, the problem is still unsolved..
i'm not sure if the command creates a new file named "2014627.csv" in FTP or it calls the file from SD card and send to FTP.. :astonished:

thanks..

shahrule:
hi Paul..

although i resize the size, the problem is still unsolved..
i'm not sure if the command creates a new file named "2014627.csv" in FTP or it calls the file from SD card and send to FTP.. :astonished:

thanks..

Have you tried "dumping" the date of the CSV file into the Serial Monitor? There's "dumpfile" sample in the SD Library.

can you please suggest me which FTP server u r using to store file from sd card..... i want some free ftp server names for my arduino to send DATALOGGER file to be uploaded to FTP server by the end of the day and i want to send mail that file from GSM with AT commands....