GPS 

Example

: Getting Coordinates

This example shows how to get the coordinates using Waspmote GPS module.


File:
"WaspGPS_1_gettingCoordinates.pde"


Code



/*
 *  ------Waspmote GPS Getting Coordinates Example--------
 *
 *  Explanation: This example shows how to get the coordinates using
 *  Waspmote GPS module.
 *
 *  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...");
  
  GPS.ON();
  
  // waiting for GPS is connected to satellites
  while( !GPS.check() ) delay(1000);
  
  USB.println("Connected");
 
}

void loop(){

  // Getting Time
  GPS.getPosition();  
  USB.println("---------------");
  USB.print("Time: ");
  USB.println(GPS.timeGPS);
  USB.print("Date: ");
  USB.println(GPS.dateGPS);
  USB.print("Latitude: ");
  USB.println(GPS.latitude);
  USB.print("Longitude: ");
  USB.println(GPS.longitude);
  USB.print("Altitude: ");
  USB.println(GPS.altitude);
  USB.print("Speed: ");
  USB.println(GPS.speed);
  USB.print("Course: ");
  USB.println(GPS.course);
  USB.println("---------------");

}
    

Download code

You can download the code of this example.


© 2009 Libelium Comunicaciones Distribuidas S.L.

| Terms of use