Source: https://mokxi.com/learn/arduino-neo6m-gps
Updated: 2026-10-05

Learn

# Arduino and the NEO-6M GPS module

Beginner

Written by the Mokxi team, updated October 5, 2026

Start building free Open the editor

Or see every lesson.

- 261 parts on the bench
- 31 boards running now
- 1.00x real time, on every board

Click the GPS to lose the fix, and again to get it back

The GPS position example on a simulated ATmega328P. The position prints once a second; click the module to lose the fix.

The NEO-6M is the GPS module in most Arduino kits. It is a small board with a square antenna on a wire. Once it finds satellites, it sends your position to the Arduino as text, once a second.

The circuit above is an Arduino Uno with a NEO-6M on pin 4. It uses SoftwareSerial at 9600 baud and the TinyGPS++ library, like most tutorials. Press Run and the serial monitor prints the latitude, longitude, satellite count, altitude and time once a second.

There is no sky here. Mokxi does not model satellites or a radio. The position is a setting on the module, so you can put it anywhere in the world. What is real is everything the Uno sees: the same text sentences a NEO-6M sends, bit by bit, at 9600 baud.

## What you need

- An Arduino Uno
- A NEO-6M GPS module (GY-NEO6MV2) with its antenna
- Jumper wires
- On a real desk: a window, and a few minutes for the first fix

## Wiring

Part and pin | Goes to | Note

NEO-6M VCC | 5 V | The breakout has its own 3.3 V regulator

NEO-6M GND | GND | Shared ground

NEO-6M TX | Pin 4 | The sketch’s RX

NEO-6M RX | Pin 3 | The sketch’s TX; the module ignores it here

## What the GPS sends

A GPS module talks in NMEA sentences. Each is a line of text that starts with a $ and a name. The NEO-6M sends six kinds each second. The two that matter most are RMC (time, date, position and speed) and GGA (position, satellites and altitude).

Here is the start of the first RMC line from the circuit above: $GPRMC,120000.00,A,3853.36820,N,07702.11380,W. That says 12:00:00 UTC, A for a good fix, and 38 degrees 53.36820 minutes north. TinyGPS++ turns that into 38.889469 for you.

All the sentences together are about 450 bytes. At 9600 baud that keeps the wire busy for almost half of every second.

## The sketch, step by step

SoftwareSerial gpsSerial(4, 3) makes a serial port with RX on pin 4. The GPS’s TX goes there. In setup(), the sketch starts the GPS port at 9600 baud, because that is what a NEO-6M ships at.

In loop(), every byte that has arrived goes into gps.encode(). TinyGPS++ reads the sentences one character at a time and checks each one. When a new GGA sentence has come in, the sketch prints a line like this: Lat: 38.889469 Lng: -77.035233 Sats: 8 Alt: 18.0 m UTC 12:00:00.

The loop, from the GPS position example

## Why the serial monitor runs at 115200

The sketch uses Serial.begin(115200) for the serial monitor, as the TinyGPS++ examples do. Here is why. On Mokxi's Uno, Serial waits for each byte to leave before it moves on. At 9600, one printed line takes about 70 milliseconds, and the sketch can do nothing else meanwhile.

The GPS keeps talking the whole time. SoftwareSerial keeps incoming bytes in a 64-byte buffer. During a slow print, more than 64 bytes arrive and the rest are dropped. The GGA sentence is often the one lost, so the satellite count reads 0. A faster serial monitor keeps up.

A real Uno is a little kinder. Its Serial has its own 64-byte send buffer, so a short line returns sooner. A long print or a long delay() can still make a sketch miss GPS bytes. The habit is the same: print less, and never stall loop().

## Move it, and lose the fix

Click the GPS module and change lat and lon in the properties panel. Try 48.858370 and 2.294481, the Eiffel Tower. The next run prints Lat: 48.858372. The last digit is off because a double on the Uno is only 32 bits. That is still within about a meter.

Click the module on the canvas to take its fix away, like walking indoors. The sentences keep coming but carry no position, and after a few seconds the sketch prints "No fix yet: waiting for satellites." Click it again to get the fix back.

You can also set speed and course. The module then moves along that heading, once a second.

## Common mistakes

GPS TX to the wrong pin. It must go to the first pin in SoftwareSerial(4, 3). Pull the TX wire above and the sketch prints "No data from the GPS: check TX goes to pin 4."

Testing indoors on real hardware. A NEO-6M needs a view of the sky. A cold start can take a minute or more, and the green LED blinks once it has a fix.

Printing too much, too slowly. See the section on 115200 above.

Using delay() in loop(). The GPS does not wait, and a long delay overflows the buffer.

## Questions

Which pins does a NEO-6M use on an Arduino Uno?

Any digital pin for its TX, with SoftwareSerial. This page uses pin 4 for RX and pin 3 for TX. VCC goes to 5 V and GND to GND. The module’s RX pin is only needed to send it commands.

What baud rate does the NEO-6M use?

9600 baud, as shipped. Start the SoftwareSerial port with gpsSerial.begin(9600).

Why does my GPS print 0.000000 for the position?

It has no fix yet. On real hardware, take it outside and wait. The sentences arrive, but with no position in them. Check gps.location.isValid() before you print, or wait for isUpdated() as this sketch does.

Does Mokxi simulate real GPS satellites?

No. There are no satellites and no radio. You set the position on the module. The NMEA sentences, the 9600 baud serial line, SoftwareSerial and TinyGPS++ are real, so the code you write here reads a real NEO-6M the same way. One difference: Mokxi's Serial has no send buffer, as the 115200 section explains.

Related

## Keep going

Arduino HC-05 Bluetooth: Wiring, Code, AT Commands Arduino SD Card Module: A GPS Data Logger Arduino DS3231 Clock With a TM1637 Display How the NEO-6M is modeled A GPS logger on a Mega Advanced The Arduino Uno simulator The project page, with the full sketch Beginner

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
