Adafruit Ultimate GPS Breakout Board
Overview
Adafruit Ultimate GPS v3 Datasheet
Adafruit's "Ultimate GPS" is a relatively cheap ($40 as of 03/22/2014) GPS module with serial output, datalogging (64 kB flash), and external antenna (via uFL connector) capabilities. It accepts anywhere from 3.3-5V with a current draw of 20 mA, and has backup coin battery capability. The breadboard also includes pinouts for PPS (pulse per second), 3.3V regulated voltage output, and an enable pin.
Setup
mBed | Breakout Board |
p27 | TX |
p28 | RX |
VU | VIN |
GND | GND |
Setting up the GPS module is simple. Connect the TX and RX pins on the breadboard to any of the three serial pairs on the mBed. After wiring VIN (either 3.3V or 5V will suffice) and GND, you're done! If the device has power, a LED labelled "FIX" should begin blinking. This LED will blink once every second when it is unable to obtain a satellite fix or once every 15 seconds if it has one.
The FIX pin, much like its name implies, will go high when a satellite fix is obtained and remain low when it is not.
The PPS ("pulse per second") pin emits a 1 Hz square wave with 50% duty cycle, synced with the GPS's clock that may be useful in some timing applications.
The 3.3V pin offers a regulated output at 3.3V.
The VBAT pin is for use with an external backup battery, if so desired.
Working Example
A modified, mBed compatible version of Adafruit's GPS library can be found here. The conversion, among other things, removes certain distinctions made between hardware and software serial on the Arduino and also accounts for slight datatype discrepancies.
The following program closely follows this Adafruit example:
gps.cpp
//gps.cpp //for use with Adafruit Ultimate GPS //Reads in and parses GPS data #include "mbed.h" #include "MBed_Adafruit_GPS.h" Serial * gps_Serial; Serial pc (USBTX, USBRX); int main() { pc.baud(115200); //sets virtual COM serial communication to high rate; this is to allow more time to be spent on GPS retrieval gps_Serial = new Serial(p28,p27); //serial object for use w/ GPS Adafruit_GPS myGPS(gps_Serial); //object of Adafruit's GPS class char c; //when read via Adafruit_GPS::read(), the class returns single character stored here Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info? const int refresh_Time = 2000; //refresh time in ms myGPS.begin(9600); //sets baud rate for GPS communication; note this may be changed via Adafruit_GPS::sendCommand(char *) //a list of GPS commands is available at http://www.adafruit.com/datasheets/PMTK_A08.pdf myGPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); //these commands are defined in MBed_Adafruit_GPS.h; a link is provided there for command creation myGPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); myGPS.sendCommand(PGCMD_ANTENNA); pc.printf("Connection established at 115200 baud...\n"); wait(1); refresh_Timer.start(); //starts the clock on the timer while(true){ c = myGPS.read(); //queries the GPS if (c) { pc.printf("%c", c); } //this line will echo the GPS data if not paused //check if we recieved a new message from GPS, if so, attempt to parse it, if ( myGPS.newNMEAreceived() ) { if ( !myGPS.parse(myGPS.lastNMEA()) ) { continue; } } //check if enough time has passed to warrant printing GPS info to screen //note if refresh_Time is too low or pc.baud is too low, GPS data may be lost during printing if (refresh_Timer.read_ms() >= refresh_Time) { refresh_Timer.reset(); pc.printf("Time: %d:%d:%d.%u\n", myGPS.hour, myGPS.minute, myGPS.seconds, myGPS.milliseconds); pc.printf("Date: %d/%d/20%d\n", myGPS.day, myGPS.month, myGPS.year); pc.printf("Fix: %d\n", (int) myGPS.fix); pc.printf("Quality: %d\n", (int) myGPS.fixquality); if (myGPS.fix) { pc.printf("Location: %5.2f%c, %5.2f%c\n", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon); pc.printf("Speed: %5.2f knots\n", myGPS.speed); pc.printf("Angle: %5.2f\n", myGPS.angle); pc.printf("Altitude: %5.2f\n", myGPS.altitude); pc.printf("Satellites: %d\n", myGPS.satellites); } } } }
This will produce output similar to:
$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76 $GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A $GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70 $GPGSV,3,2,11,02,39,223,19,13,28,070,17,26,23,252,,04,14,186,14*79
This is the raw output from the GPS expressed in NMEA format. Note that for GPGSA, the first parameter seen is an "A." This indicated an "active" lock for the GPS. This will be a "V" (void) when no lock is obtained.
Troubleshooting
GPS Fix Times
The GPS may take an inordinately long time to acquire a fix, especially without an external antenna. While Adafruit implies a fix time of 30 seconds, it is not uncommon for it to require 10 to 15 minutes to acquire a signal with no external antenna. The inlaid ceramic antenna is very weak and requires direct line of sight to the sky. To decrease fix times, find an outdoors location, get to a higher elevation, or buy a better external antenna.
Important Member Functions
Adafruit_GPS::sendCommand(char *) | This is equivalent to directly sending contents of the string to the GPS via serial. |
Adafruit_GPS::read() | This member reads in the next character available from the GPS and stores it, as appropriate, into a string for later parsing as an full NMEA sentence. Note that it returns the character retrieved, making it useful for outputting raw GPS output. |
Adafruit_GPS::parse(char *) | This is the workhorse of the library; this will parse NMEA sentences and disseminate them into the appropriate member variables for ease of use. Note that this needn't accept newest NMEA sentences and may be easily modified to interpret NMEA sentences from other places, such as a logger. |
Adafruit_GPS::LOCUS_StartLogger(void) | This initiates the GPS's onboard 64 kB flash memory logger. Log frequency, among other things, may be changed by sending a serial command, and more information may be found on the Adafruit website. Note that while reading the logged data via mBed is possible (albeit slow), Adafruit's website has several software options available for this task. |
External
Adafruit has invested a considerable amount of effort in creating a reasonably comprehensive library and example set with an accompanying tutorial; both of which are tailored for the Arduino platform. Some interesting examples exist such as this reverse geocache box or Raspberry Pi adaptation.
1 comment on Adafruit Ultimate GPS Breakout Board:
Please log in to post comments.
Can you tell me where I can download the mbed.h and MBed_Adafruit_GPS.h files.
Thanks, Ed Naramor ednaramor@verizon.net 727-791-41547