Skip to content

Using the GPS TinyShield Tutorial

This tutorial will demonstrate how to use the GPS TinyShield with TinyCircuits processors.

If you would prefer to use a Flash Memory TinyShield to store NMEA GPS data, the GPS Tracker and Data Logger Project tutorial program offers the option to do so.

To learn more about the TinyDuino Platform, click here


Description

Use GPS positioning with your TinyDuino project! This TinyShield is based on the Telit JF2 GPS Module, which uses the popular SiRFstar IV chipset. This module is configured by default to output GPS strings in the NMEA format at a 1Hz update rate (this can be changed to 5HZ with an updated NMEA command).

This TinyShield includes an external passive GPS antenna on with a U.FL connector for great outdoor performance. This TinyShield also includes level shifters and a local power supply to ensure proper and safe operation over the entire TinyDuino operating voltage range up to 5V.

To see what other TinyShields are compatible with this TinyShield, see the TinyShield Compatibility Matrix

Technical Details Telit JF2 GPS Specs
  • Standards: NMEA and OSP
  • Update Rate: 1Hz (default), 5Hz settable
  • 48 Channel GPS architecture
  • Positional Accuracy < 2.5m
  • Accuracy Speed < 0.01m/s
  • Accuracy Heading < 0.01deg
  • Time to First Fix
    • Hot Start: 1 sec
    • Cold Start: < 35 sec
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V
  • Current:
    • 37mA (Full Power Tracking)
    • 10mA (Low Power Tracking, 1Hz)
    • 14uA (Hibernate Mode)
    • Due to the current requirements, this board cannot be run using the TinyDuino coin cell option
Pins Used
  • A0 - GPS_RX: Software UART Transmit from the TinyDuino to the GPS Module.
  • A1 - GPS_TX: Software UART Receive to the TinyDuino from the GPS Module.
  • A2 - SYS_ON: This signal is an output the GPS module to indicate if the module is in an active mode (the signal is a logic-high) or in hibernate mode (the signal is a logic-low). By Default this signal is connected between the GPS module and the A2 signal using R7, which is a 0 ohm resistor. This resistor can be removed if this signal is not needed to free up A2 for other uses.
  • A3 - ON_OFF: This signal is an input into the GPS module, and is used to transition between hibernate and active modes. Transitions between states are made with a low to high pulse on this signal (minimum time of 100uS).
Dimensions
  • 20mm x 20mm (.787 inches x .787 inches).
  • Max Height (from lower bottom TinyShield Connector to upper top TinyShield Connector): 5.11mm (0.201 inches)
  • Antenna: 10mm x 10mm x 7mm (.394 inches x .394 inches x .276 inches).  40mm (1.57 inches) cable with U.FL connector
  • Weight: Board: 1.65 grams (.06 ounces)  Antenna: 2.60 grams (0.09 ounces)

Notes

  • Previous versions (Rev 3 and earlier) of this board shipped with an integrated chip antenna and the board size was 20mm x 28mm. The integrated GPS antenna is not as sensitive as larger GPS antennas. This antenna will not pick up GPS signals indoors and will only work well outdoors. For best results, keep all metal away from the antenna and make sure it is used in an outdoor environment.  
  • Note: A number of the revision 5 TinyShields have modules configured to run at 4800 baud instead of 9600 baud. So if during testing the module does not seem to work at 9600, try it at 4800 baud.

Materials

Hardware materials

Hardware

Software


Hardware Assembly

Connect your GPS TinyShield to your processor board of choice (i.e. TinyZero) and then connect the stack of boards to your computer using a microUSB cable:

An assembled stack of a TinyZero and GPS TinyShield


Software Setup

With your stack of boards already connected, plug in the microUSB and upload the GPS Logger example program using the Arduino IDE and the correct Tools selections for your processor board:

Tools Selections using a TinyZero or TinyScreen+

The SoftwareSerialZero library is included in this .zip file for Arduino Zero based platforms like TinyScreen+.

This basic example shows how to receive and log or display NMEA strings from the GPS module. During startup, the code will try to initialize an optional microSD card in our standard SD TinyShield. If it fails, it will revert to displaying the NMEA strings. These strings can be viewed in the Serial Monitor with the baud rate set to 115200:

Example data output to Arduino IDE Serial Monitor

Code
/*
  TinyCircuits GPS TinyShield Logging Example

  This example logs GPS NMEA sentences to an SD card. If it doesn't detect an SD
  card at startup, it will output data to the Serial Monitor.
  With the Telit SE868 V2 module with Glonass support, some messages come through
  as GN** sentences instead of GP**. These are changed back to GP** before logging
  so that they don't cause problems with programs like Google Earth.

  If you see bad data:
  - Make sure the baud rate in the Serial Monitor is the same you see set in the below 
    program for the SerialMonitorInterface - 115200
  - Some GPS modules shipped before 2018 shipped with 4800 baud instead of 9600. Try changing 
    this value in the top of the GPS.h file.

  Written 10 July 2018 By Ben Rose
  Modified 07 January 2019 By Hunter Hykes
   - This update added SoftwareSerialZero files modified for SAMD21 based boards like
     the TinyScreen+, TinyZero or Arduino Zero.
  Modified May 2021 to clarify comments

  https://TinyCircuits.com
*/

#include "GPS.h"
#include <SD.h>

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#include <SoftwareSerial.h>
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#include "SoftwareSerialZero.h"
#endif

const int chipSelect = 10;
int cardPresent;

// The GPS connection is attached with a software serial port
SoftwareSerial softSerial(GPS_RXPin, GPS_TXPin);

#define Gps_serial softSerial

void setup()
{
  Gps_serial.begin(GPSBaud);
  SerialMonitorInterface.begin(115200);
  while (!SerialMonitorInterface && millis() < 5000); //On TinyScreen+, this will wait until the Serial Monitor is opened or until 5 seconds has passed

  gpsInitPins();
  delay(100);
  SerialMonitorInterface.print("Attempting to wake GPS module.. ");
  gpsOn();
  SerialMonitorInterface.println("done.");
  delay(200);

  //Enable and set interval or disable, per NMEA sentence type
  Gps_serial.print(gpsConfig(NMEA_GGA_SENTENCE, 1));
  Gps_serial.print(gpsConfig(NMEA_GLL_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GSA_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GSV_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_RMC_SENTENCE, 1));
  Gps_serial.print(gpsConfig(NMEA_VTG_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GNS_SENTENCE, 0));

  SerialMonitorInterface.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (SD.begin(chipSelect)) {
    SerialMonitorInterface.println("card initialized.");
    cardPresent = true;
  } else {
    SerialMonitorInterface.println("Card failed, or not present- continuing with serial output");
    cardPresent = false;
  }
}

void loop() {
  handleGPS();
}

char waitForCharacter() {
  while (!Gps_serial.available());
  return Gps_serial.read();
}

void handleGPS() {
  while (Gps_serial.read() != '$') {
    if(!Gps_serial.available()){
      return;
    }
  }
  int counter = 1;
  char c = 0;
  char buffer[100];
  buffer[0] = '$';
  c = waitForCharacter();
  while (c != '*') {
    buffer[counter++] = c;
    if(c=='$'){//new start
      counter=1;
    }
    c = waitForCharacter();
  }
  buffer[counter++] = c;
  buffer[counter++] = waitForCharacter();
  buffer[counter++] = waitForCharacter();
  buffer[counter++] = '\r';
  buffer[counter++] = '\n';
  buffer[counter] = '\0';

  buffer[1] = 'G';
  buffer[2] = 'P';

  gpsDoChecksum(buffer);

  if (cardPresent) {
    File dataFile = SD.open("gps.txt", FILE_WRITE);
    // if the file is available, write to it:
    if (dataFile) {
      dataFile.write(buffer, counter);
      dataFile.close();
    } else {
      SerialMonitorInterface.println("error opening gps.txt");
      cardPresent = false;
    }
  } else {
    SerialMonitorInterface.print((char *)buffer);
  }
}

Powering the System

The Telit JF2 module draws between 25mA – 50mA when operating (not in hibernation mode), so a coin cell battery is not sufficient to run this board- a lithium polymer battery or USB power source is required. The GPS TinyShield includes a local voltage regulator and level shifters, and can operate from 3 to 5 volts.

Using the GPS TinyShield

Upon power-up, the GPS is in hibernation mode. To wake up the module, a low-to-high pulse is needed on the ON-OFF pin of the module, which is connected to pin A3.

After waking, the module will start to send NMEA data once per second through the serial data interface attached to pins A0 and A1. This data can be logged directly or the time, date, location, speed, and altitude information can be interpreted and used within your software.

The system can also be put back into hibernation mode with a pulse on the ON-OFF pin (A3) again.

These necessary functions along with pin definitions and basic helper functions are provided in a GPS.h header file in each of our examples.

What's NMEA data?

NMEA stands for National Marine Electronics Association, this association was formed to create better communications with manufacturers. NMEA is now a standard data format supported by all GPS manufacturers. Read through this GPS website for a more in-depth description of what the NMEA data structure actually means, since at glance it looks like an alien language. There are many free options for plugging your collected NMEA data into some software so that it can create a map of the data collected, one of which is mentioned in the same GPS website.

Directly interpret GPS data?

If your application needs to interpret and use the GPS data directly, we've tested the previous example with the TinyGPS library and provided a modified version that works with our hardware here: GPS TinyShield TinyGPS library.


Downloads


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!