user32336: I am working on a class project where I am using a Teensy 3.5 with a Prop Shield with sensor attached that will be loaded into a rocket that I will launch and gather data from the altitude, pressure and temperature sensors and then read into an array and then dump at the peak of the height and when it hits the ground. I believe I have everything working when I test the code but when I open up the txt file I get what looks to be ASCII code but I don't know how to fix it.
Below is the code:
//import statements
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_MPL3115A2.h>


// global variable declarations
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();

int seconds = 0;
int secondsPerTick = 0;
int counter = 0;
double pressure[15];
double heightA[15];
double temperature[15];
File myFile;
int tempNum;
const int chipSelect = BUILTIN_SDCARD;




//test to make sure program uploaded
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");
  while (!Serial){
}

  if (! baro.begin()) {
    Serial.println("Couldnt find sensor");
   return;
  }


if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }

while ( seconds < 5 ){

              double pascals = baro.getPressure();
              pressure[counter] = pascals;
              Serial.print(pascals/3377); Serial.println(" Inches (Hg)");

             double altm = baro.getAltitude();
              heightA[counter] = altm;
              Serial.print(altm); Serial.println(" meters");

             double tempC = baro.getTemperature();
              temperature[counter] = tempC;
              Serial.print(tempC); Serial.println(" *C");
              tempNum ++;



              secondsPerTick++; //increments seconds per tick
              if(secondsPerTick == 3){  //if its 3 reset "secondspertick" and increments "seconds"
                secondsPerTick = 0;
                seconds++;
              }
              counter++;

 }


myFile = SD.open("Sensor4.txt", FILE_WRITE);

   if(myFile) {
    Serial.print("Writing to file...");

    //cycle through the array and store it in the SD card
    myFile.write("Pressure Recordings(going up): ");
    for(int i=0; i< 15; i++){
      myFile.write(pressure[i]);
      }
    Serial.println('\n');

       //header for the height sensor recordings
   myFile.write("Height Recordings(going up): ");
    //cycle through the array and store it in the SD card
    for (int j = 0; j <15; j ++){
     myFile.write(heightA[j]); 
    }
    Serial.println('\n');

    //header for the temperature sensor recordings
    myFile.write("Temperature Recordings(going up): ");
    Serial.println('\n');
    //cycle through the array and store it in the SD card
    for (int k = 0; k <15; k++){
     myFile.write(temperature[k]);
    Serial.println('\n');
   }

    // close the file:
    myFile.close();
    Serial.println("done.");
    }
   else {
    // if the file didn't open, print an error:
    Serial.println("error opening sensor_recordings.txt");
  }

     //as the rocket descends      
while ( seconds > 5 ){

              double pascals = baro.getPressure();
              pressure[counter] = pascals;
              Serial.print(pascals/3377); Serial.println(" Inches (Hg)");

              myFile.write(pressure[counter]);

             double altm = baro.getAltitude();
              heightA[counter] = altm;
              Serial.print(altm); Serial.println(" meters");

             double tempC = baro.getTemperature();
              temperature[counter] = tempC;
              Serial.print(tempC); Serial.println(" *C");
              tempNum ++;



              secondsPerTick++; //increments seconds per tick
              if(secondsPerTick == 3){  //if its 3 reset "secondspertick" and increments "seconds"
                secondsPerTick = 0;
                seconds++;
              }
              counter++;

 }


myFile = SD.open("Sensor4.txt", FILE_WRITE);

   if(myFile) {
    Serial.print("Writing to file...");

    //cycle through the array and store it in the SD card
    myFile.write("Pressure Recordings(going down): ");
    for(int i=0; i< 15; i++){
      myFile.write(pressure[i]);
      }
    Serial.println('\n');

       //header for the height sensor recordings
   myFile.write("Height Recordings(going down): ");
    //cycle through the array and store it in the SD card
    for (int j = 0; j <15; j ++){
     myFile.write(heightA[j]); 
    }
    Serial.println('\n');

    //header for the temperature sensor recordings
    myFile.write("Temperature Recordings(going down): ");
    Serial.println('\n');

    //cycle through the array and store it in the SD card
    for (int k = 0; k <15; k++){
     myFile.write(temperature[k]);
    Serial.println('\n');
   }

    // close the file:
    myFile.close();
    Serial.println("done.");
    }
   else {
    // if the file didn't open, print an error:
    Serial.println("error opening sensor_recordings.txt");
  }
 }

void loop() { 

Here is what gets printed to the txt file:

€€€ƒ€ƒ‚ƒ€€„~ƒ‚€€€€ƒ€ƒ‚ƒ€€„~ƒ‚€ƒ‚‚‚„‡€„ƒ„……ƒ‚ƒ„Pressure Recordings: ƒ‚‚‚„‡€„ƒ„……ƒ‚ƒ„
  Height Recordings: 10010110010101111000Temperature 
  Recordings: Å……ƒƒ…€€ƒ‡‚w
  Pressure Recordings: Å……ƒƒ…€€ƒ‡‚w
  Height Recordings: 000010100010111     Temperature Recordings:      Pressure Recordings: Å……ƒƒ…€€ƒ‡‚w     Height Recordings: 000010100010111     Temperature Recordings:      Pressure Recordings: Ã‡…„†…„…„ˆ†„„€†     Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings: Ã‡…„†…„…„ˆ†„„€†     Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings: Â†‰†‡…††‰…‰ˆˆ…ˆ Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings: Â†‰†‡…††‰…‰ˆˆ…ˆ Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings(going up): ÀŽ‘ŽŒŽŽHeight Recordings(going up): ///000/0/0/0///Temperature Recordings(going up): Pressure Recordings(going down): ÀŽ‘ŽŒŽŽHeight Recordings(going down): ///000/0/0/0///Temperature Recordings(going down): Pressure Recordings(going up): ½–™––•˜–••š™š—™Height Recordings(going up): ///////////////Temperature Recordings(going up): Pressure Recordings(going down): ½–™––•˜–••š™š—™Height Recordings(going down): ///////////////Temperature Recordings(going down): 

I also don't know how I can get the data to be formatted to where it reads like:
Pressure(going up):----
Altitude(going up):---
Temperature(going up):---
Pressure(going down):----
Altitude(going down):---
Temperature(going down):---

user31542: You should convert double to String with this kind of code:
char[9] stringval;
dtostrf(doubleval, 8, 4, stringval);

where 8 is presicion and 4 is number of digits after point.
More info: http://forum.arduino.cc/index.php?topic=282250.0

32336: <p>I am working on a class project where I am using a Teensy 3.5 with a Prop Shield with sensor attached that will be loaded into a rocket that I will launch and gather data from the altitude, pressure and temperature sensors and then read into an array and then dump at the peak of the height and when it hits the ground. I believe I have everything working when I test the code but when I open up the txt file I get what looks to be ASCII code but I don't know how to fix it.</p>

<p>Below is the code:</p>

<pre><code>//import statements
#include &lt;SD.h&gt;
#include &lt;SPI.h&gt;
#include &lt;Wire.h&gt;
#include &lt;Adafruit_MPL3115A2.h&gt;


// global variable declarations
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();

int seconds = 0;
int secondsPerTick = 0;
int counter = 0;
double pressure[15];
double heightA[15];
double temperature[15];
File myFile;
int tempNum;
const int chipSelect = BUILTIN_SDCARD;




//test to make sure program uploaded
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");
  while (!Serial){
}

  if (! baro.begin()) {
    Serial.println("Couldnt find sensor");
   return;
  }


if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }

while ( seconds &lt; 5 ){

              double pascals = baro.getPressure();
              pressure[counter] = pascals;
              Serial.print(pascals/3377); Serial.println(" Inches (Hg)");

             double altm = baro.getAltitude();
              heightA[counter] = altm;
              Serial.print(altm); Serial.println(" meters");

             double tempC = baro.getTemperature();
              temperature[counter] = tempC;
              Serial.print(tempC); Serial.println(" *C");
              tempNum ++;



              secondsPerTick++; //increments seconds per tick
              if(secondsPerTick == 3){  //if its 3 reset "secondspertick" and increments "seconds"
                secondsPerTick = 0;
                seconds++;
              }
              counter++;

 }


myFile = SD.open("Sensor4.txt", FILE_WRITE);

   if(myFile) {
    Serial.print("Writing to file...");

    //cycle through the array and store it in the SD card
    myFile.write("Pressure Recordings(going up): ");
    for(int i=0; i&lt; 15; i++){
      myFile.write(pressure[i]);
      }
    Serial.println('\n');

       //header for the height sensor recordings
   myFile.write("Height Recordings(going up): ");
    //cycle through the array and store it in the SD card
    for (int j = 0; j &lt;15; j ++){
     myFile.write(heightA[j]); 
    }
    Serial.println('\n');

    //header for the temperature sensor recordings
    myFile.write("Temperature Recordings(going up): ");
    Serial.println('\n');
    //cycle through the array and store it in the SD card
    for (int k = 0; k &lt;15; k++){
     myFile.write(temperature[k]);
    Serial.println('\n');
   }

    // close the file:
    myFile.close();
    Serial.println("done.");
    }
   else {
    // if the file didn't open, print an error:
    Serial.println("error opening sensor_recordings.txt");
  }

     //as the rocket descends      
while ( seconds &gt; 5 ){

              double pascals = baro.getPressure();
              pressure[counter] = pascals;
              Serial.print(pascals/3377); Serial.println(" Inches (Hg)");

              myFile.write(pressure[counter]);

             double altm = baro.getAltitude();
              heightA[counter] = altm;
              Serial.print(altm); Serial.println(" meters");

             double tempC = baro.getTemperature();
              temperature[counter] = tempC;
              Serial.print(tempC); Serial.println(" *C");
              tempNum ++;



              secondsPerTick++; //increments seconds per tick
              if(secondsPerTick == 3){  //if its 3 reset "secondspertick" and increments "seconds"
                secondsPerTick = 0;
                seconds++;
              }
              counter++;

 }


myFile = SD.open("Sensor4.txt", FILE_WRITE);

   if(myFile) {
    Serial.print("Writing to file...");

    //cycle through the array and store it in the SD card
    myFile.write("Pressure Recordings(going down): ");
    for(int i=0; i&lt; 15; i++){
      myFile.write(pressure[i]);
      }
    Serial.println('\n');

       //header for the height sensor recordings
   myFile.write("Height Recordings(going down): ");
    //cycle through the array and store it in the SD card
    for (int j = 0; j &lt;15; j ++){
     myFile.write(heightA[j]); 
    }
    Serial.println('\n');

    //header for the temperature sensor recordings
    myFile.write("Temperature Recordings(going down): ");
    Serial.println('\n');

    //cycle through the array and store it in the SD card
    for (int k = 0; k &lt;15; k++){
     myFile.write(temperature[k]);
    Serial.println('\n');
   }

    // close the file:
    myFile.close();
    Serial.println("done.");
    }
   else {
    // if the file didn't open, print an error:
    Serial.println("error opening sensor_recordings.txt");
  }
 }

void loop() { 
</code></pre>

<p>Here is what gets printed to the txt file:</p>

<blockquote>
  <p>€€€ƒ€ƒ‚ƒ€€„~ƒ‚€€€€ƒ€ƒ‚ƒ€€„~ƒ‚€ƒ‚‚‚„‡€„ƒ„……ƒ‚ƒ„Pressure Recordings: ƒ‚‚‚„‡€„ƒ„……ƒ‚ƒ„
  Height Recordings: 10010110010101111000Temperature 
  Recordings: Å……ƒƒ…€€ƒ‡‚w
  Pressure Recordings: Å……ƒƒ…€€ƒ‡‚w<br>
  Height Recordings: 000010100010111     Temperature Recordings:      Pressure Recordings: Å……ƒƒ…€€ƒ‡‚w     Height Recordings: 000010100010111     Temperature Recordings:      Pressure Recordings: Ã‡…„†…„…„ˆ†„„€†     Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings: Ã‡…„†…„…„ˆ†„„€†     Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings: Â†‰†‡…††‰…‰ˆˆ…ˆ Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings: Â†‰†‡…††‰…‰ˆˆ…ˆ Height Recordings: 000000000000000     Temperature Recordings:      Pressure Recordings(going up): ÀŽ‘ŽŒŽŽHeight Recordings(going up): ///000/0/0/0///Temperature Recordings(going up): Pressure Recordings(going down): ÀŽ‘ŽŒŽŽHeight Recordings(going down): ///000/0/0/0///Temperature Recordings(going down): Pressure Recordings(going up): ½–™––•˜–••š™š—™Height Recordings(going up): ///////////////Temperature Recordings(going up): Pressure Recordings(going down): ½–™––•˜–••š™š—™Height Recordings(going down): ///////////////Temperature Recordings(going down): </p>
</blockquote>

<p>I also don't know how I can get the data to be formatted to where it reads like:</p>

<p>Pressure(going up):----</p>

<p>Altitude(going up):---</p>

<p>Temperature(going up):---</p>

<p>Pressure(going down):----</p>

<p>Altitude(going down):---</p>

<p>Temperature(going down):---</p>
 31542: <p>You should convert double to String with this kind of code:</p>

<pre><code>char[9] stringval;
dtostrf(doubleval, 8, 4, stringval);
</code></pre>

<p>where 8 is presicion and 4 is number of digits after point.</p>

<p>More info: <a href="http://forum.arduino.cc/index.php?topic=282250.0" rel="nofollow noreferrer">http://forum.arduino.cc/index.php?topic=282250.0</a></p>
