Step 1

Note: The GPS module only works on port C at the moment. Port C is the most isolated from RF noise from the MCU, and having Tessel doing a lot of processing will make getting a lock harder. The time between seeing satellites and actually getting a lock is dependent on the satellite. Be in view of the open sky for best results (and even then it may take a while to get a lock). Once the module has a lock, the lock should stay for a while.

Make a directory inside your "tessel-code" folder: enter mkdir gps into your command line, then change directory into that folder: cd gps

Step 2

Plug the GPS module into Tessel port C with the hexagon/icon side down and the electrical components on the top, then plug Tessel into your computer via USB.

Step 3

Install by typing npm install gps-a2235h into the command line.

Step 4

Save this code in a text file called gps.js:

// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

/**********************************************************
This gps example logs a stream of data:
coordinates, detected satellites, timestamps, and altitude.
For best results, try it while outdoors.
**********************************************************/

var tessel = require('tessel');
var gpsLib = require('gps-a2235h');

// GPS uses software UART, which is only available on Port C on Tessel 1
// we use Port C because it is most isolated from RF noise
// Port C doesn't exist on Tessel 2 so use Port A
var portToUse = 'C';

if (!tessel.port[portToUse]) {
  portToUse = 'A';
}

var gps = gpsLib.use(tessel.port[portToUse]);

// Wait until the module is connected
gps.on('ready', function () {
  console.log('GPS module powered and ready. Waiting for satellites...');
  // Emit coordinates when we get a coordinate fix
  gps.on('coordinates', function (coords) {
    console.log('Lat:', coords.lat, '\tLon:', coords.lon, '\tTimestamp:', coords.timestamp);
  });

  // Emit altitude when we get an altitude fix
  gps.on('altitude', function (alt) {
    console.log('Got an altitude of', alt.alt, 'meters (timestamp: ' + alt.timestamp + ')');
  });

  // Emitted when we have information about a fix on satellites
  gps.on('fix', function (data) {
    console.log(data.numSat, 'fixed.');
  });

  gps.on('dropped', function(){
    // we dropped the gps signal
    console.log("gps signal dropped");
  });
});

gps.on('error', function(err){
  console.log("got this error", err);
});

Step 5

In your command line, tessel run gps.js
Check out your location! If you're having trouble getting a location fix, try going outside; you probably don't have satellites indoors.

Bonus: Set up a geofence so that you are inside it. (Hint: you may need to check the documentation.)

To see what else you can do with the GPS module, see the module docs here.

Step 6

What else can you do with a GPS module? Try a community-created project.


What are you making? Share your invention!

If you run into any issues you can check out the GPS forums.

Choose another module

Or if you're all set, move on to Wifi.

Fork on Github