Building Library for NEO-6M GPS Part 1: Introduction and Environment Setup

The NEO-6M GPS module is a popular and cost-effective solution for adding location tracking to embedded systems. This guide demonstrates how to interface the NEO-6M with the STM32F411-Nucleo64 board and display GPS data on a 1602 LCD. In part one, we shall take a look at the sensor, hardware setup and STM32CubeIDE setup.

In this guide, we shall cover the following:

  • What is GPS.
  • NEO-6M GPS module.
  • Hardware connection.
  • STM32CubeIDE setup.

1. What is GPS:

Humans have looked to the skies to find their way since ancient times. Ancient sailors used the constellations in the night sky to figure out where they were and where they were going.

Today, all we need is a simple hand-held GPS (short for Global Positioning System) receiver to figure out exactly where we are anywhere in the world. But we still need objects high in the sky to figure out where we are and how we get to other places.

Instead of stars, we use satellites. Over 30 navigation satellites are zipping around high above Earth. These satellites can tell us exactly where we are.

What is GPS?

The Global Positioning System (GPS) is made up of satellites, ground stations, and receivers.

GPS is a system. It’s made up of three parts: satellites, ground stations, and receivers.

Satellites act like the stars in constellations—we know where they are supposed to be at any given time.

The ground stations use radar to make sure they are actually where we think they are.

A receiver, like you might find in your phone or in your parents car, is constantly listening for a signal from these satellites. The receiver figures out how far away they are from some of them.

Once the receiver calculates its distance from four or more satellites, it knows exactly where you are. Presto! From miles up in space your location on the ground can be determined with incredible precision! They can usually determine where you are within a few yards of your actual location. More high-tech receivers, though, can figure out where you are to within a few inches!

The ancient sailors of history would be flabbergasted by the speed and ease of pinpointing your location today.

GPS in everyday life

Space Place in a Snap logo

There’s a whole lot of important things GPS is used for—but perhaps nothing is more important than finding the quickest slice of pizza!

Source: NASA website : here

2. 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 sentences2

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 ModuleWiring to Arduino UNO
VCC5V
RXNot used in this guide
TXPA10 of STM32F4
GNDGND

Understanding NMEA Sentences

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

$GPGGA,110617.00,41XX.XXXXX,N,00831.54761,W,1,05,2.68,129.0,M,50.1,M,,*42
$GPGSA,A,3,06,09,30,07,23,,,,,,,,4.43,2.68,3.53*02
$GPGSV,3,1,11,02,48,298,24,03,05,101,24,05,17,292,20,06,71,227,30*7C
$GPGSV,3,2,11,07,47,138,33,09,64,044,28,17,01,199,,19,13,214,*7C
$GPGSV,3,3,11,23,29,054,29,29,01,335,,30,29,167,33*4E
$GPGLL,41XX.XXXXX,N,00831.54761,W,110617.00,A,A*70
$GPRMC,110618.00,A,41XX.XXXXX,N,00831.54753,W,0.078,,030118,,,A*6A 
$GPVTG,,T,,M,0.043,N,0.080,K,A*2C

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:

$GPGGA,110617.00,41XX.XXXXX,N,00831.54761,W,1,05,2.68,129.0,M,50.1,M,,*42
  • 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.

3. Hardware Setup:

The connection as following:

STM32F411RE Nucleo64NEO-6M Module
5V or 3V3Vcc
GNDGND
PA10 (D2 Arduino pin)Tx
No connectionRx

For the LCD setup, please refer to this guide here:

4. STM32CubeIDE Setup:

Open STM32CubeIDE after selecting the workspace and create new project as following:

Select the MCU:

Give the project a name:

In the CubeMX window, enable the following GPIOs as output:

Give each GPIO a name as shown in the figure above.

Thats for setup of LCD.

For NEO-6M GPS, Enable USART1 and set baudrate to 9600 and this will set PA9 and PA10 for UART as following:

Next, from NVIC Settings of USART1, enable USART1 Global Interrupt as following:

From Project Manager tab, select Code Generation and enable Generate peripheral initialization as pair of .c/.h files per peripheral as following:

Save the project this will generate the project.

Stay tuned for part 2.

Happy coding 😉

Add Comment

Your email address will not be published. Required fields are marked *