http://www.cooking-hacks.com/index.php/documentation/tutorials/arduino-gps
Documentation: GPS Module for
Arduino Tutorial
Contents:
Introduction
Steps Index
Fritzing Libraries
Links and Documentation
Introduction
Ingredients:
1 x GPS module
1 x Antenna
1 x Arduino Uno
1 x Two small wires (Red an Black)
1 x USB cable
1 x PC
Difficulty: Medium Preparation Time: 30 minutes
Steps Index
Steps Index:
1. Connecting the GPS module to Arduino (USB gateway mode).
2.
3.
4.
5.
6.
Getting GPS NMEA sentences in the PC.
Getting GPS NMEA sentences in Arduino.
Controlling the output of standard NMEA messages.
Important Issues.
Video-Tutorial.
Step 1: Connecting the GPS module to Arduino (USB gateway mode):
The GPS module for Arduino is a small electronic circuit that allows to connect to
your Arduino board to get position and altitude, as well as speed, date and time on
UTC (Universal Time Coordinated). It uses the standard NMEA protocol
(http://www.nmea.org) to transmit the position data via serial port.
For connecting the GPS module to an Arduino USB gateway, we need to take out the
Atmega chip in Arduino, so we'll connect the GPS serial port to the USB port directly.
Step 2: Getting GPS NMEA sentences in the PC:
Once the GPS is connected, you have to connect power to it. Using two small wires
(red for 5V and black for GND). See the picture.
Finally, plug the USB cable to your computer and open a terminal program to listen
the serial port. Use the following serial port configuration: 4800 baud, 8 data bits, no
parity, 1 stop bit, no flow control.
You'll se the NMEA sentences coming from the GPS module.
With these NMEA sentences you get position, altitude, speed data...etc:
(http://www.nmea.org).
Step 3: Getting GPS NMEA sentences in Arduino:
Connect the GPS to Arduino (with Atmega microcontroller connected) as shown in
the picture.
Upload the code to Arduino and watch the Serial monitor.
Serial monitor:
Arduino code: (not compatible with Arduino 1.0 IDE)
Hide Code
/*
* Copyright (C) 2010 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or
modify
* it under the terms of the GNU General Public License as
published by
* the Free Software Foundation, either version 3 of the License,
or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
License
* along with this program. If not, see
<http://www.gnu.org/licenses/>.
*
* Version 0.1
* Author: Marcos Yarza
*/
// include the SoftwareSerial library
#include <SoftwareSerial.h>
// Constants
#define rxPin 9
#define txPin 8
//rx pin in gps connection
//tx pin in gps connection
// set up the serial port
SoftwareSerial gps = SoftwareSerial(rxPin, txPin);
// variables
byte byteGPS = 0;
int i = 0;
int h = 0;
// Buffers for data input
char inBuffer[300] = "";
char GPS_RMC[100]="";
char GPS_GGA[100]="";
void setup(){
//setup for mySerial port
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
gps.begin(4800);
//setup for Serial port
Serial.begin(19200);
delay(1000);
}
void loop(){
// Read the RMC sentence from GPS
byteGPS = 0;
byteGPS = gps.read();
while(byteGPS != 'R'){
byteGPS = gps.read();
}
GPS_RMC[0]='$';
GPS_RMC[1]='G';
GPS_RMC[2]='P';
GPS_RMC[3]='R';
i = 4;
while(byteGPS != '*'){
byteGPS = gps.read();
inBuffer[i]=byteGPS;
GPS_RMC[i]=byteGPS;
i++;
}
// Read GGA sentence from GPS
byteGPS = 0;
byteGPS = gps.read();
while(byteGPS != 'A'){
byteGPS = gps.read();
}
GPS_GGA[0]='$';
GPS_GGA[1]='G';
GPS_GGA[2]='P';
GPS_GGA[3]='G';
GPS_GGA[4]='G';
GPS_GGA[5]='A';
i = 6;
while(byteGPS != '*'){
byteGPS = gps.read();
inBuffer[i]=byteGPS;
GPS_GGA[i]=byteGPS;
i++;
}
// print the GGA sentence to USB
Serial.print("GGA sentence: ");
h = 0;
while(GPS_GGA[h] != 42){
Serial.print(GPS_GGA[h],BYTE);
h++;
}
Serial.println();
// print the RMC sentence to USB
Serial.print("RMC sentence: ");
h = 0;
while(GPS_RMC[h] != 42){
Serial.print(GPS_RMC[h],BYTE);
h++;
}
Serial.println();
}
Step 4: Controlling the output of standard NMEA messages:
There are some NMEA commands that we can use for controlling the output NMEA
messages of the GPS module. We can activate / deactivate each NMEA message
(GGA, GLL, GSA, GSV, RMC and VTG) sending to the module these commands.
GGA:
Activate => $PSRF103,00,00,01,01*25
Deactivate =>$PSRF103,00,00,00,01*24
GLL:
Activate => $PSRF103,01,00,01,01*24
Deactivate => $PSRF103,01,00,00,01*25
GSA:
Activate => $PSRF103,02,00,01,01*27
Deactivate => $PSRF103,02,00,00,01*26
GSV:
Activate => $PSRF103,03,00,01,01*26
Deactivate => $PSRF103,03,00,00,01*27
RMC:
Activate => $PSRF103,04,00,01,01*21
Deactivate => $PSRF103,04,00,00,01*20
VTG:
Activate => $PSRF103,05,00,01,01*20
Deactivate => $PSRF103,05,00,00,01*21
Also it is possible to change the frequency of the output, see the GPS module
firmware documentation.
This configuration will be lost when the GPS module is powered OFF.
Step 5: Important Issues:
Important Issues:
Handle with care the internal antenna. It's fragile.
The GPS module should be inside a plastic box, isolated from the
environment.
The antenna must be in horizontal position.
For improving the satellites signal, the antenna has to be in a place with a clear
sky view (no trees, no buildings...).
Maybe the GPS module takes 2-3 minutes to get signal the firs time.
Step 6: Video-Tutorial:
Here's an explanatory video, which shows the whole process developed in this
tutorial:
Fritzing Libraries
GPS Module for Arduino
Download
GPS Module for Arduino is a small electronic circuit that allows to connect to your
Arduino board to get position and altitude, as well as speed, date and time on UTC
(Universal Time Coordinated).
GPS Module for Arduino is a perfect complement for developing geolocalization
applications.
You can download our Fritzing libraries from this area.
Links and Documentation
Links and Documentation:
Schematic of the shield
GPS module firmware documentation
GPS Module for Arduino Video-Tutorial.
NMEA
© Copyright 2026 Paperzz