Random Nerd Tutorials

Guide to NEO-6M GPS Module with Arduino


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:

  • Wire the NEO-6M GPS module to the Arduino UNO
  • Get raw GPS data
  • Parse raw data to obtain selected and readable GPS information
  • Get location

Introducing the NEO-6M GPS Module

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.

  • This module has an external antenna and built-in EEPROM.
  • Interface: RS232 TTL
  • Power supply: 3V to 5V
  • Default baudrate: 9600 bps
  • Works with standard NMEA sentences

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.

Where to buy?

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.

Pin Wiring

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
RX TX pin defined in the software serial
TX RX pin defined in the software serial

Getting GPS Raw Data

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.

Parts Required

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.

  • The module GND pin is connected to Arduino GND pin
  • The module RX pin is connected to Arduino pin 3
  • The module TX pin is connected to Arduino pin 4
  • The module VCC pin is connected to Arduino 5V pin


Copy the following code to your Arduino IDE and upload it to your Arduino board.

This sketch assumes you are using pins 4 and 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:


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();

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.

Understanding NMEA Sentences

NMEA sentences start with the $ character, and each data field is separated by a comma.


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:

  • 110617 – represents the time at which the fix location was taken, 11:06:17 UTC
  • 41XX.XXXXX,N – latitude 41 deg XX.XXXXX’ N
  • 00831.54761,W – Longitude 008 deg 31.54761′ W
  • 1 – fix quality (0 = invalid; 1= GPS fix; 2 = DGPS fix; 3 = PPS fix; 4 = Real Time Kinematic; 5 = Float RTK; 6 = estimated (dead reckoning); 7 = Manual input mode; 8 = Simulation mode)
  • 05 – number of satellites being tracked
  • 2.68 – Horizontal dilution of position
  • 129.0, M – Altitude, in meters above the sea level
  • 50.1, M – Height of geoid (mean sea level) above WGS84 ellipsoid
  • empty field – time in seconds since last DGPS update
  • empty field – DGPS station ID number
  • *42 – the checksum data, always begins with *

The other NMEA sentences provide additional information:

  • $GPGSA – GPS DOP and active satellites
  • $GPGSV – Detailed GPS satellite information
  • $GPGLL – Geographic Latitude and Longitude
  • $GPRMC – Essential GPS pvt (position, velocity, time) data
  • $GPVTG – Velocity made good

To know what each data field means in each of these sentences, you can consult NMEA data here.

Parsing NMEA Sentences with TinyGPS++ Library

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. You can click here for more information about the TinyGPS++ Library.

Installing the TinyGPS++ Library

Follow the next steps to install the TinyGPS++ library in your Arduino IDE:

  1. Click here to download the TinyGPSPlus library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get TinyGPSPlus-master folder
  3. Rename your folder from TinyGPSPlus-master to TinyGPSPlus
  4. Move the TinyGPSPlus folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE

The library provides several examples on 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.

Getting Location Using the NEO-6M GPS Module and the TinyGPS++ Library

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.

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() {

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){

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 has 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 a more accurate data.

Getting More GPS Information Using the TinyGPS++ Library

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:

  • date
  • time
  • speed
  • course
  • altitude
  • satellites
  • hdop

The code below exemplifies how you can get all that information in a simple way.

Note: the TinyGPS++ library is well commented on how to use all its functionalities.

Wrapping Up

We hope you’ve found this guide useful. We intend to make a GPS data logger with the NEO-6M GPS module and the SD card module, so stay tuned.

If you liked this project you may also like:

Thanks for reading.

Learn ESP32 with Arduino IDE

This is our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks! The registrations are open, so SIGN UP NOW »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our course even with no prior experience!

Leave a Comment:

Add Your Reply

Enroll in our Electronics and Programming Courses:

ESP32, ESP8266, Arduino and much more.