Code examples and extended information

In the Waspmote Development section you can find complete examples:

https://development.libelium.com/waspmote/code-examples

Example:


#include \
// define GPS timeout when connecting to satellites
// this time is defined in seconds (240sec = 4minutes)
#define TIMEOUT 240
// define status variable for GPS connection
bool status;
void setup()
{
    // Open USB port
    USB.ON();
    USB.println(F(\"GPS_1 example\"));
    // Set GPS ON
    GPS.ON();
}
void loop()
{
    ///////////////////////////////////////////////////
    // 1. wait for GPS signal for specific time
    ///////////////////////////////////////////////////
    status = GPS.waitForSignal(TIMEOUT);
    if( status == true )
    {
        USB.println(F(\"\n----------------------\"));
        USB.println(F(\"Connected\"));
        USB.println(F(\"----------------------\"));
    }
    else
    {
        USB.println(F(\"\n----------------------\"));
        USB.println(F(\"GPS TIMEOUT. NOT connected\"));
        USB.println(F(\"----------------------\"));
    }
    ///////////////////////////////////////////////////
    // 2. if GPS is connected then get position
    ///////////////////////////////////////////////////
    if( status == true )
    {
        USB.println(F(\"\nGET POSITION:\"));
        // getPosition function gets all basic data
        GPS.getPosition();
        // Time
        USB.print(F(\"Time [hhmmss.sss]: \"));
        USB.println(GPS.timeGPS);
        // Date
        USB.print(F(\"Date [ddmmyy]: \"));
        USB.println(GPS.dateGPS);
        // Latitude
        USB.print(F(\"Latitude [ddmm.mmmm]: \"));
        USB.println(GPS.latitude);
        USB.print(F(\"North/South indicator: \"));
        USB.println(GPS.NS_indicator);
        //Longitude
        USB.print(F(\"Longitude [dddmm.mmmm]: \"));
        USB.println(GPS.longitude);
        USB.print(F(\"East/West indicator: \"));
        USB.println(GPS.EW_indicator);
        // Altitude
        USB.print(F(\"Altitude [m]: \"));
        USB.println(GPS.altitude);
        // Speed
        USB.print(F(\"Speed [km/h]: \"));
        USB.println(GPS.speed);
        // Course
        USB.print(F(\"Course [degrees]: \"));
        USB.println(GPS.course);
        USB.println(\"\nCONVERSION TO DEGREES (USEFUL FOR INTERNET SEARCH):\");
        USB.print(\"Latitude (degrees):\");
        USB.println(GPS.convert2Degrees(GPS.latitude, GPS.NS_indicator));
        USB.print(\"Longitude (degrees):\");
        USB.println(GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator));
    }
    delay(5000);
}

Last updated