Assisted GPS on OzzMaker SARA-R5 LTE-M GPS + 10DOF

Typically, a GPS module can take a few minutes to get  Time To First Fix(TTFF), or even longer if you are in  built up areas(+20mins).  This is because the Almanac needs to be downloaded from  satellites before a GPS fix can be acquired and only a small portion of the Almanac is sent in each GPS update.

Assisted GPS speeds this up significantly by  downloading  ephemeris, almanac, accurate time and satellite status over the network, resulting in faster TTTF, in a few seconds. This is very similar how to GPS works on a smartphone.

The OzzMaker SARA-R5 LTE-M GPS + 10DOF supports assisted GPS. The below video shows a comparison between assisted and normal GPS.

  • Assisted GPS takes 19secs to get a fix
  • Normal GPS takes 8min 22Sec to get a fix

 

How does the OzzMaker SARA-R5 LTE-M GPS + 10DOF do this?

This board has a u-Blox SARA-R5 module which includes both a cellular modem and GPS recevier.

The SARA-R5 can be configured to download GPS assist data and then pass this over the the GPS module.

This assist data is downloaded by the SARA-R5 modem (not the Pi), therefore the modem needs to create an internal PDP (Packet Data Protocol) connection.

Once the PDP connection is made, the SARA-5 will reach out to uBlox AssitNow servers and download the latest assist data. A valid token is needed to perform this, all OzzMaker SARA-R5 LTE-M GPS + 10DOF  have had this token pre-configured.

<
The first step is to setup your Pi to use a GPS. If you haven't already done so, you can follow this guide.

Second step is to enable multiplexing between the Raspberry Pi and SARA-R5, follow this guide.

Connect to the SARA-R5 cellular module

pi@raspberrypi ~ $ minicom 115200 -D /dev/ttyGSM1

Do a quick test, type AT and confirm you get OK as a response

From here, you can issue AT commands to configure or retrieve information from the SARA-R5 cellular module.

 

 

Setup the Packet Data Protocol (PDP) context.

First task is to setup the connection parameters for PDP context using +CGDCONT. Any setting applied with this commend is persistent over power cycles. This means it only needs to be done once. You will however need to enter it again if you do a factory reset.

First, turn off the radio

 AT+CFUN=0

Then set up a connection profile with the APN for your network operator, using the +CGDCONT  command (Packet Switch Data configuration). In this example we are using a Hologram SIM, so the APN would be hologram.

AT+CGDCONT=1,"IP","hologram"

Now turn the radio back on;

 AT+CFUN=1

Once your SARA-R5 connects to the carrier, you can use +CGDCONT? to get your current IP address

AT+CGDCONT?
+CGDCONT: 1,"IP","hologram.mnc050.mcc234.gprs","10.170.92.244",0,0,0,2,0,0,0,0,0,0,0

Now active the PDP context

AT+CGACT=1,1

Set the PDP type to IPv4

AT+UPSD=0,0,0

Profile #0 is mapped on CID=1

AT+UPSD=0,100,1

Activate the PSD profile

 AT+UPSDA=0,3

Your SARA-R5 should now have internet access.If you want to test data connection, you can use +UPING

AT+UPING="www.google.com"
OK
+UUPING: 1,32,"www.google.com","142.250.179.228",113,617
+UUPING: 2,32,"www.google.com","142.250.179.228",113,637
+UUPING: 3,32,"www.google.com","142.250.179.228",113,636
+UUPING: 4,32,"www.google.com","142.250.179.228",113,637

 

Configure GPS and start GPS

Time now to configure the GPS assist mode.
First, we will activate the unsolicited aiding result. Without this we will not know if the assisted GPS was successful;

 AT+UGIND=1

 

The +UGPS command is used to control the GPS module and the assist mode. Here is its syntax and options;
AT+UGPS=[mode],[aid_mode],[GNSS_systems]
[mode]
0 : Off
1 : On
[aid_mode]
0 (default value): no aiding
1: automatic local aiding
2: AssistNow Offline
4: AssistNow Online
8: AssistNow Autonomous
[GNSS_systems]
1: GPS
2: SBAS
4: Galileo
8: BeiDou
16: IMES
32: QZSS
64: GLONAS

To turn on GNSS with no aiding and only use GPS, you would use;

 AT+UGPS=1,0,1

To turn off GPS

 AT+UGPS=0

To enable GPS with online assistance, we use option 4 for aid mode. This is called AssitNow Online.

 AT+UGPS=1,4,1

 

To enable more than one GNSS mode, you need the algebraic sum of GNSS sytems. For example, to enable online assistance and use GPAS+GLONAS, you would use AT+UGPS=1,4,65. It is best to enable multiple GNSS  systems (GPS+SBAS+GLONASS+Galileo) with AT+UGPS=1,4,71.
Below is an example of the output when enabling assisted GPS (AssitNow Online);

AT+UGPS=1,4,71
OK
+UUGIND: 0,71
+UUGIND: 4,0

+UUGIND is the result indication for the +UGPS command. A result of 0 is no errors
+UUGIND: 0,71 the 0 here means no errors when enabling the multiple GNSS
+UUGIND: 4,0 The 0 here means no errors when downloading GPS assist data using AssitNow Online.

 

You can also configure assisted GPS from the bash terminal by using the commands below. As we are not looking at responses, there is no need to configure AT+UGIND=1 (enable error messages)

pi@raspberrypi ~ $ echo -e "AT+CFUN=0\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+CGDCONT=1,\"IP\",\"hologram\"\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+CFUN=1\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+CGACT=1,1\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+UPSD=0,0,0\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+UPSD=0,100,1\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+UPSDA=0,3\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+UGPS=1,4,71\r\n" > /dev/ttyGSM1
pi@raspberrypi ~ $ echo -e "AT+UGPS=1,4,71\r\n" > /dev/tttyGSM1

Below is an example of how this can be done using a python script.

#!/usr/bin/env python
import serial, time
port = "/dev/ttyGSM1"
PAUSE = 0.5
def sendCommand(command):
    command = command + "\r\n"
    ser.write(command)
    #ser.flush()
    output = ser.read_until()   # default is \n
    print "Command sent:", output.rstrip()     #rstrip will remove any trailing new lines or carriage return, this makes the output more readable
    #response = ser.read_until()
    response = ser.read(120)
    print "response", response
    time.sleep(PAUSE)
ser = serial.Serial(port, baudrate = 115200, timeout = 0.2)

sendCommand("AT+CFUN=0")                                #Turn off radio
sendCommand("AT+CGDCONT=1,\"IP\",\"hologram\"")         #Set the APN for network operator
sendCommand("AT+CFUN=1")                                #Turn on radio
time.sleep(2)
sendCommand("AT+UPSD=0,0,0")                            #Set the PDP type to IPv4
sendCommand("AT+UPSD=0,100,1")                          #Profile #0 is mapped on CID=1
sendCommand("AT+UPSDA=0,3")                             #Activate the PSD profile
time.sleep(2)
sendCommand("AT+UGPS=1,1,67")  #Start the GNSS with GPS+SBAS+GLONASS systems and local aiding.
'''
The above command will response with a response code indicating if there were any errors.
UUGIND: [aid_mode],[result]
[RESULT]
 0: No error
 1: Wrong URL (for AssistNow Offline)
 2: HTTP error (for AssistNow Offline)
 3: Create socket error (for AssistNow Online)
 4: Close socket error (for AssistNow Online)
 5: Write to socket error (for AssistNow Online)
 6: Read from socket error (for AssistNow Online)
 7: Connection/DNS error (for AssistNow Online)
 8: File system error
 9: Generic error
 10: No answer from GNSS (for local aiding and AssistNow Autonomous)
 11: Data collection in progress (for local aiding)
 12: GNSS configuration failed (for AssistNow Autonomous)
 13: RTC calibration failed (for local aiding)
 14: feature not supported (for AssistNow Autonomous)
 15: feature partially supported (for AssistNow Autonomous)
 16: authentication token missing (required for aiding for u-blox M8 and future versions)
'''

 

Other Information and Guides

Blip, blop, bloop…