Hello, I am trying to get sensor reading data from a Prop shield that is attached to a Teensy 3.5 with a SD card in it. Below is my code my issue is that it is throwing errors about the conversion of data I have looked but I can't seem to find a way to actually convert the data into what it prefers so I can send the arrays to the SD card to be later viewed. Any help would be appreciated!
:
In function 'void loop()':
invalid conversion from 'double*' to 'uint8_t {aka unsigned char}' [-fpermissive]
dataFile.write(pressure);
^
SD.h:36:18: note: initializing argument 1 of 'virtual size_t SDLib::File::write(uint8_t)'
virtual size_t write(uint8_t);
^
//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();
}
}
}