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
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!
44 Comments
4 years ago on Step 4
Why are you using softwareserial???????
Question 5 years ago
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?
Question 5 years ago on Step 3
is this programme applicable for receiving the location frm gps module
5 years ago
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)'
7 years ago
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 ...
Reply 5 years ago
I got the same problem as you were.......u got a solution for this?
5 years ago
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.
5 years ago
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.
11 years ago on Step 3
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.
Reply 6 years ago
alter baud rate
Reply 7 years ago
change the baud rate on the serial monitor.
Reply 11 years ago on Introduction
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.
6 years ago
can i find whether the direction pointed is N,S, W or East ?
6 years ago
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')
6 years ago
https://youtu.be/2dnB1kgVJT0
6 years ago
Worked for me :)
At some point i need to install CP210x_Windows_Drivers.
7 years ago
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
Reply 7 years ago
Use #include<SoftwareSerial.h>
Reply 7 years ago
Thankyou for the response,.. that makes more sense now...
11 years ago on Step 3
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.