Arduino Nano - GPS
This tutorial instructs you how to use Arduino Nano with a NEO-6M GPS module. In detail, we will learn:
- How to connect Arduino Nano to a NEO-6M GPS module
- How to program Arduino Nano to read GPS coordinates (longitude, latitude, and altitude) from a NEO-6M GPS module
- How to program Arduino Nano to calculate the distance from the current GPS position to a predefined GPS coordinate (e.g. coordinates of London).
Apart from longitude, latitude, and altitude, Arduino Nano is also able to read GPS speed (km/h), and date time from a NEO-6M GPS module.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of NEO-6M GPS module
NEO-6M GPS module is a GPS module that can provide the following information:
- Longitude
- Latitude
- Altitude
- GPS speed (km/h)
- Date time
The NEO-6M GPS Module Pinout
The NEO-6M GPS module has four pins:
- The VCC pin: should be connected to the VCC (5V)
- The GND pin: should be connected to the GND (0V)
- The TX pin: is used for serial communication and should be connected to the Serial (or SoftwareSerial) RX pin on Arduino Nano.
- The RX pin: is used for serial communication and should be connected to the Serial (or SoftwareSerial) TX pin on Arduino Nano.

Wiring Diagram

This image is created using Fritzing. Click to enlarge image
The diagram below shows the same connections without a breadboard:

This image is created using Fritzing. Click to enlarge image
Pushing jumper wires into the headers is quick, but the wires can slip out. You can plug the Arduino Nano into a Screw Terminal Expansion Board for Arduino Nano and connect the wires to its screw terminals. The pins do not change. Just connect each wire to the matching screw terminal:

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Nano and other components.
Arduino Nano Code
Reading GPS coordinates, speed (km/h), and date time
Detailed Instructions
- Click to the Libraries icon on the left bar of the Arduino IDE.
- Search “TinyGPSPlus”, then find the TinyGPSPlus library by Mikal Hart
- Click Install button to install TinyGPSPlus library.

- Copy the code mentioned above and open it in the Arduino IDE.
- Click the Upload button on the Arduino IDE to send the code to the Arduino Nano.
- Check the Serial Monitor to observe the outcome.
Calculating the distance from current location to a predefined location
The code below computes the distance between the current location and London (lat:51.508131 , long: -0.128002).
Detailed Instructions
- Copy the code and open it with the Arduino IDE.
- Click the Upload button on the Arduino IDE to compile and upload the code to the Arduino Nano.
- View the outcome on the Serial Monitor.