Hi!
I am new to arduino programming so please forgive me if this question is stupid. I am trying to store GPS altitude data along with the data from an ultrasonic sensor. I can program the sensor without issue so I didn't include that into the code. My problem is that it outputs 0 : 0.00 : 0 when it should say something like 0 : 180.7 : 57. I just have seconds in there because I need to have a real time clock as well. I deleted a bunch of GPS things from the example that I didn't think were necessary in order to fit under the memory limit of the Uno.
Code:
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <NewPing.h>
SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);
#define GPSECHO true
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
int total;
int pin;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
const int chipSelect = 10;
void setup()
{Serial.begin(115200);
Serial.println("Adafruit GPS library basic test!");GPS.begin(9600);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
GPS.sendCommand(PGCMD_ANTENNA);
pinMode(10, OUTPUT);
SD.begin(chipSelect);
delay(1000);
mySerial.println(PMTK_Q_RELEASE);
}SIGNAL(TIMER0_COMPA_vect) {
char c = GPS.read();
}void loop()
{
char c = GPS.read();
File dataFile = SD.open("datalog.txt", FILE_WRITE);
dataFile.print(total);
dataFile.print(" : ");
dataFile.print(GPS.altitude);
dataFile.print(" : ");
dataFile.println(GPS.seconds, DEC);
/dataFile.print(now.hour());
dataFile.print(".");
dataFile.print(now.minute());
dataFile.print(".");
dataFile.println(now.second());/
dataFile.close();}
Any help would be greatly appreciated!