Introduction: STM32F103: GPS NEO 6M (using Mbed.h)

In this tutorial, we will be interfacing GPS NEO 6M Module with STM32F103 using mbed online Compiler.

This tutorial is divided into following steps:

  1. Setting up Hardware
  2. Coding
  3. Visualizing the output


Step 1: Setting Up Hardware

Setting up Hardware For NEO 6M is very Easy. Make Connection as described below:

  1. NEO 6M Vcc -> Nucleo 3.3V (DONT Connect to 5V!)
  2. NEO 6M Rx -> Nucleo D8
  3. NEO 6M Tx -> Nucleo D2
  4. NEO 6M GND -> Nucleo GND


  1. Don't connect your NEO 6M Vcc to 5V! Never!

Step 2: Coding...

Open up and Sign In to mbed Compiler. Click NEW. Make sure that NUCLEO-F103EB Platform is selected. From template select 'Blinky LED Hello World". Enter Program Name and click OK. Now, right click on your program name folder and click select Import lirary->From Import Wizard. Now, Search For "Thanawat Phattaraworamet" Only one library will appear. Like show in Figure Above. Drag it and Drop it onto your program name folder. Now, open main.cpp file and remove all the code written there.

<p>#include "mbed.h"<br>#include "GPS.h"</p><p>Serial pc(SERIAL_TX, SERIAL_RX);
GPS ark(PA_9, PA_10);
DigitalOut myled(LED1);</p><p>int main()
    while(1) {
        if( ark.sample() == 1) {
            float latitude = ark.latitude;
            float longitude = ark.longitude;
            float utc = ark.utc+50000;
            pc.printf("latitude: %0.2f, longitude: %0.2f, utc: %f\r\n",latitude,longitude,utc);
        } else {

Copmile and Download the .bin file to Nucleo Board

Step 3: Visualizing the Output

Open a Serial Port communication window on COM port on which your STM board is connected.

If your GPS is connected, the LED will turn OFF and you will see values being displayed on the screen.

If your GPS is not connected, the LED will turn ON indicating that GPS is not connected.


  1. The latitude and longitude being displayed are according to GPS System.