1 /***********************************
2 This is the Adafruit GPS library - the ultimate GPS library
3 for the ultimate GPS module!
5 Tested and works great with the Adafruit Ultimate GPS module
7 ------> http://www.adafruit.com/products/746
8 Pick one up today at the Adafruit electronics shop
9 and help support open source hardware & software! -ada
11 Adafruit invests time and resources providing this open source code,
12 please support Adafruit and open-source hardware by purchasing
13 products from Adafruit!
15 Written by Limor Fried/Ladyada for Adafruit Industries.
16 BSD license, check license.txt for more information
17 All text above must be included in any redistribution
18 ****************************************/
20 #ifndef _ADAFRUIT_GPS_H
21 #define _ADAFRUIT_GPS_H
24 #include <SoftwareSerial.h>
26 #include <NewSoftSerial.h>
29 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
30 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
31 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
32 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
35 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
36 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
38 // turn on only the second sentence (GPRMC)
39 #define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
40 // turn on GPRMC and GGA
41 #define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
42 // turn on ALL THE DATA
43 #define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
45 #define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
47 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
48 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
50 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
51 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
52 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
53 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
54 #define LOCUS_OVERLAP 0
55 #define LOCUS_FULLSTOP 1
57 // standby command & boot successful message
58 #define PMTK_STANDBY "$PMTK161,0*28"
59 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*3" // Not needed currently
60 #define PMTK_AWAKE "$PMTK010,002*2D"
62 // ask for the release and version
63 #define PMTK_Q_RELEASE "$PMTK605*31"
65 // request for updates on antenna status
66 #define PGCMD_ANTENNA "$PGCMD,33,1*6C"
67 #define PGCMD_NOANTENNA "$PGCMD,33,0*6C"
69 // how long to wait when we're looking for a response
70 #define MAXWAITSENTENCE 5
74 #if !defined(__AVR_ATmega32U4__)
75 #include "SoftwareSerial.h"
79 #include "NewSoftSerial.h"
85 void begin(uint16_t baud);
88 Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
90 Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial
92 Adafruit_GPS(HardwareSerial *ser); // Constructor when using HardwareSerial
95 boolean newNMEAreceived();
96 void common_init(void);
97 void sendCommand(char *);
98 void pause(boolean b);
100 boolean parseNMEA(char *response);
101 uint8_t parseHex(char c);
104 boolean parse(char *);
105 void interruptReads(boolean r);
107 boolean wakeup(void);
108 boolean standby(void);
110 uint8_t hour, minute, seconds, year, month, day;
111 uint16_t milliseconds;
112 float latitude, longitude, geoidheight, altitude;
113 float speed, angle, magvariation, HDOP;
116 uint8_t fixquality, satellites;
118 boolean waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE);
119 boolean LOCUS_StartLogger(void);
120 boolean LOCUS_ReadStatus(void);
122 uint16_t LOCUS_serial, LOCUS_records;
123 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
127 uint8_t parseResponse(char *response);
129 SoftwareSerial *gpsSwSerial;
131 NewSoftSerial *gpsSwSerial;
133 HardwareSerial *gpsHwSerial;