GPS / GNSS — study guide

The concept's fragments, read in order.

For your capstone Fly a site and deliver a survey-grade map

On the mapping flight the satellite receiver does two jobs. It feeds the autopilot, whose position hold, mission and return-home modes will not engage without a usable fix, and it records where the aircraft was when each photo was taken.

Alone, those positions are meters out while the job needs centimeters, which is why satellite error and correction come later. Before takeoff, wait for a 3D fix, check that RMC reads A and not V, and watch the satellite count and the dilution figure, with the antenna clear of the propellers and facing the sky. Keep the height's label too: the position sentence measures it from a sea-level model, while survey work uses the height above the ellipsoid.

A receiver that only listens

A satellite navigation receiver never transmits anything. It listens to radio signals from satellites about 20,200 km (12,550 miles) up, each one announcing where that satellite is and what time it is, and from those signals it works out two things: where its antenna is, and what time it is. The general name for these systems is GNSS, global navigation satellite system. GPS is one of them, the United States' system, run by the U.S. Space Force.

It is not the only one. Russia runs GLONASS, the European Union runs Galileo and China runs BeiDou, all of them global, while Japan's QZSS and India's NavIC cover their own regions. A part sold as a GPS module may track more than one of these systems at once, and the text it sends says which. On this page GPS means the US system and GNSS means the family.

On a robot the receiver is usually a small serial GNSS module: an antenna, a receiver chip and a UART that streams its results as lines of text, normally once a second. Wiring it is a UART job like any other. Reading it means knowing what those lines say, how long the module needs after power-up before it says anything useful, and what its antenna needs to see.

The answer it gives is good to a few meters under open sky. GPS.gov puts a phone's receiver typically within 4.9 m (16 ft) under open sky, and worse near buildings, bridges and trees; that is the US government's figure for its own system. Why it is meters and not centimeters, and how surveyors close that gap, are subjects of their own; this page is about getting the meters at all.

Ranges, plus one clock nobody trusts

sat 1 sat 2 sat 3 range = travel time x speed of light dashed ranges cross in three places, not one one point: the position measured: clock 100 ns fast, every range 30 m too long same ranges minus one shared offset: they meet not to scale; the offset found is the clock error, so the time too
Every measured range is too long by the same clock error, so the ranges fail to meet at one point; subtracting one common clock offset from all of them makes them meet at a single point, which is the position, and the offset found is the receiver clock error, which gives the time.

Every satellite carries atomic clocks and broadcasts a signal stamped with the moment it left, along with data that describes the satellite's orbit, so the receiver can work out where the satellite was at that moment. The receiver notes when the signal arrives. The travel time multiplied by the speed of light, about 30 cm per nanosecond, is the distance to that satellite, a range. From straight overhead the trip takes about a fifteenth of a second.

One range puts the receiver somewhere on a sphere around one satellite. Three spheres cross at two points, one of which is usually far out in space or moving impossibly fast, so three good ranges would settle a position. They are not good, because the receiver's clock is a cheap crystal, not an atomic clock. If it runs 100 nanoseconds fast, every travel time reads 100 nanoseconds long and every range comes out about 30 m too long, all by the same amount, like timing runners from a starting gun with a stopwatch that was started a moment late, so every time comes out wrong by the same amount and one correction fixes them all. Ranges carrying that shared error are called pseudoranges, and stretched spheres no longer pass through one common point.

The receiver's way out is to treat its own clock error as a fourth unknown beside the three coordinates. Four unknowns need four measurements, which is why a fix needs at least four satellites. The receiver adjusts its guess of position and clock offset together until all the ranges agree on one point, and modern receivers use every extra satellite they can track to make that agreement sturdier.

The clock offset is not thrown away. Once it is solved, the receiver's time is tied to the satellites' atomic clocks, and GPS.gov says a receiver can determine time to within 100 billionths of a second this way. That is why a GNSS receiver is also one of the best clocks a small robot can carry, and why some modules bring the time out on a pin of its own.

What a module tells the board

satellite signals, from above patch antenna, facing the sky GNSS module board controller power power GND GND shared ground TX RX text sentences, about once a second RX TX settings, only when changing them PPS GPIO one edge at the start of each second both ends of the link set to the same baud, such as 9600
A serial GNSS module turns satellite signals caught by its upward-facing antenna into lines of text sent from its TX pin to the board's RX pin at an agreed baud rate, about once a second, while an optional PPS pin sends one timing edge per second to a GPIO input; power and ground are shared and the board's TX is used only for configuration.

A GNSS module reports more than a position. Each update carries latitude and longitude, a height, the time and date in UTC (Coordinated Universal Time), the speed over the ground and the direction of travel, called course. Alongside them it reports how good the fix is: whether it has one at all, whether it is a 2D fix (latitude and longitude without a trustworthy height) or a full 3D fix, how many satellites went into it, and a dilution of precision (DOP) figure. The receiver works out the DOP from where its satellites sit in the sky; smaller is better, and what it measures belongs to the study of satellite error. The same report also has codes for fixes improved with correction data from elsewhere, which a module working alone does not produce.

Most modules send an update once a second unless told otherwise. Some can be set to run several times faster, and one open-source autopilot asks for five fixes a second by default. Each fix describes where the antenna was at one instant and reaches the board a little after it. Between fixes the board learns nothing new about position, which matters at speed: the GPSD project's documentation works the example of 50 km/h (31 mph), where once a second means about 14 m between updates.

The wiring is a UART connection plus power. The module's TX goes to the board's RX and carries the reports as text; the board's TX to the module's RX is needed only to send configuration, such as a new rate. Some modules also bring out a pulse-per-second (PPS) pin, whose edge marks the start of each second far more precisely than a line of text arriving over a serial link can. A text report says which second it was; the pulse says exactly when it began.

Two numbers deserve suspicion before they reach a map. The latitude and longitude are in a global datum (for GPS, WGS 84), not necessarily the one a local map or a survey uses. And the height is not necessarily an elevation: a module's position sentence measures it from a sea-level model the receiver rarely documents, with the gap to the WGS 84 ellipsoid in a separate field, while survey equipment and correction software work from the height above the ellipsoid itself. Each of those has its own concept; for now, treat them as labels to keep, not details to ignore.

Sentences on a serial line

$GNGGA,142305.00,4530.600,N,12205.400,W, 1,09,1.1,821.4,M,-21.5,M,,*48 $ start of sentence GN talker ID: more than one system GGA sentence type: fix data 142305.00 time of fix, 14:23:05.00 UTC 4530.600,N latitude: 45 degrees 30.600 minutes N 12205.400,W longitude: 122 degrees 05.400 minutes W 1 fix quality: 1, an ordinary fix 09 satellites in use 1.1 horizontal dilution of precision 821.4,M altitude above mean sea level, m -21.5,M geoid separation, m ,, two empty fields: no correction data *48 asterisk, then the checksum in hex CR LF end of line (71 characters in all) XOR of every character in here
An NMEA GGA sentence is a dollar sign, a talker ID and sentence type, comma-separated fields for time, position, fix quality, satellites, dilution and heights, then an asterisk and a two-digit hexadecimal checksum that is the XOR of every character between the dollar sign and the asterisk, then a line ending.

Most modules speak NMEA 0183, a format that began in marine electronics, where one instrument talks and many others listen, all in printable ASCII text. The National Marine Electronics Association sells the standard itself, so builders work from open descriptions of it, such as the one the GPSD project maintains. On the wire it is refreshingly plain: each report is one line of text, called a sentence.

Every sentence has the same frame. It starts with a dollar sign. Then comes a five-letter tag: a two-letter talker ID saying which system produced it (GP for GPS alone, GL for GLONASS, GA for Galileo, GB or BD for BeiDou, GN for a combination) and a three-letter type such as GGA or RMC. Comma-separated fields follow, then an asterisk, a two-character checksum, and a carriage return and line feed. The whole line, dollar sign and line ending included, is at most 82 characters. A field with no valid data is meant to be left empty, two commas side by side, although many receivers fill in zeros instead.

The checksum is the cheapest possible check. Take every character between the dollar sign and the asterisk, combine them with exclusive-or (XOR) one after another, and write the 8-bit result as two hexadecimal digits. The listener repeats the arithmetic and compares. A UART frame carries at most a parity bit, so this is what catches a character damaged in transit. It cannot repair anything, and does not need to: drop the sentence and use the next one, a second later.

The standard specifies 4800 baud. Modules vary, and 9600 is probably the most common setting today. At 8-N-1, ten bit periods per character, 9600 baud moves 960 characters a second, so one full-length sentence takes under a tenth of a second and a module's usual handful of sentences fits easily into each second. At 4800 a full set of reports can take most of a second, which is why asking a module for more fixes a second usually means asking for a faster baud as well, on both ends of the link.

Reading GGA and RMC

the latitude field as the module sends it 45 30.600 ,N degrees minutes divide by 60 0.5100 add right: 45.5100 degrees north wrong: divide the whole field by 100 45.3060 degrees the same two answers on the ground, north up 45.5100: where the module is 45.3060: where the bad parser puts it 0.204 degrees of latitude, about 23 km (14 miles)
An NMEA latitude field such as 4530.600 is whole degrees followed by minutes, so it is 45 plus 30.600 divided by 60, which is 45.51 degrees; reading it as 45.306 degrees puts the point 0.204 degrees of latitude, about 23 km, too far south.

Two sentence types carry almost everything a builder needs. GGA is the fix data: the UTC time of the fix, latitude with N or S, longitude with E or W, a fix-quality digit, the number of satellites in use, the horizontal dilution of precision, the altitude above mean sea level in meters, as the receiver's own geoid model puts it, and that model's separation between sea level and the WGS 84 ellipsoid, so adding the two gives the height above the ellipsoid. A quality digit of 0 means no fix, and everything else on the line is then meaningless; 1 is an ordinary fix from the satellites alone. The satellite count and the dilution figure make a quick health check: few satellites and a large dilution mean a weak fix.

RMC, the recommended minimum, carries the UTC time, a status letter, the position, the speed over the ground in knots, the course in degrees from true north, and the date as day, month and year (231126 is November 23, 2026). The status letter is A for valid and V for a warning, which the receiver sets when its fix falls below its own quality threshold. Speed in knots trips people up: a knot is 1852 m an hour, so 8 m/s arrives as about 15.6. Course is the direction the antenna is moving, not the way the robot faces, and it means little when the robot is barely moving.

Positions are the classic trap. A latitude of 4530.600 is not 4530.6 of anything, and not 45.306 degrees either. The two digits just left of the decimal point are whole minutes, everything before them is whole degrees, so it reads 45 degrees and 30.600 minutes, which is 45 plus 30.6 divided by 60, or 45.51 degrees. Treat it as 45.306 and the point lands about 23 km away. Longitude works the same way with three digits of degrees (12205.400 is 122 degrees 5.4 minutes), and the letters carry the sign: south and west are negative in most software.

A parser that survives the field checks the checksum first, then the status or quality, then reads the numbers, and it treats an empty field as "no data" rather than zero. Without a fix a module still sends sentences on schedule, with empty fields or zeros where the position belongs, and a zero latitude and longitude is a real place in the Gulf of Guinea, not a warning.

Cold, warm and hot starts

Power a receiver up and it says nothing useful for a while. The wait is called time to first fix, and its length depends on what the receiver still remembers. To compute a position it needs, for at least four satellites, the ephemeris: each satellite's own precise orbit and clock correction, broadcast by that satellite. To find satellites quickly in the first place it helps to know roughly the time, roughly where it is, and the almanac, a coarse description of every satellite's orbit, good to a kilometer or two.

GPS sends all of this very slowly, at 50 bits per second. The clock and ephemeris data fill the first three six-second pieces of a 30-second frame and repeat every frame, so a receiver that has just locked onto a satellite still has to listen for at least 18 seconds, and about half a minute on average, before it can use that satellite. The almanac is spread across 25 frames and takes 12.5 minutes to come round in full, like a station announcer reading the whole timetable aloud on a loop, where someone who just walked in must wait for the part they need to come round again, while someone holding yesterday's printed copy can leave at once. Ephemeris also goes stale: under normal operations each set is broadcast for two hours and fitted to a four-hour stretch of orbit.

Hence three kinds of start. A cold start knows nothing and searches the whole sky. A warm start has an almanac, the approximate time and position, and needs only fresh ephemeris. A hot start still holds valid ephemeris and fixes almost at once. The GPSD project's documentation puts a warm start on a modern receiver with a good view of the sky at about 30 seconds, and warns that a first start, or one after weeks without power, can take far longer. One common module's datasheet lists under half a minute for a cold start and about a second to reacquire. Makers measure these times in different ways, so treat any single figure as a best case under open sky.

The practical lessons are short. Some modules keep their memory and clock alive between power-ups with a small backup battery, and one without it cold-starts every time. A first start goes fastest outdoors with the antenna facing the sky and the module left alone. Even the time can be off at first: GPS keeps its own time scale without leap seconds, the correction to UTC rides in the slow part of the message, and a freshly started receiver can report UTC wrong by some seconds until it arrives.

The antenna needs the sky

The signals arrive astonishingly weak. The GPS interface specification guarantees a minimum of about -158.5 dBW for the main civil signal at an antenna near the ground, roughly a ten-millionth of a billionth of a watt, which is weaker than the background radio noise in the same band. A receiver digs each satellite out of that noise by matching it against the satellite's known code, which works remarkably well. What it cannot do is hear through things.

The signals travel in straight lines from satellites spread across the sky, and solid material in the way weakens or blocks them. GPS.gov lists blockage by buildings, bridges and trees, and use indoors or underground, among the common causes of a bad position. A sensitive module may still manage a fix indoors, especially near a window, but the position suffers, and deep inside a building or underground there may be no fix at all. Beside a tall building half the sky is gone, like looking up from the bottom of a narrow courtyard, where only a strip of sky shows and everything you can see is crowded into it. The satellites left are bunched on one side, and signals bounced off the walls add errors of their own.

The antenna on a small module is often a flat square patch on its top face, and it wants the whole sky above it. One open-source autopilot's documentation puts the rules plainly: antenna side up, a clear view of the sky, not under spinning propellers, and as far as possible from radio transmitters, motors and motor controllers. On a small robot car that means on top, clear of a metal or carbon-fiber body shell, and away from the board's own noisy electronics rather than tucked in beside them.

A failing view shows up in the output before the position visibly fails, if anything is watching. The satellite count falls, the dilution figure climbs, the fix drops from 3D to 2D to none, the RMC status turns to V, and the reported position starts to wander while the robot sits still. Code that reads those fields, and not only the latitude and longitude, knows when to stop trusting the fix.

Where the fix goes on a car and on a drone

On a small self-driving car, a serial GNSS module on one of the board's UARTs gives a fix about once a second, outdoors, good to a few meters. That is enough to know which end of a field the car is in, to measure how far it is from a goal, and, while it is moving, to know its direction of travel. It is not enough to keep a car on a path a meter wide. The fix is coarse next to the car and slow next to its steering. It is poor under trees, missing indoors, and, after a cold power-up, absent for the first half minute or more. Combining it with the car's other sensors into one estimate of position is a later concept's job; this one makes sure the numbers going in are read correctly.

On a survey drone the same kind of receiver sits on top of the aircraft, clear of the propellers. It feeds the autopilot, whose position-holding, mission and return-home modes will not engage without a usable fix, and one open-source autopilot asks it for five fixes a second. It also records where the aircraft was when each photo was taken. Left uncorrected those positions are meters out, while a map meant to support grading and stockpile volumes needs centimeters, which is why the drone path goes on to the sources of satellite error and then to correction. The receiver is where all of that starts.

Both builds want the same habits from the person wiring them. Check the checksum, the status and the fix quality before believing a number. Watch the satellite count and the dilution figure, and wait for a 3D fix before driving off or taking off. Give the antenna the sky. And remember that a position printed to seven decimal places is still a few meters wide.

Sources

The published studies, standards and guidance this page cites. Links open on other sites.

  1. Space Segment (GPS.gov) www.gps.gov
  2. Other Global Navigation Satellite Systems (GNSS) (GPS.gov) www.gps.gov
  3. GPS Accuracy (GPS.gov) www.gps.gov
  4. GPS and Telling Time (GPS.gov) www.gps.gov
  5. Complete Parameter List (ArduPilot Copter documentation) ardupilot.org
  6. Hacker's Guide to GPSD (GPSD project documentation) gpsd.gitlab.io
  7. NMEA 0183 (National Marine Electronics Association) www.nmea.org
  8. NMEA Revealed, Eric S. Raymond (GPSD project documentation) gpsd.gitlab.io
  9. IS-GPS-200N, NAVSTAR GPS Space Segment/Navigation User Segment Interfaces (U.S. Space Force Space Systems Command, 2022) www.gps.gov
  10. GPSD FAQ (GPSD project documentation) gpsd.gitlab.io
  11. TTFF (Navipedia, European Space Agency, 2012) gssc.esa.int
  12. Archived: GPS Module (External) (ArduPilot Copter documentation) ardupilot.org

Next on your path to Fly a site and deliver a survey-grade map: