Getting information

The principal purpose of a GPS is to get location, time, date and movement information of the device in which it is plugged.

Getting time

This function gets the current time on the GPS.

The format of the time is a string like "175625.000" -- hhmmss.sss. For example: to store the time 13:30:00, it is stored this way: "133000.000".

The time given by the GPS module is stored in the timeGPS variable and it is also returned.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* time;
    time=GPS.getTime(); // Get time given by GPS module
}

Related variables:

GPS.timeGPS → stores time given by the GPS module

Getting date

This function gets the current date on the GPS.

The format for the time is a string like "220813" -- ddmmyy. For example: to store the date 23rd of March 1994, it is stored this way: "230394".

The date given by the GPS module is stored in the dateGPS variable and it is also returned.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* date;
    date=GPS.getDate(); // Get date given by GPS module
}

Related variables:

GPS.dateGPS → stores date given by the GPS module

Getting longitude

It gets the longitude from the GPS and returns it.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* longitude;
    longitude=GPS.getLongitude(); // Get longitude from GPS
}

Related variables:

GPS.longitude → stores longitude given by the GPS module

GPS.EW_indicator → stores \'E\' for Eastern longitudes and \'W\' for Western longitudes

Longitude is measured in longitude and degrees. For example, "01131.0000" could be the value stored by the GPS.longitude variable, and it means: longitude 11, degrees 31, 0000 minutes.

Converting to degrees

There is a useful function to convert the longitude given by the GPS module to degrees. This function is called convert2Degrees() and returns the longitude represented as a float. Range: 180 to -180.

Example of use:

{
    float longitude;
    longitude = GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator);
}

Getting latitude

It gets the latitude from the GPS and returns it.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* latitude;
    latitude=GPS.getLatitude(); // Get latitude from GPS
}

Related variables:

GPS.latitude → stores latitude given by the GPS module

GPS.NS_indicator → stores \'N\' for Northern latitudes and \'S\' for Southern latitudes

Latitude is measured in latitude and degrees. For example, "4807.0380" could be the value stored by the GPS.latitude variable, and it means: latitude 48, degrees 07, 0380 minutes.

Converting to degrees

There is a useful function to convert the latitude given by the GPS module to degrees. This function is called convert2Degrees() and returns the latitude represented as a float. Range: 90 to -90.

Example of use:

{
    float latitude;
    latitude = GPS.convert2Degrees(GPS.latitude , GPS.NS_indicator);
}

Getting altitude

It gets the altitude in units of meters from the GPS and returns it.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* altitude;
    altitude=GPS.getAltitude(); // Get altitude from GPS
}

Related variables:

GPS.altitude → stores altitude given by the GPS module in units of meters

As the variable stores the result of an NMEA sentence, the value follows the format according to this standard: Altitude is measured in meters. GPS.altitude stores the altitude in meters inside a string.

Getting speed

It gets the speed from the GPS and returns it.

It stores the final value in the variable speed as a string, using units of km/h.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* speed;
    speed=GPS.getSpeed(); // Get speed and course from GPS
}

Related variables:

GPS.speed → stores speed given by the GPS module

Getting the course

It gets the course from the GPS and returns it.

It stores the final value in the variable course as a string, using units of degrees.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    char* course;
    course=GPS.getCourse(); // Get course and course from GPS
}

Related variables:

course → stores course over ground given by the GPS module

Getting position

It gets latitude, longitude, altitude, speed, course, time and date from the GPS.

It makes a call to the GPGGA and GPRMC sentences to extract the data from the GPS.

It stores the final values in the variables latitude, longitude, altitude, speed, course, timeGPS and dateGPS as strings.

If this function returns 0, it means that the variable has not been updated due to the information was not available from GPS.

Example of use:

{
    GPS.getPosition(); // Get all the coordinates from the GPS
}

Related variables:

GPS.latitude → stores latitude given by GPS module

GPS.longitude → stores longitude given by GPS module

GPS.altitude → stores altitude given by GPS module

GPS.speed → stores speed given by GPS module

GPS.course → stores course given by GPS module

GPS.timeGPS → stores time given by GPS module

GPS.dateGPS → stores date given by GPS module

Getting GPS data example:

http://www.development.libelium.com/gps-01-getting-basic-data

Complete GPS example:

http://www.development.libelium.com/gps-04-complete-example

Send GPS data via XBee module example:

http://www.development.libelium.com/gps-05-send-gps-xbeedm

GPS tracker using Waspmote:

http://www.development.libelium.com/gps-06-waspmote-tracker

Setting RTC time and date from the GPS

It sets Time and Date to the RTC, getting the data from the GPS.

Inside this function, Time and Date are obtained from the GPS module.

It returns nothing and modifies no flag.

Example of use:

{
    GPS.setTimeFromGPS(); // Sets time and date to the RTC from the GPS
}

Related variables:

year, month, day, hour, minute, second → stores the time and date set

Setting RTC time from GPS example:

http://www.development.libelium.com/gps-07-setting-time-from-gps

Setting RTC time and date from the GPS

Besides than the described variables and functions, there are other variables, less relevant, which are also stored in RAM memory. These variables are:

GPS.signalStatus→ status field of RMC sentence

GPS.satellites→ satellites used in the GGA sentence

GPS.accuracy→ Horizontal dilution of precision in GGA sentence

GPS.GSAMode1→ Mode 1 field of GSA sentence

GPS.GSAMode2→ Mode 2 field of GSA sentence

GPS.PDOPAccuracy→ Position dilution of precision in GSA sentence

GPS.HDOPAccuracy→ Horizontal dilution of precision in GSA sentence

GPS.VDOPAccuracy Vertical dilution of precision in GSA sentence

GPS.satellitesInView→ satellites in view field of GSV sentence

Last updated