Error galore with Adafruit ultimate GPS

Decided to add the Adafruit ultimate GPS V3 to my HAB project. I'm using the code that comes with the board to add into my current sketch but i just cannot for the life of me get it to work when added. >:(

Constantly getting error after error, hoping someone can take a look at see where the hell i am going wrong. Using an Arduino Uno board.

#include <SD.h>
#include<SPI.h>
#include "Wire.h"
#include "Adafruit_MPL3115A2.h"
Adafruit_MPL3115A2 mySensor;
#include "RTClib.h"
#include <Adafruit_GPS.h>
RTC_DS1307 RTC;

SoftwareSerial mySerial(3, 2);

Adafruit_GPS GPS(&mySerial);

#define GPSECHO  false
boolean usingInterrupt = true;
void useInterrupt(boolean);
float tempC;
float pascals;
float altm;
float temp;
int tempPin = 0;

int chipSelect = 4;
File mySensorData;


Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();

void setup() {
  Serial.begin(9600);
  mySensor.begin();

  pinMode(10, OUTPUT);
  SD.begin(4);

  Serial.begin(9600);
  Wire.begin();

  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);


  useInterrupt(true);

  delay(1000);

}



SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;
#endif
}


void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else
    TIMSK0 &= ~_BV(OCIE0A);
  usingInterrupt = false;

}

uint32_t timer = millis();


Serial.begin(9600)
Wire.begin();
{
  RTC.begin();
  if (! RTC.isrunning())
    Serial.println("RTC is NOT running!");
  // following line sets the RTC to the date & time this sketch was compiled
  RTC.adjust(DateTime(__DATE__, __TIME__));
}


void loop() {
  if (! baro.begin())
    return;
  if (! usingInterrupt) {
    char c = GPS.read();
    if (GPSECHO)
      if (c) Serial.print(c);
  }
  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA()))
      return;
  }
  if (timer > millis())  timer = millis();

  if (millis() - timer > 2000) {
    timer = millis();

    Serial.print("\nTime: ");
    Serial.print(GPS.hour, DEC); Serial.print(':');
    Serial.print(GPS.minute, DEC); Serial.print(':');
    Serial.print(GPS.seconds, DEC); Serial.print('.');
    Serial.println(GPS.milliseconds);
    Serial.print("Date: ");
    Serial.print(GPS.day, DEC); Serial.print('/');
    Serial.print(GPS.month, DEC); Serial.print("/20");
    Serial.println(GPS.year, DEC);
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
    if (GPS.fix) {
      Serial.print("Location: ");
      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
      Serial.print(", ");
      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
      Serial.print("Location (in degrees, works with Google Maps): ");
      Serial.print(GPS.latitudeDegrees, 4);
      Serial.print(", ");
      Serial.println(GPS.longitudeDegrees, 4);

      Serial.print("Speed (knots): "); Serial.println(GPS.speed);
      Serial.print("Angle: "); Serial.println(GPS.angle);
      Serial.print("Altitude: "); Serial.println(GPS.altitude);
      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
    }
  }
}

mySensorData = SD.open("DataFile.txt", FILE_WRITE);

mySensorData.println();
Serial.println();

temp = analogRead(tempPin); temp = temp * 0.48828125;
Serial.print(temp); Serial.print("*C External");
mySensorData.print(temp); mySensorData.println("*C External"); Serial.println();

float pascals = baro.getPressure();
Serial.print(pascals / 3377); Serial.println(" Inches (Hg)"); mySensorData.print(pascals / 3377); mySensorData.println(" Inches (Hg) ");

float altm = baro.getAltitude();
Serial.print(altm); Serial.println(" Meters"); mySensorData.print(altm); mySensorData.println(" Meters ");

float tempC = baro.getTemperature();
Serial.print(tempC); Serial.println("*C Internal"); mySensorData.print(tempC); mySensorData.print("*C Internal");


DateTime now = RTC.now();
mySensorData.println();
Serial.print(now.day(), DEC); mySensorData.print(now.day(), DEC);
Serial.print('/'); mySensorData.print('/');
Serial.print(now.month(), DEC); mySensorData.print(now.month(), DEC);
Serial.print('/'); mySensorData.print('/');
Serial.print(now.year(), DEC); mySensorData.print(now.year(), DEC);
Serial.print(' '); mySensorData.print(' ');
Serial.print(now.hour(), DEC); mySensorData.print(now.hour(), DEC);
Serial.print(':'); mySensorData.print(':');
Serial.print(now.minute(), DEC); mySensorData.print(now.minute(), DEC);
Serial.println(); mySensorData.println();

mySensorData.println();


delay(2500);



mySensorData.close();

}

Please paste the first dozen or two error messages in code tags so we know what kind of errors you are getting.

This is just a few of the errors popping up.

Final_Code:80: error: 'Serial' does not name a type

Serial.begin(9600)

^

Final_Code:82: error: expected unqualified-id before '{' token

{

^

Final_Code:137: error: 'mySensorData' does not name a type

mySensorData = SD.open("DataFile.txt", FILE_WRITE);

^

Final_Code:139: error: 'mySensorData' does not name a type

mySensorData.println();

^

Final_Code:140: error: 'Serial' does not name a type

Put "Serial.begin(9600)" INSIDE a function, typically setup(), and put a semicolon at the end. Fix that and some of your other errors might go away.

Final_Code:137: error: 'mySensorData' does not name a type
mySensorData = SD.open("DataFile.txt", FILE_WRITE);

You should know now that the message might mean "This code is not inside a function like it should be. Only declarations go outside of functions and this is not a declaration!"

Thank you! I finally managed to clear the errors down to just one!

Now i am just getting: error: Final_Code:88: error: expected declaration before '}' token

}

^

exit status 1
expected declaration before '}' token

I know this has to be something so stupidly easy that i'll want to hit my head against a brick wall but just can't see where i've gone wrong. Have i added to many } or ;?

Serial.begin(9600)

Needs a semicolon.

Pete

The problem is actually worse than just a semicolon

Serial.begin(9600)
Wire.begin();
{
  RTC.begin();
  if (! RTC.isrunning())
    Serial.println("RTC is NOT running!");
  // following line sets the RTC to the date & time this sketch was compiled
  RTC.adjust(DateTime(__DATE__, __TIME__));
}

You have two executable statements outside a function and then a function with no declaration of its name, type etc.

Pete

I've changed the code around but still getting the same area.

void setup() {
  Serial.begin(9600);
  mySensor.begin();

  pinMode(10, OUTPUT);
  SD.begin(4);

  Serial.begin(9600);
  Wire.begin();

  Serial.begin(9600);
  Wire.begin();
      RTC.begin(); 
    if (! RTC.isrunning()) {
      Serial.println("RTC is NOT running!");
    RTC.adjust(DateTime(__DATE__, __TIME__));

    Serial.begin(115200);
    Serial.println("Adafruit GPS Live!");
    GPS.begin(9600);
    GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
    GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
    useInterrupt(true);

    delay(1000);

  }

}

SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;
#endif
}


void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else
    TIMSK0 &= ~_BV(OCIE0A);
  usingInterrupt = false;

}


uint32_t timer = millis();


}

Please tell me this is a simple fix and i'm over thinking it.

KernowHab:
I've changed the code around but still getting the same area.

What do you mean "getting the same area"?

aarg:
What do you mean "getting the same area"?

Sorry, i meant error.

void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else
    TIMSK0 &= ~_BV(OCIE0A);
  usingInterrupt = false;   ///// If you intended this to be in the 'else' clause you forgot a '{' after 'else'

}

//// Is this line supposed to be inside the "useInterrupt" function? 
//// If so, you put an extra '}' before it and closed the function early.


uint32_t timer = millis();

//// Because it is a declaration, it can exist outside any function

//// If you intended it to be outside any function (a global variable declaration) it 
//// should not have a '}' after it because '}' is not a declaration
//// and you can only have declarations outside of functions.
}

Now you know "does not name a type" and "expected declaration before" errors usually mean you have code outside a function, often caused by an extra '}'.

You may also want to remember that "a function-definition is not allowed here" error probably means you forgot a '}' and the compiler sees the next function declaration as being inside the function, where it is not allowed.

The "expected '}' at end of input" error is similar but where there are no other function declaration before the end of the sketch.

You need to go through this program line by line and make sure that you know what each line does and why.

You do NOT need three "Serial.begin()" with different Baud rates.