Library for Libelium’s GPS module

I have been a little slow the last two months in reporting about my Xmass presents. Being on parental leave but being forced to arrange the moving of my lab to a new building seem to be two incompatible actions, but they are perfectly possible here in Sweden.

GPS on Mega

(c) 2009 BlushingBoy, GPS Shield on Arduino Mega

Leaving excuses on the side, I got a little jealous about Tom posting how he uses the Mega; therefore I decided to push a little harder for a library I am writing for the guys at Libelium. They sent me their GPS module and I decided to make a simple wrapper for users to plug their Tyco-GPS modules to Arduino Diecimila/Duemilanove/Mega from Arduino’s IDE 13/14/15. This is how much the whole thing has evolved since I started writing this piece of code in January… every time I thought I was done, we would release a new board or a new IDE and I had to debug the thing.

The library is running on a modified version of SoftwareSerial, and uses two functions by M. Hart, who wrote the brilliant tinyGPS library. My goal was to make something where unexperienced users would just have to write something like “GPS.init()” and “Serial.println(GPS.getLongitude())” and the thing would just work. Depending on how much you use the serial communication, this library weights between 4KB and 9KB … but it does everything for you ;-) On the other hand, on the Arduino Mega, 9KB is not even 10% of the available memory space. Download the library directly from this link.

GPS on Duemilanove

(c) 2009 BlushingBoy, GPS Shield on Arduino Duemilanove

I crafted three examples (basic, medium, advanced) featuring the use of different techniques to parse the GPS sentences. If you write something like a data logger, or a GPS toy, post your link here and I will be more than happy to include your code in the next revision of the library. Of course, if you found any errors or made any improvements, do the same thing.

This code compiles for Duemilanove and Mega, without any alterations. It works fine with the processors ATmega168 and up. Uses about 300 Bytes of memory space and is documented inside the code. Ah … there is a README.txt you shouldn’t miss; it explains how NOT to use the library.

[NOTE: If you are a linux user, please remember there is a bug in GCC-AVR that affects the way long ints are multiplied and this library makes an extensive use of that type of numbers. Please, read this note on Arduino's playground and upgrade!!]

8 Responses to “Library for Libelium’s GPS module”

  1. Helvis Says:

    Hi….
    I received today my shield and tried it with Arduino Diecimila. Works great. I only have some doubts with the third example about what means each one of the arguments. Have to read the rest of the specs.
    Now I am going to apply it to a robot and to use the gps info to produce some visuals.
    Thanks for the great work.
    HD

  2. Weekly Shared Items - 24. April, 2009 | toxin 2.0 - weblog of a german design student from wuerzburg Says:

    [...] Library for Libelium’s GPS module [...]

  3. dcuartielles Says:

    Hej Helvis,

    the third example is just parsing the GPS data into different arguments as specified in the datasheet to the GPS module. It is actually the standard way GPS data is stored in a string. This means:

    - arguments[0] is always the GPS sencence type, e.g. GPGGA, GPRMC, GPVTG …
    - arguments[1..12] are each one of the parts coming in the GPS sentence separated by commas. They depend on each one of the strings

    If you are just interested in getting the speed, you could call the function GPS.getSpeed() and it will answer with an integer for the speed in Km/h. I think I actually forgot to mention that in the examples. For the location there is GPS.getLocation() and so on.

  4. carlos Says:

    Hi,

    I have a Arduino Duemilanove connected to a Libelium GPS (http://www.libelium.com/tienda/catalog/product_info.php?cPath=21&products_id=37).
    I am accessing the GPS through the LB_GPS library Version 01a
    I am developing a small program (I am quite noob with Arduino) to read the data from the GPS and to show it in a LCD display.
    While I am connected to the computer through the USB port everything the GPS seems to work fine, I receive NMEA strings as expected.
    The problem comes when I want to power the system through batteries, not through the USB port.
    I disconnect the USB cable, reset the Arduino and everything goes running until the program tries to read data from the GPS. Then it is blocked.
    The following code shows what happens: working with a USB connection you can see at the display the strings “GETRAW IN” and “GETRAW OUT” swapping every 5 seconds approx.
    When the Arduino is powered through batteries the display shows one time “GETRAW IN” and the program hangs.

    Any idea on where is the problem?

    Thanks in advance

    =============
    #include
    #include

    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

    void setup()
    {
    GPS.init();
    delay(100);

    lcd.begin(16,2);

    }

    void loop()
    {
    Visualiza(“GETRAW IN “);
    GPS.getRaw(100); // reads the GPS string and stores it in inBuffer
    Visualiza(“GETRAW OUT “);
    }

    void Visualiza(const char *s1)
    {
    lcd.setCursor(0,0);
    lcd.print(buf1);
    lcd.setCursor(0,1);
    lcd.print(” “);

    delay(5000);
    }
    =============

  5. antonio Says:

    Estoy intentando conectar una duemilanove con el gps. He cambiado los pines 8 y 9 por el 1 y 0 de la librería. Sólo me aparace : setting up gps… done! pero no recibo nada más. Alguien me puede ayudar

  6. antonio Says:

    Ya funciona.

  7. Alejandro Says:

    Antonio,
    A mí me ocurre lo mismo, ¿cómo lo arreglaste?

  8. antonio Says:

    Es por que no conecta con los satélites. Mete el módulo y el arduino en una fiambrera y lo pones en la calle sin que le haga sombra ningún edificio

Leave a Reply