Source: https://mokxi.com/libraries/adafruit-gps
Updated: 2026-11-11

Libraries / Sensors

Arduino library · Sensors

# Adafruit GPS library: parse NMEA from a serial GPS module

The Adafruit GPS library was written for Adafruit’s Ultimate GPS (an MTK3339 module), but its parser reads the standard NMEA sentences any serial GPS sends, including the u-blox NEO-6M on most cheap boards. It owns the serial port it is given: read() pulls one character in, and once a whole sentence has arrived newNMEAreceived() says so and you hand lastNMEA() to parse().

Open the example in the editor See the calls

Built in on Mokxi: #include <Adafruit_GPS.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit GPS Library does

After a good parse the results sit in public fields rather than behind getter calls: fix and fixquality, hour, minute and seconds in UTC, latitude and longitude, speed in knots, altitude and the number of satellites. The position comes in three forms, the raw ddmm.mmmm from the sentence with a separate N, S, E or W letter, signed decimal degrees, and a fixed-point integer in ten-millionths of a degree.

The difference from TinyGPSPlus is mostly style and the extras. TinyGPSPlus is fed characters by you and works on any GPS; Adafruit_GPS reads the port itself and adds sendCommand() and the PMTK constants that set the update rate and sentence mix on MTK modules. The NEO-6M in the example is not an MTK module, so it ignores those commands as a real one would, and the LOCUS logger calls return false. The example reads the module through SoftwareSerial on pins 4 and 3 and prints the fix every two seconds.

Library Manager name | Adafruit GPS Library

Author | Adafruit

Include | #include <Adafruit_GPS.h>

Boards | Arduino Uno, Arduino Nano, Arduino Mega 2560, Arduino Leonardo, SparkFun Pro Micro, Arduino Micro, Arduino Pro Mini 3.3 V, ESP8266 NodeMCU, ESP32 DevKit, ESP32-DevKitC V4, LOLIN32 Lite, Wemos D1 R32, Cheap Yellow Display, TTGO T-Display, ESP32-S3-DevKitC-1, Seeed XIAO ESP32-S3, Arduino Nano ESP32

In the simulator | Runs, with a gap the note below names.

Parts it drives | GPS module, NEO-6M

## Install it

It builds on Arduino Uno, Arduino Nano, Arduino Mega 2560, Arduino Leonardo, SparkFun Pro Micro, Arduino Micro, Arduino Pro Mini 3.3 V, ESP8266 NodeMCU, ESP32 DevKit, ESP32-DevKitC V4, LOLIN32 Lite, Wemos D1 R32, Cheap Yellow Display, TTGO T-Display, ESP32-S3-DevKitC-1, Seeed XIAO ESP32-S3, Arduino Nano ESP32.

In Mokxi it is built in: #include <Adafruit_GPS.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit GPS Library" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit GPS Library to lib_deps in PlatformIO. Mokxi follows the calls of release 1.9.0, so a sketch written here builds there too.

What to know in the simulator: The NEO-6M is a u-blox module, so it ignores PMTK commands, as a real one does: the LOCUS calls wait for an answer and return false. The I2C and SPI constructors build, and begin() says those buses are not simulated.

- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- Arduino Pro Mini 3.3 V
- ESP8266 NodeMCU
- ESP32 DevKit
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- ESP32-S3-DevKitC-1
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32

## The calls you will use

In the order a sketch meets them.

### Adafruit_GPS GPS(&mySerial)

The parser on a serial port you set up first, usually SoftwareSerial mySerial(4, 3) on an Uno or Serial1 on a Mega or ESP32.

### GPS.begin(9600)

Opens the port at the module’s baud rate. The NEO-6M and Ultimate GPS both start at 9600.

### GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA)

Asks an MTK module to send only the RMC and GGA sentences. A u-blox module ignores PMTK commands.

### GPS.read()

Reads one character from the port into the sentence buffer. Call it on every pass of loop(), as often as you can.

### GPS.newNMEAreceived()

True when a full sentence is waiting. It clears itself when you call lastNMEA().

### GPS.parse(GPS.lastNMEA())

Parses the latest sentence into the fields and returns false on a bad checksum, in which case skip it and wait for the next.

### GPS.latitudeDegrees

Latitude in signed decimal degrees, negative in the south, ready for a map. longitudeDegrees is the same, negative in the west.

### GPS.satellites

How many satellites the fix uses, from the GGA sentence. fix is true and fixquality 1 or more once the position is real.

## Example: Fix, time and position from a NEO-6M with Adafruit_GPS

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- GPS module, NEO-6M TX to Arduino Uno R3 4
- GPS module, NEO-6M RX to Arduino Uno R3 3
- Arduino Uno R3 5V to GPS module, NEO-6M VCC
- Arduino Uno R3 GND to GPS module, NEO-6M GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Fix: 0 forever, with the time still counting

The module has no fix yet. Indoors it may never get one; outside, a cold start takes from 30 seconds to a few minutes. The time fields fill before the position does, so a running clock means the wiring is fine.

### Nothing parses, or newNMEAreceived() is never true

The serial lines are crossed wrongly or the baud rate is off. The GPS TX goes to the board’s receive pin (the first SoftwareSerial argument), and both must use 9600 unless the module was reconfigured.

### Sentences fail the checksum now and then

Characters are being lost because read() is not called often enough. Remove delay() from loop() and print on a millis() timer, as the example does, so the serial buffer never overflows.

## Questions and answers

### Why does the latitude print as 4044.9290 instead of 40.748?

GPS.latitude is the raw NMEA form, degrees and minutes run together. Use latitudeDegrees for decimal degrees, or latitude_fixed for an integer in ten-millionths.

## Keep going

### Learn

- Arduino NEO-6M GPS: Wiring, TinyGPS++ and Code
- UART Serial Explained: Baud, Frames and the Wire

### Parts

- GPS module, NEO-6M

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280

Every built-in library · Open the editor

## Try Adafruit GPS Library without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
