Thanks! You fixed the problem with the altimeter - thanks!!
But here is some of the crazy output:
Code: Select all
09/08/14-19:53:23 77.59 Inches (Hg), 65501.88 meters, 25.25 C
09/08/14-19:53:31 77.59 Inches (Hg), 65501.69 meters, 25.31 C
09/08/14-19:53:38 77.59 Inches (Hg), 65501.88 meters, 25.25 C
09/08/14-19:53:46 77.59 Inches (Hg), 65501.94 meters, 25.25 C
09/08/14-19:53:53 77.59 Inches (Hg), 65502.25 meters, 25.25 C
09/08/14-19:54:00 77.59 Inches (Hg), 25434.38 meters, 25.25 C
09/08/14-19:54:08 77.59 Inches (Hg), 65502.13 meters, 25.25 C
09/08/14-19:54:16 77.59 Inches (Hg), 65501.94 meters, 25.25 C
09/08/14-19:54:24 77.59 Inches (Hg), 65501.88 meters, 25.25 C
09/08/14-19:54:31 77.59 Inches (Hg), 65501.75 meters, 25.25 C
09/08/14-19:54:38 77.59 Inches (Hg), 65501.69 meters, 25.25 C
09/08/14-19:54:46 77.59 Inches (Hg), 65501.94 meters, 25.25 C
09/08/14-19:54:54 30.13 Inches (Hg), 65501.88 meters, 25.25 C
09/08/14-19:55:02 77.59 Inches (Hg), 65502.00 meters, 25.25 C
09/08/14-19:55:09 77.59 Inches (Hg), 25433.88 meters, 25.25 C
09/08/14-19:55:16 77.59 Inches (Hg), 65501.94 meters, 25.25 C
09/08/14-19:55:24 77.59 Inches (Hg), 65502.19 meters, 25.25 C
09/08/14-19:55:31 77.59 Inches (Hg), 65502.19 meters, 25.25 C
09/08/14-19:55:39 77.59 Inches (Hg), 65502.06 meters, 25.25 C
09/08/14-19:55:46 77.59 Inches (Hg), 65502.13 meters, 25.25 C
09/08/14-19:55:53 77.59 Inches (Hg), 65502.19 meters, 25.25 C
09/08/14-19:55:59 77.59 Inches (Hg), 65502.13 meters, 25.25 C
09/08/14-19:56:06 77.59 Inches (Hg), 65501.56 meters, 25.25 C
Temp seems to be correct. The other two, at times, give wild results. Today its consistently wild as you can see. Any ideas? Code is below. Thanks in advance!
Code: Select all
#include <Console.h>
#include <Wire.h>
#include <Adafruit_MPL3115A2.h>
#include <FileIO.h>
// Power by connecting Vin to 3-5V, GND to GND
// Uses I2C - connect SCL to the SCL pin, SDA to SDA pin
// See the Wire tutorial for pinouts for each Arduino
// http://arduino.cc/en/reference/wire
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
void setup() {
Bridge.begin();
Console.begin();
Console.println("Adafruit_MPL3115A2 test!");
FileSystem.begin();
}
void loop() {
String dataString;
char altText[9];
if (! baro.begin()) {
Console.println("Couldnt find sensor");
return;
}
float pascals = baro.getPressure();
float alt=pascals/3377;
// Our weather page presents pressure in Inches (Hg)
// Use http://www.onlineconversion.com/pressure.htm for other units
Console.print(pascals/3377); Console.println(" Inches (Hg)");
float altm = baro.getAltitude();
Console.print(altm); Console.println(" meters");
float tempC = baro.getTemperature();
Console.print(tempC); Console.println("*C");
dataString= " Inches (Hg), ";
dataString += altm;
dataString += " meters, ";
dataString += tempC;
dataString += " C";
File dataFile = FileSystem.open("/mnt/sda1/datalog.txt", FILE_APPEND);
dataFile.print(getTimeStamp() + " ");
dataFile.print(pascals/3377);
dataFile.println(dataString);
dataFile.close();
delay(5000);
}
// This function return a string with the time stamp
String getTimeStamp() {
String result;
Process time;
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
time.begin("date");
time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy
// T for the time hh:mm:ss
time.run(); // run the command
// read the output of the command
while(time.available()>0) {
char c = time.read();
if(c != '\n')
result += c;
}
return result;
}