STM32F0 and the GY-GPS6MV2 GPS receiver – Part 2!

As ever, the massive wealth of information on the internet and a bit of ingenuity of mine has lead to some improvements to my test application! Not only are all sentences sent from the module, received and stored in their corresponding buffers,  I’ve written a few functions to parse some of the useful sentenced, to get things like the time of fix, along with the latitude and long. I’ve also added functions to convert between the various forms of notation, namely NMEA style (received from the sentences), to decimal latitude and longitude, and finally, degrees, minutes and seconds format. Different formats are used in different situations though the decimal format is the most useful.

I’ve also included a function that gets the as the crow flies distance and bearing between two latitudes and longitudes, namely a source and destination. This function uses the Haversine method to calculate the distance as stated variously around the web. I got the formula from because it was one of the first hits on google! Various other websites will state the same formula. The function also returns the bearing between the source and destination, in degrees between 0 and 360.

As I’ve now got to use various trigonometric functions, I’ve had to include the standard C library which has boosted the size up dramatically so sorry about that!

I’ve taken a screen shot (blanking out my position of course!) of the kind of data you can expect from my code:

A couple of the parameters have been highlighted, namely a destination (the Trafford center, Manchester), the source (My current position though I’ve blanked out some of the fields!) and the distance and bearing between the two.

As per, the updated code can be found on my github!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s