Initialization

Initializing the GPS module

GPS module is connected to a multiplexer, due to GPRS module and 3G/GPRS module are connected to the same microcontroller UART. To start using GPS module, this multiplexer is switched on and the right combination for GPS is selected.

When the module is switched on, the OSP sentence "PSRF150,1\3E*" is received, which means the module is ready.

After the communication with the GPS is available, some initial values are used by the init() function, to set the initial position of the GPS module. The default values of these variables are set in the constructor. The default position is set on Zaragoza (Spain) and the user can modify them to set other location.

All the necessary configuration for a right GPS initialization is done by the ON() function.

Example of use:

{
    GPS.ON(); // Turn it on, open the UART and executes the init process
}

Switching GPS off

It turns GPS off and closes the UART

Example of use:

{
    GPS.OFF(); // Turns it off and closes the UART
}

Wait for signal connection

Once the GPS is set on, it is necessary to wait for signal connection. The function in charge of this duty is waitForSignal().

This function waits to connect to satellites for a specific time. The default time to wait for signal connection is 60 seconds. But another time can be specified. If the GPS module connects to satellites, the function returns successfully. If the GPS does not connect to satellites for the specified time, then returns error.

It returns '1' if the GPS has connected within the period of time and '0' if not.

Example of use:

{
    // define timeout
    #define GPS_TIMEOUT 200
    // wait to connect for a maximum time of 200 seconds
    bool status = GPS.waitForSignal(GPS_TIMEOUT);
    if(status == true)
    {
        // connected
    }
    else
    {
        // not connected
    }
}

Setting the GPS Power Mode

The function setMode() sets the current internal Power Mode on the GPS. The GPS module has two different power modes: GPS_ON and GPS_OFF. This function is used by default inside ON() and OFF() functions.

The function will set up the pwrMode variable to one of the two values.

Example of use:

{
    GPS.setMode(GPS_ON); // Set GPS on
    GPS.setMode(GPS_OFF); // Set GPS off
    GPS.getMode(); // Get GPS power mode
}

Related variables:

GPS.pwrMode → stores GPS power mode

Setting the UART communication

There are a couple of functions to control the state of the microcontroller\'s UART. But it is recommended to use both ON() and OFF() functions to switch on/off the GPS module and open/close the microcontroller\'s UART at the same time.

Open UART

It opens the UART the GPS module is connected to.

Example of use:

{
    GPS.begin(); // open UART
}

Close UART

It closes the UART the GPS module is connected to. It implies the disconnection of the internal UART drivers inside the ATMEGA1281 processor.

Example of use:

{
    GPS.close(); // close UART
}

Setting the communication mode

Sets the communication mode: binary or NMEA. By default, the GPS module starts using NMEA mode.

The possible values have been defined in previous chapters.

Returns '1' if success and '0' if not.

Example of use:

{
    GPS.setCommMode(OSP_MODE); // Sets binary mode
    GPS.getCommMode(); // gets the communication mode
}

Related variables:

GPS.commMode → stores communication mode established in the GPS module

Last updated