This guide shows how to use the NEO-6M GPS module with the Arduino to get GPS data. GPS stands for Global Positioning System and can be used to determine position, time, and speed if you’re travelling.
You’ll learn how to:
The NEO-6M GPS module is shown in the figure below. It comes with an external antenna, and does’t come with header pins. So, you’ll need to get and solder some.

The NEO-6M GPS module is also compatible with other microcontroller boards. To learn how to use the NEO-6M GPS module with the Raspberry Pi, you can read: Email Alert System on Location Change with Raspberry Pi and GPS Module.
You can get the NEO-6M GPS module for a price between $5 to $20. We recommend checking the NEO-6M GPS module page on Maker Advisor to compare the price in different stores and find the best one.
The NEO-6M GPS module has four pins: VCC, RX, TX, and GND. The module communicates with the Arduino via serial communication using the TX and RX pins, so the wiring couldn’t be simpler:
| NEO-6M GPS Module | Wiring to Arduino UNO |
| VCC | 5V |
| RX | TX pin defined in the software serial |
| TX | RX pin defined in the software serial |
| GND | GND |
To get raw GPS data you just need to start a serial communication with the GPS module using Software Serial. Continue reading to see how to do that.
For testing this example you’ll need the following parts:
You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!
Wire the NEO-6M GPS module to your Arduino by following the schematic below.

Copy the following code to your Arduino IDE and upload it to your Arduino board.
/* * Rui Santos * Complete Project Details https://randomnerdtutorials.com */ #include <SoftwareSerial.h> // The serial connection to the GPS module SoftwareSerial ss(4, 3); void setup(){ Serial.begin(9600); ss.begin(9600); } void loop(){ while (ss.available() > 0){ // get the byte data from the GPS byte gpsData = ss.read(); Serial.write(gpsData); } }
This sketch assumes you are using pin 4 and pin 3 as RX and TX serial pins to establish serial communication with the GPS module. If you’re using other pins you should edit that on the following line:
SoftwareSerial ss(4, 3);
Also, if your module uses a different default baud rate than 9600 bps, you should modify the code on the following line:
ss.begin(9600);
This sketch listen to the GPS serial port, and when data is received from the module, it is sent to the serial monitor.
while (ss.available() > 0){ // get the byte data from the GPS byte gpsData = ss.read(); Serial.write(gpsData); }
Open the Serial Monitor at a baud rate of 9600.

You should get a bunch of information in the GPS standard language, NMEA. Each line you get int the serial monitor is an NMEA sentence.
NMEA stands for National Marine Electronics Association, and in the world of GPS, it is a standard data format supported by GPS manufacturers.
NMEA sentences start with the $ character, and each data field is separated by a comma.
$GPGGA,110617.00,41XX.XXXXX,N,00831.54761,W,1,05,2.68,129.0,M,50.1,M,,*42 $GPGSA,A,3,06,09,30,07,23,,,,,,,,4.43,2.68,3.53*02 $GPGSV,3,1,11,02,48,298,24,03,05,101,24,05,17,292,20,06,71,227,30*7C $GPGSV,3,2,11,07,47,138,33,09,64,044,28,17,01,199,,19,13,214,*7C $GPGSV,3,3,11,23,29,054,29,29,01,335,,30,29,167,33*4E $GPGLL,41XX.XXXXX,N,00831.54761,W,110617.00,A,A*70 $GPRMC,110618.00,A,41XX.XXXXX,N,00831.54753,W,0.078,,030118,,,A*6A $GPVTG,,T,,M,0.043,N,0.080,K,A*2C
There are different types of NMEA sentences. The type of message is indicated by the characters before the first comma.
The GP after the $ indicates it is a GPS position. The $GPGGA is the basic GPS NMEA message, that provides 3D location and accuracy data. In the following sentence:
$GPGGA,110617.00,41XX.XXXXX,N,00831.54761,W,1,05,2.68,129.0,M,50.1,M,,*42The other NMEA sentences provide additional information:
To know what each data field means in each of these sentences, you can consult NMEA data here.
You can work with the raw data from the GPS, or you can convert those NMEA messages into a readable and useful format, by saving the characters sequences into variables. To do that, we’re going to use the TinyGPS++ library.
This library makes it simple to get information on location in a format that is useful and easy to understand.
In the Arduino IDE, go to Sketch > Include Library > Manage Libraries or click on the Library Manager icon at the left sidebar.
Search for TinyGPSPlus and install the library by Mikal Hart.

The library provides several examples of how to use it. In your Arduino IDE, you just need to go to File > Examples > TinyGPS++, and choose from the examples provided.
Note: the examples provided in the library assume a baud rate of 4800 for the GPS module. You need to change that to 9600, if you’re using the NEO-6M GPS module.
You can get the location in a format that is convenient and useful by using the TinyGPS++ library. Below, we provide a code to get the location from the GPS. This is a simplified version of one of the library examples.
/* * Rui Santos * Complete Project Details https://randomnerdtutorials.com */ #include <TinyGPS++.h> #include <SoftwareSerial.h> static const int RXPin = 4, TXPin = 3; static const uint32_t GPSBaud = 9600; // The TinyGPS++ object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); void setup(){ Serial.begin(9600); ss.begin(GPSBaud); } void loop(){ // This sketch displays information every time a new sentence is correctly encoded. while (ss.available() > 0){ gps.encode(ss.read()); if (gps.location.isUpdated()){ Serial.print("Latitude= "); Serial.print(gps.location.lat(), 6); Serial.print(" Longitude= "); Serial.println(gps.location.lng(), 6); } } }
You start by importing the needed libraries: TinyGPSPlus and SoftwareSerial
#include <TinyGPS++.h> #include <SoftwareSerial.h>
Then, you define the software serial RX and TX pins, as well as the GPS baud rate. If you are using other pins for software serial you need to change that here. Also, if your GPS module uses a different default baud rate, you should also modify that.
static const int RXPin = 4, TXPin = 3; static const uint32_t GPSBaud = 9600;
Then, you create a TinyGPS++ object:
TinyGPSPlus gps;And start a serial connection on the pins you’ve defined earlier
SoftwareSerial ss(RXPin, TXPin);
In the setup(), you initialize serial communication, both to see the readings on the serial monitor and to communicate with the GPS module.
void setup() { Serial.begin(9600); ss.begin(GPSBaud); }
In the loop is where you request the information. To get TinyGPS++ to work, you have to repeatedly funnel the characters to it from the GPS module using the encode() method.
while (ss.available() > 0){ gps.encode(ss.read());
Then, you can query the gps object to see if any data fields have been updated:
if (gps.location.isUpdated()){ Serial.print("Latitude="); Serial.print(gps.location.lat(), 6); Serial.print("Longitude="); Serial.println(gps.location.lng(), 6); }
Getting the latitude and longitude is as simple has using gps.location.lat(), and gps.location.lng(), respectively.
Upload the code to your Arduino, and you should see the location displayed on the serial monitor. After uploading the code, wait a few minutes while the module adjusts the position to get more accurate data.

The TinyGPS++ library allows you to get way more information than just the location, and in a simple way. Besides the location, you can get:
The code below exemplifies how you can get all that information in a simple way.
/* * Rui Santos * Complete Project Details https://randomnerdtutorials.com * * Based on the example TinyGPS++ from arduiniana.org * */ #include <TinyGPS++.h> #include <SoftwareSerial.h> static const int RXPin = 4, TXPin = 3; static const uint32_t GPSBaud = 9600; // The TinyGPS++ object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); void setup(){ Serial.begin(9600); ss.begin(GPSBaud); } void loop(){ // This sketch displays information every time a new sentence is correctly encoded. while (ss.available() > 0){ gps.encode(ss.read()); if (gps.location.isUpdated()){ // Latitude in degrees (double) Serial.print("Latitude= "); Serial.print(gps.location.lat(), 6); // Longitude in degrees (double) Serial.print(" Longitude= "); Serial.println(gps.location.lng(), 6); // Raw latitude in whole degrees Serial.print("Raw latitude = "); Serial.print(gps.location.rawLat().negative ? "-" : "+"); Serial.println(gps.location.rawLat().deg); // ... and billionths (u16/u32) Serial.println(gps.location.rawLat().billionths); // Raw longitude in whole degrees Serial.print("Raw longitude = "); Serial.print(gps.location.rawLng().negative ? "-" : "+"); Serial.println(gps.location.rawLng().deg); // ... and billionths (u16/u32) Serial.println(gps.location.rawLng().billionths); // Raw date in DDMMYY format (u32) Serial.print("Raw date DDMMYY = "); Serial.println(gps.date.value()); // Year (2000+) (u16) Serial.print("Year = "); Serial.println(gps.date.year()); // Month (1-12) (u8) Serial.print("Month = "); Serial.println(gps.date.month()); // Day (1-31) (u8) Serial.print("Day = "); Serial.println(gps.date.day()); // Raw time in HHMMSSCC format (u32) Serial.print("Raw time in HHMMSSCC = "); Serial.println(gps.time.value()); // Hour (0-23) (u8) Serial.print("Hour = "); Serial.println(gps.time.hour()); // Minute (0-59) (u8) Serial.print("Minute = "); Serial.println(gps.time.minute()); // Second (0-59) (u8) Serial.print("Second = "); Serial.println(gps.time.second()); // 100ths of a second (0-99) (u8) Serial.print("Centisecond = "); Serial.println(gps.time.centisecond()); // Raw speed in 100ths of a knot (i32) Serial.print("Raw speed in 100ths/knot = "); Serial.println(gps.speed.value()); // Speed in knots (double) Serial.print("Speed in knots/h = "); Serial.println(gps.speed.knots()); // Speed in miles per hour (double) Serial.print("Speed in miles/h = "); Serial.println(gps.speed.mph()); // Speed in meters per second (double) Serial.print("Speed in m/s = "); Serial.println(gps.speed.mps()); // Speed in kilometers per hour (double) Serial.print("Speed in km/h = "); Serial.println(gps.speed.kmph()); // Raw course in 100ths of a degree (i32) Serial.print("Raw course in degrees = "); Serial.println(gps.course.value()); // Course in degrees (double) Serial.print("Course in degrees = "); Serial.println(gps.course.deg()); // Raw altitude in centimeters (i32) Serial.print("Raw altitude in centimeters = "); Serial.println(gps.altitude.value()); // Altitude in meters (double) Serial.print("Altitude in meters = "); Serial.println(gps.altitude.meters()); // Altitude in miles (double) Serial.print("Altitude in miles = "); Serial.println(gps.altitude.miles()); // Altitude in kilometers (double) Serial.print("Altitude in kilometers = "); Serial.println(gps.altitude.kilometers()); // Altitude in feet (double) Serial.print("Altitude in feet = "); Serial.println(gps.altitude.feet()); // Number of satellites in use (u32) Serial.print("Number os satellites in use = "); Serial.println(gps.satellites.value()); // Horizontal Dim. of Precision (100ths-i32) Serial.print("HDOP = "); Serial.println(gps.hdop.value()); } } }
Copyright ©2025. All Rights Reserved Emblab THE RAVE INNOVATION