This example shows the different time for connecting to satellites using ephemeris.
File:
"WaspGPS_3_coldStartvsHotStart.pde"
/*
* ------Waspmote GPS Cold Start versus Hot Start Example--------
*
* Explanation: This example shows the different time for connecting to
* satellites using ephemeris.
*
* Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 0.1
* Design: David Gascón
* Implementation: Alberto Bielsa
*/
void setup(){
//setup for Serial port
USB.begin();
// setup the GPS module
USB.println("Setting up GPS...");
// Inits SD pins
SD.begin();
// Power SD up
SD.setMode(SD_ON);
// Turn GPS on
GPS.ON();
}
long time=0;
void loop(){
USB.println("Initializing SD Card");
USB.println(SD.init());
// GPS does not connect to sats yet
USB.print("GPS Time, Date: ");
USB.println(GPS.timeGPS);
USB.println(GPS.dateGPS);
time=millis();
// while GPS does not connect to sats, do nothing
while(!GPS.check());
time=millis()-time;
USB.print("Time elapsed without ephemeris: ");
USB.println(time,DEC);
// store ephemeris in "file_ephemeris.txt"
if(GPS.saveEphems()){
USB.println("Ephemeris stored succesfully");
GPS.OFF();
delay(15000);
USB.println("Turning GPS on");
GPS.ON();
time=millis();
if(GPS.loadEphems()) USB.println("Ephemeris loaded succesfully");
else USB.println("Ephemeris load failed");
while(!GPS.check());
time=millis()-time;
USB.print("Time elapsed with ephemeris: ");
USB.println(time,DEC);
}
else USB.println("Ephemeris save failed");
SD.close();
delay(5000);
}
You can download the code of this example.