Instructables

Connecting GPS-module to Arduino

Step 1: Customizing the GPS

Picture of Customizing the GPS
Firstly, we need to make the GPS useable in our custom environment.

Cut the connecting plug of the furthest side of the GPS' connection wires.
Now it is your choice to extend them with longer wires, make sure to connect them thoroughly.

Remove the plastic off the ends of the wires.

See the images below.

Step 2: Connecting the GPS to the Arduino

Now that your GPS-module is ready, we can go ahead.

Connect your GPS wires to the Arduino like on this schematic below. Where "pin 5" gets used as "TX" and "pin 3" as "RX".

Any available pins on your Arduino may be used. Just be sure to connect the right wire to the right pin.

The gray wire is left aside unconnected.

Step 3: The Coding

Doing the coding for your Arduino is simple, you can copy the sample code and/or edit it for your own use.

This code sends all strings received from the GPS through serial to your computer (Serial Monitor)
Note: See comments in coding for filtering of certain strings
#include 

// GPS Setup
#define rxGPS 3
#define txGPS 5
SoftwareSerial serialGPS = SoftwareSerial(rxGPS, txGPS);
String stringGPS = "";

void setup() {
  pinMode(rxGPS, INPUT);
  pinMode(txGPS, OUTPUT);


  Serial.begin(9600);
  Serial.println("Started");

  // GPS Setup
  serialGPS.begin(4800);
  digitalWrite(txGPS,HIGH);

  // Cut first gibberish
  while(serialGPS.available())
    if (serialGPS.read() == '\r')
      break;
}

void loop()
{
  String s = checkGPS();
  if(s && s.substring(0, 6) == "$GPGGA")
  {
    Serial.println(s);
  }
}

// Check GPS and returns string if full line recorded, else false
String checkGPS()
{
  if (serialGPS.available())
  {
    char c = serialGPS.read();
    if (c != '\n' && c != '\r')
    {
      stringGPS  = c;
    }
    else
    {
      if (stringGPS != "")
      {
        String tmp = stringGPS;
        stringGPS = "";
        return tmp;
      }
    }
  }
  return false;
}
jcduplessis7 months ago
Hi!
Thanks for your instructable! I am currently trying to connect an old Garmin GPS 12CX to my Arduino. I have copied your code as is and when I try to upload it from the Arduino software I get the following error message: "invalid conversion from 'char' to 'const char*'" when compiling the code. Any ideas why?

I got the sketch to compile by changing that line to the following:

String stringGPS = String(c);

Reference: http://arduino.cc/en/Reference/StringConstructor#.UzBNUK1dUzh

Thanks, I'll have a look what it does when I change it!

Also, I've since got my GPS to work using the following sketch: http://pastebin.com/ZdgN2tzD

And you'll need to add the TinyGPS library as well (https://github.com/mikalhart/TinyGPS/releases/tag/...

Thanks!

hello

plz help me by uplaading the same code i am gotting the compliling error,

i dont know where the error coming from

gps.jpg
Sansanito3 months ago

For me the code works, but with some modifications.
On this segment

[if (c != '\n' && c != '\r')
{
stringGPS = c; }]

change [stringGPS = c;] to [stringGPS += c;]

In the last code line, change [return false] to [return "" ]

(all without the "[ ]")

Sorry for my bad english.

hi, actually i am having problem with my "Robokit GPS02",dont know why it is not working...Can any one help me...please it urgent......Hoping to see reply soon.
aa103082 years ago
I use your code but all I see just that "ÿø†xxx†à†à†à†à†"

Is it normal?? Or I just forgot something to write??
aa10308 aa103082 years ago
And where could I find "string.h" and "ctype.h"??
cattwood3 years ago
Thanks this was really helpful (to know that it is possible to hook the EM406A directly to the Arduino) but the pin references are confusing, if you hook it up as described above your Arduino will shut down. This happend to me, luckily nothing blew but it just goes to show how important it is to check the specifications PDF before hooking +5 V --- so the +5v goes on pin 2 of the Gps VCC in the spec,( The grey wire is pin 1 of the GPS which as described does not need to be connected. so if looking at the EM406a GPS as described about the pins are (from top to bottom ), Grey wire = Pin 1 - GND, Pin 2, VCC (ie +5 from the Arduino), Pin 3 RX, Pin 4 TX,
Alti3 years ago
Hi - Thanks for replying. Yeah everything is connected OK. Something very odd going on, anyway I now get the 'Started' message in the serial monitor, but that's it. It never budges beyond that!

Similar to the issue here http://www(dot)sparkfun(dot)com/tutorials/173#
whereby it just sits 'waiting for lock' even though I know it has a lock and works fine. Very strange.

Also the driver that I used can also be used with the above GPS module to get it working in Autoroute or whatever s/f needs a usb GPS unit, just add a cable to it.
Alti3 years ago
Hi - I merely get strings of 'ðððððððððøðððððð' using your code.

I have the same setup as you.

My Module is OK as when I use the driver for this GPS module (Google BU-353 and USGlobalSat ) and connect via a USB cable to a windows box, all is well, I can read NMEA sentences in hyper-terminal. Bur for the life of me I cannot get this GPS module to work with an Arduino,

I took my GPS unit out of a USGlobalSat USB device, which is just an Em-406a in plastic attached to a USB cable and comes with a driver, so it works fine with Microsoft Autoroute for instance...but following your instructions, I cannot get anything but the above garbage..! Any one else get this working..? Thanks.

louwhopley (author)  Alti3 years ago
Hi. Are you sure you are connecting the correct wires to correct pins and it's directly from the device? Not through some other chips first. I.e. the wires coming from the Em-406a connected directly to Arduino.

I use this instructable for myself every time I start a new GPS project (since I forget how to do this stuff) So these instructions works if you follow them correctly.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!