GlobalSat EM 406 GPS Module

This is the GlobalSat EM-406 GPS module with serial interface.


Hello World!


#include "mbed.h"
#include "GPS.h"

Serial pc(USBTX, USBRX);
GPS gps(p9, p10);

int main() {
    while(1) {
        if(gps.sample()) {
            pc.printf("I'm at %f, %f\n", gps.longitude, gps.latitude);
        } else {
            pc.printf("Oh Dear! No lock :(\n");



1 related question:


20 Sep 2010

Might be handy to have functions to return time, date, heading, speed, and altitude.

06 Oct 2010

If you have a commercial serial GPS module available it can also be used on mbed with an RS-232 breakout board and perhaps a PS/2 breakout board. Some low cost serial GPS units such as the GlobalSat BR355 modules get 5V power only off of a PS/2 connector and the data comes out using an RS-232 serial connector. In the BR355 units, a special Y cable with both a PS/2 and a RS-232 serial connector is used. Depending on where it is purchased, this cable may need to be purchased separately from the GPS. These GPS units can cost a bit less (might cover most of the cost of breakout boards) and everything just plugs into a breadboard.


12 Oct 2010

Why does this get incorrect longitude results? can anyone help please

16 Oct 2010


There are two main co-ordinate representations I think; Degrees Minutes Seconds, and Decimal Degrees, and you can convert between them.

I converted it to the right co-ordinate system for google maps, which i think was decimal degrees. Maybe you are using the other system i.e. the raw data (or the calculation is incorrect)?

If you look at the GPS library source, there is a calculation to turn the co-ordinates from one type to another. Perhaps you could take them raw for your application, or perhaps update the library to support both.

05 Nov 2010


I was having similar problems with the longitude, getting positions out off the Pacific coast from here in the Midwest. I solved it by editing line 51 of GPS.cpp. You should see:

degrees = trunc(longitude / 100.0f * 0.01f);

and you should try changing it to:

degrees = trunc(longitude / 100.0f);

I'll probably do some more testing to see what exactly necessitates this change, but I'm guessing it has something to do with the length of the 'longitude' field that we're pulling out of the GPGGA sentence.

31 Jan 2011

incorrect longitude

measured data from EM-406 :224.961273

true data :135degree 37.657minute

why incorrect

latitude is true

25 Feb 2011

Hi all,

I see on your schema that only the TX is connected to the mbed (not the RX). That's true that it's only needed to received raw from the GPS... but why having a RX pin on the GPS then ? To send configuration ?


[edit] I see in the spec document : TX: This is the main transmits channel for outputting navigation and measurement data to user’s navigation software or user written software.

  • RX: This is the main receive channel for receiving software commands to the engine board from SiRFdemo software or from user written software.
18 Feb 2012


This is what the data looks like that I'm getting. As you can see with the GSA messages it is saying that lock is not available. I'm using this device outside with a clear sky and it is wired up exactly as shown in demonstration. Any ideas?

This is what it shows when I power cycle the gps.

$PSRFTXT,TOW:  594027*18
$PSRFTXT,WK:   1675*60
$PSRFTXT,POS:  6378137 0 0*2A
$PSRFTXT,CLK:  96250*25
$PSRFTXT,Baud rate: 4800*65
29 Feb 2012

I think my issue may be a power issue... I've eventually got it to lock but it seems random. One problem I am having is powering the device. I've tried using a 1cell LiPo they sell at spark fun and it is sketchy. Sometimes it works, sometimes it doesn't.

What is a good battery solution for the mbed?

30 Apr 2012


I am having the same problem as Tyler Weaver..

How to get a fix ? is this due to battery? i am running the gps receiver from the 3.3v output from mbed.

the receiver i am using is mediatek 3329

any help will be appreciated.


09 Jun 2012

The Lon and Lat in most NEMA cases are expressed as DDMM. MMMM where DD is Degrees (00 to about 90 for Lat and 000 to about 180 for Lon). The MM. MMMM is Minutes and fractions thereof.

28 Aug 2012

shahid darbar wrote:

mediatek 3329

If you haven't already solved this, you may want to check the data sheet. The V-backup pin is listed in the data as "must be held high for normal operation"... Just a thought.

18 Mar 2013

on the hello world program the coordinates shown are 0,0 even when there is no lock (led isn't flashing) has this happened to anyone else?

28 Nov 2013

can i use this code for vkel vk 162 GPS module? i try to connect vk 162 with mbed but the result is only error message (ovelflowed message)

28 Nov 2013

can i use this code for vk162 gps module?