Using SoftwareSerial library and TinyGPS libraries on a UNO with GPS Shield

I recently purchased an UNO and installed IDE v.1.0 and subsequently purchased a GPS shield kit from Sparkfun (came with EM-406 GPS module). After soldering the shield together and pasting the code from the Sparkfun site, I learned that the reference to the NewSoftSerial library is obsolete so I referenced the SoftwareSerial and did my best to update the code. This was a good lesson in chasing down compiling errors. Eventually, I got rid of all the errors, but now when I open the Serial Monitor, I get some (for lack of a better word) gibberish. I have pasted the code below and as you can see it is primarily written by Aaron Weiss (Sparkfun website). I changed the library reference and some of the code referencing the current SoftwareSerial library (hopefully correctly, but maybe not). I made sure I had everything turned on (Lights on shield and GPS come on), the switch on DLINE and a message at the bottom of the IDE reads “Done Compiling”.

Based on the instructions posted on the Sparkfun website, the serial monitor should read “…waiting for lock…” until the GPS locks. I do not get this at all. Again, just gibberish. Specifically, boxes scrolling right after selecting the rate at 115200. After the GPS obtains lock, it’s supposed to show the time and location from the NMEA data.

Below is all the code in the sketch (including comments).

  Aaron Weiss
  SparkFun Electronics
  Example GPS Parser based off of TinyGPS examples.
  Parses NMEA sentences from an EM406 running at 4800bps into readable 
  values for latitude, longitude, elevation, date, time, course, and 
  For the SparkFun GPS Shield. Make sure the switch is set to DLINE.
  Once you get your longitude and latitude you can paste your 
  coordinates from the terminal window into Google Maps. Here is the 
  link for SparkFun's location.,+-105.20997
  Uses the NewSoftSerial library for serial communication with your GPS, 
  so connect your GPS TX and RX pin to any digital pin on the Arduino, 
  just be sure to define which pins you are using on the Arduino to 
  communicate with the GPS module. 
    changed values to RXPIN = 2 and TXPIN = to correspond with
    hardware v14+. Hardware v13 used RXPIN = 3 and TXPIN = 2.
  1-15-12 (jseery)
    changed reference from NewSoftSerial library to Software Serial.

// In order for this sketch to work, you will need to download 
// NewSoftSerial and TinyGPS libraries from and put them 
// into the hardware->libraries folder in your ardiuno directory.
// Here are the lines of code that point to those libraries

#include <SoftwareSerial.h>
#include <TinyGPS.h>

// Define which pins you will use on the Arduino to communicate with your 
// GPS. In this case, the GPS module's TX pin will connect to the 
// Arduino's RXPIN which is pin 3.
#define RXPIN 2
#define TXPIN 3
//Set this value equal to the baud rate of your GPS
#define GPSBAUD 4800

// Create an instance of the TinyGPS object
TinyGPS gps;
// Initialize the SoftwareSerial library to the pins you defined above
SoftwareSerial mySerial = SoftwareSerial (RXPIN, TXPIN);

// This is where you declare prototypes for the functions that will be 
// using the TinyGPS library.
void getgps(TinyGPS &gps);

// In the setup function, you need to initialize two serial ports; the 
// standard hardware serial port (Serial()) to communicate with your 
// terminal program an another serial port (NewSoftSerial()) for your 
// GPS.
void setup()
  // This is the serial rate for your terminal program. It must be this 
  // fast because we need to print everything before a new sentence 
  // comes in. If you slow it down, the messages might not be valid and 
  // you will likely get checksum errors.
  //Sets baud rate of your GPS
  Serial.println("GPS Shield QuickStart Example Sketch v12");
  Serial.println("       ...waiting for lock...           ");

// This is the main loop of the code. All it does is check for data on 
// the RX pin of the ardiuno, makes sure the data is valid NMEA sentences, 
// then jumps to the getgps() function.
void loop()
  while(mySerial.available())     // While there is data on the RX pin...
      int c =;    // load the data into a variable...
      if(gps.encode(c))      // if there is a new valid sentence...
        getgps(gps);         // then grab the data.

// The getgps function will get and print the values we want.
void getgps(TinyGPS &gps)
  // To get all of the data into varialbes that you can use in your code, 
  // all you need to do is define variables and query the object for the 
  // data. To see the complete list of functions see keywords.txt file in 
  // the TinyGPS and NewSoftSerial libs.
  // Define the variables that will be used
  float latitude, longitude;
  // Then call this function
  gps.f_get_position(&latitude, &longitude);
  // You can now print variables latitude and longitude
  Serial.print("Lat/Long: "); 
  Serial.print(", "); 
  // Same goes for date and time
  int year;
  byte month, day, hour, minute, second, hundredths;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);
  // Print data and time
  Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/"); 
  Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(hour, DEC); Serial.print(":"); 
  Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC); 
  Serial.print("."); Serial.println(hundredths, DEC);
  //Since month, day, hour, minute, second, and hundr
  // Here you can print the altitude and course values directly since 
  // there is only one value for the function
  Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude());  
  // Same goes for course
  Serial.print("Course (degrees): "); Serial.println(gps.f_course()); 
  // And same goes for speed
  Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
  // Here you can print statistics on the sentences.
  unsigned long chars;
  unsigned short sentences, failed_checksum;
  gps.stats(&chars, &sentences, &failed_checksum);
  //Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
  //Serial.println(); Serial.println();

Is your serial monitor set to 115200?

Yes. When the serial monitor window opens, I change the rate to 115200 & still get the incorrect results

Try adding ", true" to the end of the SoftwareSerial constructor. Perhaps the data output by the GPS is inverted.

Are you sure gps.enable(c); is working correctly?

Maybe we have a similar problem at:

Greetings Mig

Thanks Mig, i'll definitely take a look at the post you have referenced.

hey! i am having the same problem.
i have tried other codes as well but all of them only returns gibberish values.
any luck with yours?