Using the GPS on OzzMaker SARA-R5 LTE-M GPS + 10DOF

There are two methods of accessing the GNSS receiver on the OzzMaker SARA-R5 LTE-M GPS + 10DOF module;

  1. Using AT commands through the cellular module.
  2. Enabling multiplexing on the serial interface and then stream the GPS data to a dedicated virtual serial interface.

The second method is the preferred method as it will continuously stream the data to the virtual interface and you can use programs like gpsmon to read this information.

Using AT commands through the cellular module to access the GNSS receiver

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

Connect to the SARA-R5 cellular module

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

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

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

Now to configure the GNSS receiver.
First, we will activate the unsolicited aiding result.

AT+UGIND=1

Activate storing of the last value of a NMEA sentence

AT+UGRMC=1
AT+UGGLL=1
AT+UGGSV=1
AT+UGGGA=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

 

Start the GNSS with GPS+SBAS+GLONASS systems and local aiding.

AT+UGPS=1,1,67

You can now use the below commands to read the last NMEA sentence.

AT+UGRMC?
AT+UGGLL?
AT+UGGSV?
AT+UGGGA?

E.g. reading the last RMC sentence;

AT+UGRMC?
+UGRMC: 1,$GNRMC,005007.00,A,3343.22678,S,15224.63191,E,0.083,,310123,,,D*7E

Stream GNSS data to a dedicated interface

This is the preferred method of viewing NMEA sentences from the GNSS receiver, as the data will be stream continuously to a specific tty interface, which you can than use to point other programs to.

To be able to do this, multiplexing needs to be enabled between the Raspberry Pi and SARA-R5 module, you can follow this guide to enable this.

Once mutliplxiung is up and running, it is now time to tell the SARA-R5 module where to stream GNSS data.
Connect to the second mutlipler channel to perform AT commands to configure the SARA-R5

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

Use +UGPRF command to tell the module to send and receive GNSS data through the multiplexer

AT+UGPRF=2

Configure the dataflow on the SARA-R5 serial interface to the right varient

AT+USIO=2

Once this is done, you can continue on with configuring and enabling the GNSS receiver.
Activate the unsolicited aiding result

AT+UGIND=1

Activate storing of last value of NMEA

AT+UGRMC=1
AT+UGGLL=1
AT+UGGSV=1
AT+UGGGA=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

Start the GNSS with GPS+SBAS+GLONASS systems and local aiding.

AT+UGPS=1,1,67

 

You can no connect to /dev/ttyGSM3 to view the streaming NMEA sentences

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

gpsmon

You can now use /dev/ttyGSM3 with gpsmon.

Edit the config file so that gpsd uses the correct serial device

pi@raspberrypi ~ $ sudo nano /etc/default/gpsd

 

Look for
DEVICES=""
and change it to
DEVICES="/dev/ttyGSM3"

Reboot once you have updated the above file.

Python script

Below is a python script which will automation the above streaming configuration

 

#!/usr/bin/env python
import serial, time
port = "/dev/ttyGSM2"
PAUSE = 0.1
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(80)
    print "response", response
    time.sleep(PAUSE)
ser = serial.Serial(port, baudrate = 115200, timeout = 0.2)

sendCommand("AT+UGPRF=2")               #Configure multiplexer
sendCommand("AT+USIO=2")                #Configure serial interface varient

#Activate storing of last values of selected NMEA sentences from the GPS module
sendCommand("AT+UGGLL=1")               #Activate storing of last value of $GLL
sendCommand("AT+UGGSV=1")               #Activate storing of last value of $GSV
sendCommand("AT+UGGGA=1")               #Activate storing of last value of $GGA
sendCommand("AT+UGRMC=1")               #Activate storing of last value of $RMC
#Ennable communication betweenn GPS and GSM
sendCommand("AT+UGIND=1")               #Activate the unsolicited aiding result

''''
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 Autonomou'
[GNSS_systems]
 1: GPS
 2: SBAS
 4: Galileo
 8: BeiDo
 16: IMES
 32: QZSS
 64: GLONAS
 Examples;
 AT+UGPS=1,0,64         Turn on GNSS with no aiding and only use GLONASS
 AT+UGPS=0              Turn off GNSS
 AT+UGPS=1,2,67         Start the GNSS with GPS+SBAS+GLONASS systems and AssistNow Offline aiding
'''
#Turn on GNSS
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)
'''
time.sleep(PAUSE+3)

sendCommand("AT")

Other Information and Guides

Blip, blop, bloop...