GPS – The Dexter Industries GPS is a GPS unit manufactured for use with the LEGO® MINDSTORMS® NXT. The sensor calculates positional and navigational data. It then delivers latitude, longitude, time, velocity, angle of travel, and navigational information such as distance and angle to a specified destination.

Getting Started


Connect the GPS unit to the NXT using any of the four sensor ports.

Two types of data are sent back and forth between the NXT:

Positional Data: The GPS sensor sends data on time (UTC), latitude, longitude, velocity (in cm/s), and heading (in degrees).

Navigational Data: The NXT may be programmed to send the latitude and longitude of a desired destination or waypoint to the GPS sensor.  The GPS sensor calculates the distance and angle of travel to the destination.  The sensor then sends the information back to the NXT.  For more accurate direction of travel data, the GPS can calculate an angle since last call.

Understanding the GPS Coordinate Systems: The Basics

Imagine the earth, divided by lines running north to south (longitude) and east to west (latitude).  One can describe any place on earth with a pair of latitude and longitude coordinates. The earth is also divided into North (the northern hemisphere, north of the equator) and South (the southern hemisphere, south of the equator) and East (the eastern hemisphere, east of the Prime Meridian) and West (the western hemisphere, west of the Prime Meridian).

These coordinates are traditionally divided into degrees, minutes, and seconds.
A position is typically described in the following format: 77°04’35.54” W
(seventy-seven degrees, four minutes, thirty-five point five four seconds West).

A thorough explanation of conversion between coordinate systems can be found here: http://en.wikipedia.org/wiki/Geographic_coordinate_conversion

Positional data from the Dexter Industries GPS is in integer decimal-degree
format.  Most mapping systems, like Google Maps, run on a format called
“decimal degrees,” where the output data looks like this:  dd.mmmmmm.

Because of NXT-G 1.0’s integer math limitations, the Dexter Industries GPS sensor sends and receives data in the format ddmmmmmm.  Therefore, data must be input into the GPS sensor in integer format (no decimals).

  • Latitude is represented by an 8-digit integer.  If the position is in the northern hemisphere, the number is positive.  If the position is in the southern hemisphere, the latitude is negative.
  • Longitude is represented by a 9-digit integer.  If the position is in the eastern hemisphere, the number is positive.  If the position is in the western hemisphere, the number is negative.

Understanding the GPS Coordinate Systems:
An Example with Google Maps

The NXT-G software is capable of communicating with the robot, telling where it is, how far it is from its destination, and what angle it must travel to.  For our example, we’ll select a destination for our robot—the Washington Monument in Washington, DC.

1. Using Google maps (maps.google.com), we’ll find the Washington
Monument.  Type Washington Monument in the search box.  Right-click on
the monument ‘s location and select What’s here? from the pull-down menu.
2. The latitude and longitude of the Washington Monument are now displayed in the search box at
the top of the page.  Latitude and longitude are displayed in decimal-degree format.

3. The latitude is 38.889463 and the longitude is -77.03536.  That makes sense because the Washington Monument is in the northern hemisphere (latitude is positive), and the western hemisphere (longitude is negative).


Starting the Hardware and Acquiring a Signal

The GPS unit connects to the NXT through any of the four sensor ports.

On startup, the GPS will begin searching for GPS satellites.  Depending on the location and the amount of horizon visible, the GPS may take up to a minute to find a satellite signal.  Acquisition time varies widely and depends on the view of the horizon, the time of day, and the number of satellites in view of your particular location.  For example, if starting in a position with no obstructions and a clear view of the entire horizon, the GPS can acquire a signal in as little as 30 seconds.  However, when part or all of the view is blocked, it may take the GPS longer to acquire a signal.  Before a signal is acquired, the GPS will begin sending the default location and time (121000000 E, 24000000 W) until a valid signal is locked by the sensor.

Starting the dGPS for the first time:

When starting the dGPS for the first time, it can take up to 10 minutes or more to acquire a satellite signal. On first startup, the dGPS acquires an almanac from the satellites.  This process can be sped up by taking the dGPS to an open space with as much of the horizon visible as possible (an open field, or the top of a building is ideal).  After the first startup satellite acquisition should be much faster, less than a minute, when in an open space.

The LED on the GPS unit indicates a valid GPS signal.  When a signal is acquired, the LED on the GPS sensor will turn solid.  If satellite signals are lost, the LED will turn off.  When a signal is lost, the GPS sensor will continue to transmit the location of the last valid signal.  The GPS clock will continue to operate and provide an accurate time.

After locking the initial signal, the GPS sensor can retain a valid signal with limited view of the horizon.  For example, in many cases, the GPS will continue to work inside a building or in a position with less view of the horizon.  Upon locking the initial signal, reacquiring a signal after it is lost can take less than one second.

When the sensor is disconnected or the power to the NXT is lost, the signal must be reacquired with maximum view of the horizon.

Software Setup

NXT-G:  GPS Read

The GPS Read Block can be used to read position, time,
velocity, and heading.

Positional information is read by the GPS and returned in integer format.

Latitude – Output is in integer/decimal degree format.  Positive indicates northern hemisphere.  Negative indicates southern hemisphere.

Longitude – Output is in integer/decimal degree format.  Positive indicates eastern hemisphere.  Negative indicates western hemisphere.

Universal Time – Output is an integer and reads hhmmss. (hour hour minute minute second second).

Heading – Integer format is a 0 to 360 degree heading of direction. Directly north is 0.  Directly east is 90.  Directly south is 180.  Directly
west is 270.

Velocity – Integer format in cm/s.

NXT-G:  GPS Navigation

The GPS Navigation Block can be used to navigate
to a user-defined destination.  The destination is
defined by latitude and longitude in integer format.
To get a decimal degree, one can use a program
such as Google Maps.  (For additional information on Google Maps, see the Using Dexter Industries GPS Sensor and Google Maps tutorial.)

Coordinates are entered as integers.

The GPS sensor calculates the distance to the
destination (in meters) and the angle to the destination
(in degrees).  The distance to destination and angle to
destination is returned in integer format.

NXT-G:  GPS Angle of Travel

The Angle of Travel is a function that reads the GPS position and calculates the angle traveled since the function was last called.  When used over distance, this function can serve as a more precise compass than the GPS output.
Calling the function intermittently over travel distances greater than 10 feet will give a more accurate compass reading.

The function works as follows:

1. When the function is first called, the GPS coordinates are stored in the GPS chip.  We will call the coordinates C1.
2. When the function is called a second time, the coordinates at that point are stored (we’ll call them C2) and the angle between C1 and C2 is returned through the Angle of Travel Port.
3. When the function is called a third time, the coordinates at that point are stored (C3), and the angle between C2 and C3 is returned through the Angle of Travel Port.

“Hello World”:  A Quick Start

The diagram below depicts a very basic NXT-G program using the Dexter Industries GPS Sensor.  The GPS Read Block is used to obtain the time, latitude, and longitude and to display these values on the screen.

I2C Communications

The NXT communicates with the Dexter Industries GPS sensor via I2C.  The NXT sends seven bytes of data to the GPS.  The first three bytes tell the GPS what type of data to send back to the NXT.  The last four bytes are reserved for latitude and longitude of a destination.

I2C communications are diagramed in the figure below.  A complete list of I2C calls are tabulated below.

I2C Communications Protocol for dGPS

I2C Register Table for dGPS for LEGO MINDSTORMS

dGPS-X Extended Firmware

If you received your dGPS from Dexter Industries after June 2012, you should have the dGPS-X software.  The extended firmware commands must be turned on before using them.  Turning on the extended firmware can slow down the dGPS sensor, but provides more detailed information such as altitude, HDOP, and satellites-in-view.

  • Turn On dGPS-X Extended Firmware: This is in register 13.  Send the integer “1” to turn the firmware on.  Send the integer “0” to turn the firmware off.  Reply Size is 3 for this command.
  • Altitude: This is in register 14.  Reply size is 4.  Altitude is measured in meters.
  • HDOP: This is in register 15.  Reply size is 4.  HDOP is a measure of the precision that can be expected at any given time by the dGPS.
  • Satellites in View: This is in register 16.  Reply size is 4.  This function will display the number of satellites in view.

Other Links and Examples:


What is the accuracy of the dGPS?

The dGPS uses a single commercial GPS receiver and can attain an accuracy of 3 meters.  This reading is highly dependent on the number of satellites in view, obstructions to the sky, and other error-causing phenomenon.

Because of geometrical complications, GPS receivers are less accurate in measuring altitude and measurements are frequently 10 meters or greater.

What is the Maximum Altitude of the dGPS?

The dGPS operates up to a maximum altitude of 18,000m  and a maximum velocity of 515m/s.


Got a question?  Ask on our forum!