0% found this document useful (0 votes)
127 views

GPS Module Interfacing With ARM MBED - MBED

This document discusses interfacing a NEO-6M GPS receiver module with an ARM MBED microcontroller. It provides code to parse NMEA strings from the GPS module and display location, time, speed and satellite data on a serial monitor. The GPS module communicates via USART and outputs data like latitude, longitude, altitude and time in NMEA format, which the code example parses and prints out relevant information from.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

GPS Module Interfacing With ARM MBED - MBED

This document discusses interfacing a NEO-6M GPS receiver module with an ARM MBED microcontroller. It provides code to parse NMEA strings from the GPS module and display location, time, speed and satellite data on a serial monitor. The GPS module communicates via USART and outputs data like latitude, longitude, altitude and time in NMEA format, which the code example parses and prints out relevant information from.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GPS Module Interfacing with ARM MBED

NEO-6M GPS Receiver Module

Global Positioning System (GPS) makes use of signals sent by satellites in space and ground stations on Earth to accurately determine
its position on Earth.
The NEO-6M GPS receiver module uses USART communication to communicate with microcontroller or PC terminal.
It receives information like latitude, longitude, altitude, UTC time, etc. from the satellites in the form of NMEA string. This string needs to
be parsed to extract the information that we want to use.

For more information about GPS and how to use it, refer the topic GPS Receiver Module (http://electronicwings.com/sensors-modules/gps-
receiver-module) in the sensors and modules section.

Interfacing Diagram

Interfacing NEO-6M GPS Receiver Module With ARM MBED

Example
We are going to display data (latitude, longitude, altitude, speed, date, number of satellite, and time) received by the GPS receiver module on
the serial monitor.

Here, we will be using Edoardo De Marchi’s GPS_U-blox_NEO-6M_Test_Code library and code from MBED.

Download or import this library from here.  (https://os.mbed.com/users/edodm85/code/GPS_U-blox_NEO-6M_Test_Code/)

Note: The GPS may require some time to lock on to satellites. Give it around 20-30 seconds so that it can start giving you correct data. It
usually takes no more than 5 seconds to lock on to satellites if you are in an open space; but occasionally it may take more time (for example if
3 or more satellites are not visible to the GPS receiver).

Program
/*

* Author: Edoardo De Marchi

* Date: 22-08-14

* Notes: Firmware for GPS U-Blox NEO-6M

*/

#include "main.h"

void Init()

gps.baud(9600);

pc.baud(115200);

pc.printf("Init OK\n");

int main()

Init();

char c;

while(true)

if(gps.readable())

if(gps.getc() == '$'); // wait a $

for(int i=0; i<sizeof(cDataBuffer); i++)

c = gps.getc();

if( c == '\r' )

//pc.printf("%s\n", cDataBuffer);

parse(cDataBuffer, i);

i = sizeof(cDataBuffer);

else

cDataBuffer[i] = c;

void parse(char *cmd, int n)

char ns, ew, tf, status;

int fq, nst, fix, date; // fix quality, Number of satellites being tracked, 3D fix

float latitude, longitude, timefix, speed, altitude;

// Global Positioning System Fix Data

if(strncmp(cmd,"$GPGGA", 6) == 0)

sscanf(cmd, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%*f,%f", &timefix, &latitude, &ns, &longitude, &ew, &fq, &nst, &altitude)
pc.printf("GPGGA Fix taken at: %f, Latitude: %f %c, Longitude: %f %c, Fix quality: %d, Number of sat: %d, Altitude: %f M\n", timefix
}

// Satellite status

if(strncmp(cmd,"$GPGSA", 6) == 0)

sscanf(cmd, "$GPGSA,%c,%d,%d", &tf, &fix, &nst);

pc.printf("GPGSA Type fix: %c, 3D fix: %d, number of sat: %d\r\n", tf, fix, nst);

// Geographic position, Latitude and Longitude

if(strncmp(cmd,"$GPGLL", 6) == 0)

sscanf(cmd, "$GPGLL,%f,%c,%f,%c,%f", &latitude, &ns, &longitude, &ew, &timefix);

pc.printf("GPGLL Latitude: %f %c, Longitude: %f %c, Fix taken at: %f\n", latitude, ns, longitude, ew, timefix);

// Geographic position, Latitude and Longitude

if(strncmp(cmd,"$GPRMC", 6) == 0)

sscanf(cmd, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,,%d", &timefix, &status, &latitude, &ns, &longitude, &ew, &speed, &date);
pc.printf("GPRMC Fix taken at: %f, Status: %c, Latitude: %f %c, Longitude: %f %c, Speed: %f, Date: %d\n", timefix, status, lati
}

Output of Serial Monitor

You might also like