Raspberry Pi – C GPS NMEA library (Global Positioning System)
23 November 2013
A couple of weeks ago I bought a Raspberry Pi and it is an interesting board: ARM processor, 512MB RAM (v2) and many other things like GPIOs. I want to realize something that works with GPS and IMUs. This board, with raspbian and other linux based os, is not an embedded system, is more like a general purpose computer but with more interesting possibilities. First of all: Go programming language is designed also for this kind of platforms (ARM based) and this open a wide set of incredible projects and with GPIOs we can communicate easily with different peripherals.
Golang is not only designed also for ARMs but it has a very wonderful integration with C programs and libraries. For that reason I have decided to decouple the problem of realize something that can use GPS and IMUs boards in 2 main parts. The “lower part” developed in C that communicate and abstract the data layer and the second part (the general program) in Golang.
I bought a GPS board (in particular the: Adafruit Ultimate GPS Breakout – 66 channel w/10 Hz updates – Version 3) that supports the NMEA standard and can provides updates at a good rates (10Hz).
Before start buying things I have written the C library that I will use as the base layer for GPS (you can find the project here: https://github.com/wdalmut/libgps). The goal of this project is to simplify all the operation around the GPS board, for example see a GPS data logger implementation (in C).
GPS Data logger in 3 lines of code
Before starting, remember that you have to use the serial port of Raspberry Pi not through the console but with a peripheral and for that reason you have to configure your pi board (follow the manual: Connect Raspberry Pi to a microcontroller or other peripheral)
You just need the main entry point:
That’s all! You have just to compile your program directly on the Raspberry Pi!
Now you have your compiled program (position_logger), run it!
You will see in the console something like this:
That’s all!! In just 3 lines of codes we have a GPS data logger!