Speed of SD Card & Arduino !

Hi All, i am facing a problem while transferring a data in a file in SD Card (that connected with the Arduino UNO ), to another Arduino UNO using the Serial Port, the received data have a high speed, and that cause some problems like printing the data in the Serial monitor in different format or lets say in not organized format as the format of the data in the SD Card. So, i want to know how to reduce the speed of the received data that are coming from an SD Card through the serial port of the Arduino. I thing the speed of both the Arduino & the SD Card are not the same, so i want ot make them have same speed . Regards, AishaJ.

Have you read this before posting a programming question ? Without seeing your code (all of it) it is not possible to provide sensible advice.

the received data have a high speed

Nonsense. Data does not have speed.

these are the codes used in the sender & the receiver Arduino,

my problem is that when i transfer the extracted data from the SD card in the sender to the Receiver via XBees connected in the serial ports of both Arduino , the result is that as shown in the pictures of the Receiver.

I received a garbage & i some of the data are not complete , i do not know what is the reason.

The Receiver Code :

#include <SPI.h>
#include <SD.h>

String inputString ;        
boolean stringComplete = false;  
const int chipSelect = 4;

char inChar=0;


//------------------------
char computerdata[14]; 
char Sensor_data[15]; 
byte received_from_computer=0; 
byte received_from_sensor=0;  
byte string_received=0; 
//-----------------------

void setup() {
  Serial.begin(9600);
  
  inputString.reserve(200);  
  
 //---------------------------------------------------------------------- 
  Serial.print("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    return;                   }
    
  Serial.println("card initialized.");

}
//-----------------------------------------------------------------------

void serialEvent() {

     received_from_computer=Serial.readBytesUntil('~',computerdata,14);    
           computerdata[received_from_computer]=0;
           Serial.print(computerdata); 
           
           Serial.print('\r'); 
}
  
//------------------------------------------------------------------------

void loop() {
    if(Serial.available() > 0){      
  //    serialEvent();
}




//-------------------------------------------------------------

File dataFile = SD.open("datalog8.txt", FILE_WRITE);
  //delay(1000);
  
  if (dataFile) { 
    dataFile.println(computerdata);
    dataFile.println(" ");
    dataFile.close();
  //delay(1000);
  }
  else {
    Serial.println("error opening datalog.txt");
  }
}

The Sender Code :

 int i=0;
 int j=0;

#include <SPI.h>
#include <SD.h>
#include <Sensirion.h>
//--------------------------------------------------------
#define trigPin 2 // blue
#define echoPin 3 // green
//----------------------------------------------------------
const uint8_t dataPin  =  6;
const uint8_t clockPin =  7;

// Variables for the temperature & humidity sensor
float temperature;
float humidity;
float dewpoint;
File dataFile;

 String dataString = "";
 float temp;
 int analogPin=0;

// Create sensor instance
Sensirion soilSensor = Sensirion(dataPin, clockPin);

const int chipSelect = 4;

//-----------------------------------------------------------------
void setup() {
  Serial.begin (9600); // allows terminal access
  
  pinMode(trigPin, OUTPUT);         // set up pin to trigger
  pinMode(echoPin, INPUT); 

  Serial.print("Initializing SD card...");
  
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");  
    return;
  }
  Serial.println("card initialized.");
  
 //-------------------------------------------------

}
//--------------------------------------------------------------------

void loop() {
  int duration, distance;           // set up variables
  digitalWrite(trigPin, HIGH);      // start of trigger sequence
  delayMicroseconds(1000);          // delay 1ms
  digitalWrite(trigPin, LOW);       // complete trigger sequence
  duration = pulseIn(echoPin, HIGH);  // see: http://arduino.cc/en/Reference/pulseIn
  distance = (duration/2) / 29.1;  // calculate distance from time
                                   // Divide the time in half (because
                                   // the pulse travelled to the object
                                   // AND back again.
                                   // Then divide the time by 29.1 microseconds/cm
                                   // (the speed of sound).


//------------------------------------------------------------------------------------
  if (distance >= 30 || distance <= 0){  // remove out-of-bounds readings
    Serial.println("Out of range");

while(i<5){ // number of readings
delay(5000); 
 soilSensor.measure(&temperature, &humidity, &dewpoint);
  
  // read three sensors and append to the string:

    float sensor = analogRead(analogPin);
   temp= sensor / 1023.0 * 1.23;
 //  temp= temp -0.5;
   temp= temp/ 0.01;
    dataString = (String)temp;
   if (analogPin < 1) {
      dataString += " ";
    }

dataFile = SD.open("datalog6.txt", FILE_WRITE);
 
  if (dataFile) { 
        
    dataFile.print("Temperature(1): ");
    dataFile.print(temperature);
    dataFile.print(" C, Temperature(2): ");
    dataFile.print(dataString); 
    dataFile.print("    C, Humidity: ");
    dataFile.print(humidity);
    dataFile.print(" %");
    dataFile.println("\0");
   //  dataFile.close();
    
  dataFile.close();
  }
   
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
  i++;
}//----- cllosing for 
    
  }
  else {                           // print distance if valid
    Serial.print(distance);
    Serial.println(" cm");
    
//while(j<=2 )
//{
File dataFile1 = SD.open("datalog6.txt", FILE_READ);

    if (dataFile1) {
      
    while (dataFile1.available()>0) {
      Serial.write(dataFile1.read());
      
    }
    delay(3000);
       dataFile1.close();
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt>>>>>>>");
  }
//  j++;  
 //} 
  i=0;
 SD.remove("datalog6.txt");
File dataFile2 = SD.open("datalog6.txt", FILE_WRITE);
dataFile2.close();
}
 
  j=0;
}

Sender.jpg

    dataString = (String)temp;

WTF? What do you think you are accomplishing by casting a float to a String object? That is NOT a meaningful cast. The sizes aren't even remotely the same.

Stuffing pure garbage into dataString is not a useful tactic.

There is NO reason to have the term String ANYWHERE in your code. GET RID OF ALL USES OF String.

    if(Serial.available() > 0){     
  //    serialEvent();
}

Adding a comment makes no sense. If your damned delete key is broken, GET A NEW KEYBOARD!

You are STILL logging data even if nothing has arrived. I give up.

Change the baudrate, in the serial monitor or in the code.