Go Down

Topic: Writing to SARA-U201 file system (Read 884 times) previous topic - next topic


Jun 15, 2018, 12:08 pm Last Edit: Jun 15, 2018, 12:10 pm by MohitB
I am working with MKR GSM 1400 to upload file to FTP server from Sdcard interfaced to the board. I read the data sheet of GSM modem SARA-U201 and found that first you have to create a file in U201 file system and then transfer to FTP server. I am able to create and write to the file system of U201 but it takes around 7-8 minutes to copy data from SDCARD to gsm modem file system for 1MB file. Can anyone tell me faster way to copy data.

Code: [Select]
#include <SPI.h>
#include <SD.h>

unsigned long baud = 19200;

bool debug = 1;

char* file_name1 = "REC00000.wav";
File File1;
int file_size_sd;
long int bytes;   

void setup()
  pinMode(2, OUTPUT);

  while (!Serial)
        ; // wait for serial port to connect. Needed for native USB port only
  digitalWrite(GSM_RESETN, HIGH);
  digitalWrite(GSM_RESETN, LOW);


  if (!SD.begin(2)) {
    Serial.println("Initialization failed!");
  }else {
    Serial.println("Initialization done.");

  File1 = SD.open(file_name1);
  if (File1) {
    Serial.println("Opening the file: " + String(file_name1) + " done.");
  }else {
    Serial.println("Error opening " + String(file_name1));

   if (File1) {
     int i = 0;
     file_size_sd = File1.size();

     sendATcommand("AT+ULSTFILE=","OK", 1000);                   //List all the files in the file system

     sendATcommand("AT+ULSTFILE=1","OK", 1000);                   //get free space in file system
     sendATcommand("AT+UDWNFILE=\"sound.wav\",2000000","OK", 1000);     //create a file in gsm file system

     Serial.println("Copy file data");   
     while (File1.available()>0) {

     Serial.println("Done Writing");


void loop()

unsigned char sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout) {
  unsigned char x = 0;
  unsigned char answer = 0;
  char response[100];
  unsigned long previous;
  memset(response, '\0', 100);
  while( SerialGSM.available() > 0) SerialGSM.read();
  x = 0;
  previous = millis();
    if(SerialGSM.available() != 0){   
      response[x] = SerialGSM.read();
      if (strstr(response, expected_answer1) != NULL) {
        answer = 1;
  } while((answer == 0) && ((millis() - previous) < timeout));
  if (debug) {Serial.println(response);}
  return answer;


In the Serial Passthrough Example sketch the Baud rate is set to "115200", any reason your Baud rate is set to only "19200"?

Have you tried just creating a simple text file instead of a .wav file? I'd imagine that would cut your copy time down significantly too.

Very cool project by the way.


Changing the baud rate worked, now i am able to write it faster than before. Is 115200 highest baud rate that can be used with this board?

Go Up