Search code examples
gpsraspberry-pi3stm32mbedadafruit

How to read Adafruit GPS Data with STM32?


I'm using a STM32 Nucleo-F334R8 board and a Ultimate GPS Breakout V3 from Adafruit.

What I'm trying to do is to read the GPS data with Putty on my computer using the serial communication.

At the end I want to get the GPS data on my F334R8 board and then send it to a RaspberryPi 3 with the serial communication. I'm having a lot of trouble so far, I'm coding on Mbed Compiler Online and every time I have the feeling to find a solution it gets worse.

Does anyone have a solution for me?

EDIT : Alright thank you! I'm also trying to send my received data to a Raspberry Pi 3 through serial communication. I have connected the D15 and D14 to the TX and RX of the Raspberry but when i'm using :

#include "mbed.h"
#include "MTK3339.h"

static int waitData = 0;
static MTK3339 gps(D8, D2);
static float latitude = 0;
static float longitude = 0;

Serial rasp(D15, D14); // D15 = RX, D14 = TX

static void dataAvailable() {
    waitData |= gps.getAvailableDataType();
}

int main(void) {

    gps.start(&dataAvailable, (MTK3339::NmeaGga|MTK3339::NmeaVtg));

    while(1) {
        while(waitData == 0);

        if ((waitData & MTK3339::NmeaGga) != 0) {
            waitData &= ~(MTK3339::NmeaGga);
            latitude = gps.getLatitudeAsDegrees();
            longitude = gps.getLongitudeAsDegrees();
            //printf("%f,%f\n", gps.getLatitudeAsDegrees(), gps.getLongitudeAsDegrees());
            //printf("lat = %f, long = %f",latitude, longitude); 
            rasp.printf("%f\n", latitude);           
        }  

        waitData &= (MTK3339::NmeaGga|MTK3339::NmeaVtg);
    }
}

But it's not working. I'm not receiving anything on the Raspberry console. Could someone help please?


Solution

  • Here's an example application which reads data of the GPS chip that's on the Adafruit board: https://os.mbed.com/users/embeddedartists/code/app_gps/

    Hook the GPS chip to the F334R8 board over UART on pins D8/D2 (D0/D1 are not usable for UART on that board as it's used for communication with the computer). Then change line 5 in main.cpp to:

    static MTK3339 gps(D8, D2);