User Tools

Site Tools


digispark:tutorials:gps

This is an old revision of the document!


Pro GPS Shield Kit Tutorial

Product Description:

gps1.jpg gps6.jpg

This is an unassembled kit and requires basic soldering. This is designed for use with the Digispark development board, which is not included.

Parts:

Part Quantity Identification
Pro Combo PCB1
Serial GPS Module 1
1x40pin male 0.1“ pitch header 25 pins worth

Resistor Values: For more information on how to identify the value of the resistors we recommend these sites: A nice simple resistor calculator: http://www.ealnet.com/m-eal/resistor/resistor.htm A comprehensive article on identification: http://www.diyaudioandvideo.com/Electronics/Color/

Soldering: If you are new to soldering we recommend the following tutorials: Soldering Basics (http://www.sparkfun.com/tutorials/106) and Soldering Crash Course from the folks at Sparkfun (http://www.sparkfun.com/tutorials/354). How to solder from the Curious Inventor: http://store.curiousinventor.com/guides/How_to_Solder

Adafruit has this excellent guide that starts with the tools needed and then shows detailed pictures, including some of the common problems that beginners experience (http://learn.adafruit.com/adafruit-guide-excellent-soldering)

We assume for these assembly instructions that you know the basics of thru-hole soldering. If you don't check out the links above, these boards are very easy to solder - we promise!

Assembly:

gps1.jpg

Insert a strip of 4 header pins into the top of the board in the four holes labeled for the GPS module. Solder on the bottom of the board.

gps2.jpg

Cut two lengths of male headers each 9 pins long and one 3 pins long. Insert into corresponding positions (on the bottom of the board) and solder each pin.

Tip: Inserting the headers into a breadboard and then placing the board on top can make this process easier.

Note: If you are using stackable headers, use them here instead of the standard male headers.

gps3.jpg

Insert the GPS module into the front of the board onto the 4 pins. Solder the pins to the module, optionally snip off the excess.

gps4.jpg

gps5.jpg

Optionally - attach the antenna to the board by applying a blob of solder to each solder point and the antenna case. Don't apply too much heat or you may damage the antenna.

gps6.jpg

Programming:

NOTE: The first time you use the GPS module it may take 5 minutes or more, near a window or outside, to acquire a fix and produce data.

The below code will type the data out like a keyboard and must be connected to a computer - but other than the DigiKeyboard stuff, it can be reused in non-connected projects as well.

#include "DigiKeyboard.h"
 
String nmeaString;
bool gpsReady = 0;
 
void setup() {
 
DigiKeyboard.delay(3000);
  Serial.begin(9600);
  initGPS();
}
 
 
void loop() {
 
  if(updateGPS()){
    DigiKeyboard.println(nmeaString);
    DigiKeyboard.println(getStatus());
    if(gpsReady){
     DigiKeyboard.println(getTime());
     DigiKeyboard.println(getDate());
    }
  }
  DigiKeyboard.delay(1000);
 
 
}
 
void initGPS(){
 
  Serial.println(PSTR("$PUBX,40,RMC,1,1,1,0*46")); //turn on RMC msgs
  Serial.println(PSTR("$PUBX,40,GLL,0,0,0,0*5C")); //turn off the rest
  Serial.println(PSTR("$PUBX,40,GGA,0,0,0,0*5A"));
  Serial.println(PSTR("$PUBX,40,GSA,0,0,0,0*4E"));
  Serial.println(PSTR("$PUBX,40,GSV,0,0,0,0*59"));
  Serial.println(PSTR("$PUBX,40,VTG,0,0,0,0*5E"));
 
}
 
 
 
 
bool updateGPS() {
    if(Serial.find("GPRMC,")){
      nmeaString = Serial.readStringUntil('$');
      if(getStatus() == 'A')
        gpsReady = 1;
      else
        gpsReady = 0;
 
      return true;
    }
 
    return false;
 
}
 
 
long getTime(){
  return nmeaString.substring(0,6).toInt();
}
 
char getStatus(){
  return nmeaString.charAt(nmeaString.indexOf(',')+1); //this has to work even if the other data isn't present
}
 
float getLat(){
  return nmeaString.substring(12,22).toFloat();
}
 
int getLatDeg(){
  return nmeaString.substring(12,14).toInt();
}
 
float getLatMin(){
  return nmeaString.substring(14,22).toFloat();
}
 
float getLon(){
  return nmeaString.substring(25,36).toFloat();
}
 
int getLonDeg(){
  return nmeaString.substring(25,28).toInt();
}
 
float getLonMin(){
  return nmeaString.substring(28,36).toFloat();
}
 
float getKnots(){
  return nmeaString.substring(39,44).toFloat();
}
 
long getDate(){
  return nmeaString.substring(46,52).toInt();
}
 
int getDay(){
  return nmeaString.substring(46,48).toInt();
}
 
int getMonth(){
  return nmeaString.substring(48,50).toInt();
}
 
int getYear(){
  return nmeaString.substring(50,52).toInt();
}
 
long getFullYear(){
  return 2000 + nmeaString.substring(50,52).toInt();
}
 
char getNS(){
  return nmeaString.charAt(23); 
}
 
char getEW(){
  return nmeaString.charAt(37); 
}
digispark/tutorials/gps.1418423312.txt.gz · Last modified: 2014/12/12 14:28 by digistump