2. Circuit & Operation
Most GPS modules automatically output NMEA messages at a certain rate, for example, once every second. They usually work independently without having to be setup or controlled. GPS library only tracks messages from the module when it needs to update data, otherwise, output messages will be ignored.
Therefore, your program is free to do other things while having GPS module connected. Any IO pin on Ansteron Board can be used to accept signal. There is no additional setup needed except one that GPS modules will take time to start up and its outputs are unusable for that period.
Typical connection between Ansteron Board and GPS module:
GPS modules usually send messages on TX pin at 4800bps (may vary depends on each module). Your program must change the baurate of SoftSerial before data can be retrieved. Below is an example:
This program will retrieve location data from GPS module and display on Serial Terminal. The numbers are raw data, latitude and longitude unit is in 1,000,000th of a degree. The descriptions for each value are below.
Update current data with data from GPS module. After this function is called, new data will be placed on memory and can be read at any time. Input pin is the IO where data signal of GPS module connected to, similar to other IO functions (
PIN_Dx). This function will poll for data and will not return until all necessary information is retrieved. The time this function takes will vary, depends on GPS module (up to 1 second for 1Hz modules).
Return position fix indicator of GPS data. If it is letter "0" then data is not valid. Other values indicate different modes but for any of those, location data is valid.
Return UTC time and date. They are
long values and the formats are hhmmss for time, ddmmyy for date. For example, 172302 time value represent 17:23:02, which is 05:23:02 PM. You may need to add or subtract offset from UTC time to get your local time.
Return location data. Longitude and Altitude are in 1,000,000th of a degree unit. For example, value 40,568,235 represents 40.568235 degree. Returned values have
long data type.
Return location data in Degree-Minute-Second format. They are
long values in the format ddmm.mmmm for latitude, dddmm.mmmm for longitude. For example, longitude value 56,352,653 represents 56:35.2653 (degree:minute).
Return North/South and East/West indicator. They are turn letter (
char) "N" or "S" and "E" or "W".
Return the altitude in foot and meter units respectively.
Return speed over ground in mile per hour (mph) or knot respectively.
Return the number of satellites currently in use.
Print GPS UTC time and date into
buffer as a string. The format for time is HH:MM:SS and date is MM/DD/YY. Buffer size is 9 bytes minimum.
Print GPS location data into
buffer as a string in real number format. For example, "23.235642,70.56365" or "40.253652,-82.351236". This function handles the sign of latitude and longitude according to NS and EW indicators. Buffer should be big enough to hold the result string (up to 22 bytes). Function returns the length of output string.
Print individually Latitude or Longitude to buffer. They are both in degree and +/- signs are automatically handled. These functions returns the length of output string.