I am working on a final project for my class an I have decided I was going to use the Teensy 3.5 along with Prop Shield With Motion Sensors to get pressure,temperature and altitude readings,
store them into an array, and then dump it all into a text file on the SD card i'm adding when I put them in a 2 stage rocket and launch it into the sky.
The issue I am having is that the code is throwing me errors which I can't figure out. Below is the error messages and my code.
In function 'void loop()':
warning: invalid conversion from 'double*' to 'uint8_t {aka unsigned char}' [-fpermissive]
dataFile.write(pressure);
^
C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:36:18: note: initializing argument 1 of 'virtual size_t SDLib::File::write(uint8_t)'
virtual size_t write(uint8_t);
^
I understand what it is saying but I can't figure out how to fix it. Any help would be greatful!
//import statements
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_MPL3115A2.h>
/* Temperature Sensor, Raw Numbers, Teensyduino Tutorial #4
http://www.pjrc.com/teensy/tutorial4.html
*/
//variable declarations
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
int seconds = 0;
int secondsPerTick = 0;
int counter = 0;
double pressure[20];
double heightA[20];
double temperature[20];
File dataFile;
//test to make sure program uploaded
void setup() {
Serial.begin(9600);
Serial.println("Adafruit_MPL3115A2 test!");
while (!Serial){
}
}
//makes sure sensors are working
void loop() {
if (! baro.begin()) {
Serial.println("Couldnt find sensor");
return;
}
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
dataFile =SD.open("sensor_recordings.txt", FILE_WRITE);
while (-1){
double altm = baro.getAltitude();
if (altm > 105){
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");
delay(250); // records data every quarter of a second
secondsPerTick++; //increments seconds per tick
if(secondsPerTick == 3){ //if its 3 reset "secondspertick" and increments "seconds"
secondsPerTick = 0;
seconds++;
}
counter++;
}
}
// data dump when rocket hits peak height
// if the file opened okay, write to it:
if (dataFile) {
Serial.print("sensor_recordings.txt");
dataFile.write("Pressure Recordings: ");
dataFile.write('\n');
dataFile.write(pressure);
Serial.print('\n');
dataFile.write("Height Recordings: ");
Serial.print('\n');
//dataFile.write(heightA);
Serial.print('\n');
dataFile.write("Temperature Recordings: ");
Serial.print('\n');
//dataFile.write(temperature);
Serial.print('\n');
// close the file:
dataFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening sensor_recordings.txt");
}
// re-open the file for reading:
dataFile = SD.open("sensor_recordings.txt");
if (dataFile) {
Serial.println("sensor_recordings.txt");
// read from the file until there's nothing else in it:
while (dataFile.available()) {
Serial.write(dataFile.read());
}
// close the file:
dataFile.close();
}
}
}