In-Depth - Interface Ublox NEO-6M GPS Module With Arduino
In-Depth - Interface Ublox NEO-6M GPS Module With Arduino
Battery EEPROM
Antenna
Library Installation
Using Ucenter
Give your next Arduino project the ability to sense locations with the NEO-6M GPS module
that can track 22 satellites and identify locations anywhere in the world. It can serve as a
great launch pad for anyone looking to get into the world of GPS.
They are low power (suitable for battery operated devices), affordable, easy to interface and
extremely popular with hobbyists.
GPS is a system of 30+ navigation satellites orbiting the earth. We know where
they are in space because they constantly transmit information about their
position and current time to Earth in the form of radio signals.
A GPS receiver listens to these signals. Once the receiver calculates its distance
from at least three GPS satellites, it can figure out where you are.
Hardware Overview
NEO-6M GPS Chip
At the heart of the module is a GPS chip from U-blox – NEO-6M. The chip measures less than
a postage stamp but packs a surprising amount of features into its tiny frame.
It can track up to 22 satellites over 50 channels and achieve the industry’s highest level of
tracking sensitivity i.e. -161 dB, while consuming only 45 mA current.
Unlike other GPS modules, it can perform 5 location updates in a second with 2.5m
horizontal position accuracy. The U-blox 6 positioning engine also has a Time-To-First-Fix
(TTFF) of less than 1 second.
One of the best features offered by the chip is Power Save Mode (PSM). This allows a
reduction in system power consumption by selectively switching certain parts of the receiver
on and off. This dramatically reduces the power consumption of the module to just 11mA
making it suitable for power sensitive applications such as GPS wristwatches.
The required data pins of the NEO-6M GPS chip are broken out to a 0.1″ pitch headers. It
contains the pins needed for communication with the microcontroller over the UART. The
module supports baud rates from 4800bps to 230400bps with a default baud of 9600.
NEO-6M Datasheet
Blink every 1s – Position Fix is found (the module can see enough satellites).
The logic pins are also 5-volt tolerant, so we can easily connect it to Arduino or any 5V logic
microcontroller without using a logic level converter.
The module also houses a rechargeable button battery that acts as a super-capacitor.
EEPROM and battery together help in retaining the BBR (Battery Backed RAM). BBR contains
clock data, latest position data (GNSS orbit data) and module configuration. But it is not for
permanent data storage.
The battery charges automatically when power is supplied to the module and retains data for
two weeks without power.
Since the battery retains the clock and last position data, Time-To-First-Fix (TTFF) is
significantly reduced to 1s. This allows much faster position locks. Without battery the GPS is
always cold-started and takes longer for the initial GPS lock.
Antenna
The module comes with -161 dBm sensitivity patch antenna for receiving radio signals from
GPS satellites.
You can snap-fit this antenna into the small U.FL connector located on the module.
The patch antenna is great for most of our projects. But if you want to get more sensitivity
and accuracy, you can also snap-on any 3V active GPS antenna.
U.FL connectors are small, delicate and are not rated for strain. To prevent damage
to the U.FL connection, you can thread the U.FL cable through the mounting hole.
GND is the ground pin and needs to be connected to the GND pin on the Arduino.
VCC supplies power to the module. You can connect it directly to the 5V pin on the
Arduino.
Begin by connecting the patch antenna to the U.FL connector. You can thread the U.FL cable
through one of the mounting holes.
The module usually comes with unsoldered header pins. So you will need to solder them first.
Next, connect the VCC pin to the 5V pin on the arduino and GND to ground.
Finally connect the Tx and Rx pins on the module to digital pins #2 and #3 respectively.
#include <SoftwareSerial.h>
void setup()
{
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(9600);
void loop()
{
// Displays information when new sentence is available.
while (gpsSerial.available() > 0)
Serial write(gpsSerial read());
Upload the program and open the Serial Monitor from the Arduino IDE. Remember to select
9600 baud. You should see text like the following:
NMEA Sentences
The data you are getting on the serial monitor are actually NMEA sentences.
NMEA is an acronym for National Marine Electronics Association. This is a standard message
format for almost all GPS receivers.
The NMEA standard is formatted in rows of data called sentences. Each sentence has
comma-separated data fields to make it easier to parse by computers and microcontrollers.
These NMEA sentences are sent at an interval called the update rate.
The NEO-6M GPS module updates this information once per second (1Hz frequency) by
default. But you can configure it for up to 5 updates per second (5Hz frequency).
There are many sentences in the NMEA standard. The most common are:
$GPRMC provides time, date, latitude, longitude, altitude, and estimated velocity.
$GPGGA sentence provides essential fix data which provides the 3D location and
accuracy data.
1 GPS fix
$GPRMC and $GPGGA are basic GPS NMEA sentences. There are many alternative and
companion NMEA sentences that provide similar or additional information. For more
information on other NMEA sentences, visit gpsinformation.org
Library Installation
Although the comma delimited format of NMEA sentences makes them extremely easy to
parse, there are libraries available that do the heavy lifting. One of the popular libraries is the
TinyGPS++ library. This is the library we will use in our examples.
TinyGPS++ library provides compact and easy-to-use methods for extracting position, date,
time, altitude, speed, and course from GPS devices.
This library is not included in the Arduino IDE, so you will need to install it first.
To install the library navigate to Sketch > Include Libraries > Manage Libraries… Wait for
Library Manager to download the library index and update the list of installed libraries.
Filter your search by typing ‘tinygpsplus‘. Click on the first entry and then select Install.
The following test sketch will print location information (latitude, longitude and altitude) and
UTC (date and time) to the serial monitor. Give the sketch a try before we explain it in some
detail.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
void setup()
{
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(9600);
void loop()
{
Code Explanation:
The sketch begins by including the newly installed TinyGPS++ library and the SoftwareSerial
library. Then those arduino pins are declared to which the NEO-6M GPS module is connected
and a variable that stores the default GPS baud rate.
Creating a TinyGPSPlus object will help access special functions related to the library. After
this we create a software serial port called gpsSerial through which we will talk to the
module.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
int RXPin = 2;
int TXPin = 3;
int GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial gpsSerial(RXPin, TXPin);
In the setup function, we initiate the serial communication with the PC as well as the GPS
module.
void setup()
{
Serial.begin(9600);
gpsSerial.begin(GPSBaud);
}
In the loop function, the displayInfo() custom function is called which prints location
information (latitude, longitude and altitude) and UTC (date and time) to the serial monitor,
each time a new NMEA sentence is encoded correctly.
If 5000 milliseconds elapse and no characters arrive at the software serial port, a ‘No GPS
detected’ error message is printed.
void loop()
{
while (gpsSerial.available() > 0)
if (gps.encode(gpsSerial.read()))
displayInfo();
gps.age() function tells how old an object’s data is. It returns the number of
milliseconds since its last update. If the value is 1500 or more, it may indicate a ‘lost fix’.
If you want to extract data from another NMEA sentence. You can use the library’s
custom extraction functionality by telling TinyGPS++ the name of the sentence and the
field number you are interested in. If you want to know the magnetic variation, for
example, you can call: TinyGPSCustom magneticVariation(gps, "GPRMC", 10); You
can then query it like this: magneticVariation.value()
U-center software
The U-center from u-blox is a powerful tool for the evaluation, performance analysis and
configuration of u-blox GPS receivers, including the NEO-6M. It is a free tool but it can be
used only on Windows platform.
It can display realtime structured and graphical data visualizations from any GPS receiver
such as:
U-Center
The image below shows the NEO-6M connected to the PC with the PL2303 USB to TTL
converter.
Using U-center
After a successful installation, U-Center can be started from the Start Menu (All Programs ->
u-blox-> u-center -> u-center), it will start up as shown below.
Locate the Communications toolbar and click the arrow next to the icon. This will show a list
of all available COM ports. Select the corresponding COM port where the receiver is
connected.
The Text Console button will show you the raw NMEA sentences. This is handy for quickly
inspecting visible ASCII coming from the module over USB.
For more information about U-center software, please refer this user guide.
SHARE