Connecting GPS-module to Arduino

261,276

142

41

Published

Introduction: Connecting GPS-module to Arduino

This is a simple Instructable for the people who'd like to know how to connect and use their GPS module with an Arduino.

I am using an Arduino Duemilanove and an EM-406A GPS module.
NOTE: The breadboard is not necessary but makes the job a lot easier.

Step 1: 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;
}

Step 4: Testing

Now that you are setup and ready to run your project, make sure the code has been uploaded to the Arduino and that all wires and connections are rightly fitted.

Switch on the Arduino and switch on your Serial-Monitor. Wait for the message "Started" to appear on your monitor screen. If all your connections are perfect, the red light will be shining stable and you will start seeing messages appear underneath each other.

Remember to scroll down manually if it reaches the end of the screen!

The GPS will only give through the coordinates when the red-onboard light is flashing. (Meaning it has a fix.)

Use your GPS manual to decode these messages. It delivers great data such as coordinates, UTC time, height above sea-level etc.

Have fun and let me know if I made any mistakes!

Share

    Recommendations

    • Casting Contest

      Casting Contest
    • Make it Move Contest

      Make it Move Contest
    • Planter Challenge

      Planter Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    2 Questions

    0

    hi

    am using G702-001UB gps module.I upload the code given but in serial monitor no output is display.it only display "started".

    What can I do to get the co ordinates.What is the exact code to work in this module?

    is this programme applicable for receiving the location frm gps module

    41 Comments

    This error came for the last line of the program
    "return false"

    converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

    Hi im using VK16E gps module with Arduino Mega... i uploaded ur code but at Serial Monitor it just shows Started and nothing else happens....

    I'd checked ur code with the connections in both ways as:

    1...GPS-rx to arduino-tx and GPS-tx to arduino-rx

    2...GPS-tx to arduino-tx and GPS-rx to arduino-rx

    but not working ...

    1 reply

    I got the same problem as you were.......u got a solution for this?

    Please help me.
    Arduino: 1.8.2 (Windows 8.1), Board: "Arduino/Genuino Uno"

    In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:24:0,

    from sketch\sketch_may09a.ino.cpp:1:

    C:\Users\Asus\AppData\Local\Temp\arduino_modified_sketch_360574\sketch_may09a.ino: In function 'String checkGPS()':

    sketch_may09a:55: error: converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

    return false;

    ^

    exit status 1
    converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    Arduino: 1.8.1 (Windows 8.1), Board: "Arduino/Genuino Uno"

    In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:24:0,

    from sketch\sketch_apr07d.ino.cpp:1:

    C:\Users\hp\AppData\Local\Temp\arduino_modified_sketch_178042\sketch_apr07d.ino: In function 'String checkGPS()':

    sketch_apr07d:55: error: converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

    return false;

    ^

    exit status 1

    converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

    This report would have more information with

    "Show verbose output during compilation"

    option enabled in File -> Preferences.

    user

    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.

    3 replies

    alter baud rate

    change the baud rate on the serial monitor.

    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.

    can i find whether the direction pointed is N,S, W or East ?

    I included the softserial library and tried to compile. I get the following errors.

    Can you tell me what I am doing wrong?


    sketch_nov14b.ino: In function 'String checkGPS()':
    sketch_nov14b:47: error: ambiguous overload for 'operator=' (operand types are 'String' and 'char')
    sketch_nov14b.ino:47:18: note: candidates are:
    In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:26:0,
    from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26,
    from C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.h:36,
    from sketch_nov14b.ino:2:
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86:11: note: String& String::operator=(const String&) <near match>
    String & operator = (const String &rhs);
    ^
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86:11: note: no known conversion for argument 1 from 'char' to 'const String&'
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87:11: note: String& String::operator=(const char*) <near match>
    String & operator = (const char *cstr);
    ^
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87:11: note: no known conversion for argument 1 from 'char' to 'const char*'
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88:11: note: String& String::operator=(const __FlashStringHelper*) <near match>
    String & operator = (const __FlashStringHelper *str);
    ^
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88:11: note: no known conversion for argument 1 from 'char' to 'const __FlashStringHelper*'
    In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:24:0,
    from sketch_nov14b.ino:9:
    sketch_nov14b:59: error: converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'
    ambiguous overload for 'operator=' (operand types are 'String' and 'char')

    https://youtu.be/2dnB1kgVJT0

    Worked for me :)
    At some point i need to install CP210x_Windows_Drivers.

    Sorry,... but the #include statement seems to be missing the actual library to be used,.. assume this must just be a typo somewhere....

    many thanks

    2 replies

    Thankyou for the response,.. that makes more sense now...

    user

    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.

    3 replies

    Same here, it just says "Started".

    I am using an Arduino Mega 2560 board with a ircirocomm gps module (it has "595k" written on it if that helps)

    any luck with the started and no other activity thing??

    nope, i tryed for a few weeks, then tried again on and off since, any tips?