TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle

GPS NMEA standard data parser for STM32Fxxx devices - More...


 Library private defines without any sense for USER.
 Library Typedefs.
 Library Functions.

Detailed Description

GPS NMEA standard data parser for STM32Fxxx devices -

This library parses response from GPS module, in NMEA statements format.

For more, how GPS returns data, look at link below:

There is a lot of possible sentences, which can be returned from GPS. This library uses only 4. But some GPS don't returns all of this 4 sentences, so I made a possibility to disable them.

By default, these statements are in use and supported:

By default, each of this data has to be detected in order to get "VALID" data. If your GPS does not return any of this statement, you can disable option. If you disable any of statements, then you will loose data, corresponding to statement.

Add lines below in your defines.h file and uncomment your settings

//Disable GPGGA statement
//Disable GPRMC statement
//Disable GPGSA statement
//Disable GPGSV statement

To communicate with GPS, USART is commonly used. By default, my library uses USART1, but if you want your own USARTx, add lines below in your defines.h file:


With default pinout:

STM32F4xx TX = PB6
STM32F4xx RX = PB7

Connect GPS's TX to STM32F4xx's RX and vice versa
Increase USART internal buffer

GPS library is based on USART library, which uses internal buffers to store data which are received but not read.

GPS receiver will send a lot of data at a time and if you are doing other stuff that time, it might happen that you will not so quickly update GPS data and buffer will overflow. Default buffer size is for my USART lib 32 bytes.

I recommend that you increase that memory. For further instructions how to do that, look at TM_USART module.

Distance and bearing

Distance between 2 points can not be provided from GPS receiver, so we have to calculate it. This is useful, if you have let’s say quadcopter and you want to know, how far you are from quad. First coordinate will be quad’s current position from GPS and second point will be set before you start with your flight.

If you want to make let’s say “Return home” function on quadcopter, bearing comes to be very useful. GPS module tells you your direction (included in library) where you are currently moving. Still, first coordinate is from quad’s GPS receiver, and second is where quad started with flight. When you activate “Return home” function, quad will know how far he is from “home” and in which direction (bearing) he has to move according to the north. Then, you just have to compare your calculated bearing with actual direction provided from GPS. And you will know, if he needs to go more left, right, etc. You can tune PID then according to values.

Custom GPS statements

Library supports by default 4 statements. It assumes that every GPS module should output these 4 statements. It may happen, that your module outputs data that you need, but are not available with my library by default.

Here is why custom GPS statements come handy. It is possible to define custom statements which will be parsed as strings from GPS receiver directly to user.

For example, let’s say that your module outputs $GPRMB sentence (navigation). From that statement, you want to get “Steering value”, which can be “L” or “R” for Left or Right. Steering value is part 3 inside GPRMB sentence. If you want to include this into your output, you can do this:

//Set variable
TM_GPS_Custom_t* GPRMB_3_Pointer;
//$GPRMB statement, term number 3 = Steering value
GPRMB_3_Pointer = TM_GPS_AddCustom(&GPS_Data, "$GPRMB", 3);

This statement is now added into main GPS_Data structure and also, pointer to small GPRMB.3 structure is returned.

You have to make sure, that in this case, GPRMB statement is really returned from module. If module will not return this statement, you will not be able to read anything from library, because it will never happen that everything will be updated before new data are available.
 Version 1.0
  - First release
 - STM32Fxxx HAL
 - defines.h
 - defines.h
 - math.h