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

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

Note:

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

Note:

  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) {
            myled=0;
            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);
            wait(1);
        } else {
            myled=1;
        }
    }
}</p>

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.

Note:

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

Be the First to Share

    Recommendations

    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge
    • Backyard Contest

      Backyard Contest

    4 Discussions

    0
    leo.gracia970607
    leo.gracia970607

    10 months ago

    mistuve probando el codigo tal cual lo tiene el, y funciona perfectamente, gracias amigo !
    La idea es conectar tal cual en la imagen de arriba el TX de la placa con el RX del modulo GPS, y el TX del modulo GPS con el RX de la placa stm32!.
    el modulo hay que conectarlo a 3.3 voltios como se indica y dejarlo conectado de cinco a diez minutos hasta que coja señal.
    para saber si el modulo gps tiene señal, es porque el modulo gps empieza a prender y a apagar un led del mismo modulo.
    si el modulo no les coge señal, toca que lo squen por la ventana un momento hasta que coja señal y listo.

    0
    NatchapatM
    NatchapatM

    Question 1 year ago on Step 3

    about my case ; Serial port display latitude & longitude = 0.00

    i dont understand that why serial port display like that ?

    Capture.PNG
    0
    kfmurphy
    kfmurphy

    3 years ago

    Hi - I'm wondering why you connect the "NEO 6M Rx" pin, as your code only appears to be listening to the GPS device (not configuring). Am I missing something? I ask because I need to wire functions to configure the GPS device, and it does not appear your project does that, correct? Thank you.

    0
    sa163
    sa163

    3 years ago

    Hi,

    I am using the stm32 L476rg neucleo board. I cant get this code to work for my gps neo6m module. Could you be kind enough as to let me know what could i be doing wrong??

    thanks in advance