Anda di halaman 1dari 6

http://www.instructables.

com/id/Connecting-GPS-module-to-Arduino/
Food Living Outside Play Technology Workshop
Connecting GPS-module to Arduino
by louwhopley on July 29, 2010
Table of Contents
Connecting GPS-module to Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Intro: Connecting GPS-module to Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Step 1: Customizing the GPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Step 2: Connecting the GPS to the Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Step 3: The Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Step 4: Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
http://www.instructables.com/id/Connecting-GPS-module-to-Arduino/
Intro: 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.
Image Notes
1. GPS Module EM-406A
2. Wires made longer for ease of use
3. Arduino Duemilanove
4. Breadboard
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.
http://www.instructables.com/id/Connecting-GPS-module-to-Arduino/
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.
Image Notes
1. Pin 3 on your Arduino
2. Pin 5 on your Arduino
3. 5V pin on your Arduino
4. GND pin on your Arduino
5. GPS Module
Image Notes
1. GPS Module
2. Pin3
3. Pin5
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");
http://www.instructables.com/id/Connecting-GPS-module-to-Arduino/
// 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!
Related Instructables
The Complete
understanding
made simple -
GPS with
ARDUINO by
Niranjaan
Getting Started
With The
LS20031 GPS
Receiver by
JayconSystems
Building a
device that clips
to your belt and
tracks how
much time you
spend inside
and outside by
gramsky
Darkness Map
Data Collection
Device by
gennaveeva
Simple
Atmospheric
Satellite by
Theoscillate
GPS time (UTC)
to local time
conversion
using Arduino
by JeonLab
http://www.instructables.com/id/Connecting-GPS-module-to-Arduino/
Advertisements
Comments
16 comments Add Comment
liam.maslovich says: Aug 1, 2014. 12:14 PM REPLY
Hi, I tried to upload this code to my arduino mega and it gave the error message ('SoftwareSerial' does not name a type)
Any Ideas on how to fix this?
mokhtar.grati says: Aug 2, 2014. 12:08 PM REPLY
add #include <SoftwareSerial.h>
jcduplessis says: Dec 16, 2013. 1:30 PM REPLY
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?
stursby says: Mar 24, 2014. 8:54 AM REPLY
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
jcduplessis says: Mar 24, 2014. 9:24 AM REPLY
Thanks, I'll have a look what it does when I change it!
stursby says: Mar 24, 2014. 10:32 AM REPLY
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/...
jcduplessis says: Mar 24, 2014. 1:33 PM REPLY
Thanks!
josephsoso says: Apr 10, 2014. 10:29 AM REPLY
hello
plz help me by uplaading the same code i am gotting the compliling error,
i dont know where the error coming from
Sansanito says: Apr 10, 2014. 10:27 AM REPLY
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;]
http://www.instructables.com/id/Connecting-GPS-module-to-Arduino/
In the last code line, change [return false] to [return "" ]
(all without the "[ ]")
Sorry for my bad english.
abhisek1234 says: Jul 16, 2013. 3:33 AM REPLY
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.
aa10308 says: Jul 10, 2012. 2:28 AM REPLY
I use your code but all I see just that "?xxx?????"
Is it normal?? Or I just forgot something to write??
aa10308 says: Jul 10, 2012. 2:35 AM REPLY
And where could I find "string.h" and "ctype.h"??
cattwood says: Jul 5, 2011. 12:33 PM REPLY
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,
Alti says: Jun 9, 2011. 2:32 AM REPLY
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.
Alti says: Jun 8, 2011. 11:09 AM REPLY
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 says: Jun 8, 2011. 12:54 PM REPLY
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.

Anda mungkin juga menyukai