Get a GPS fix in seconds using assisted GPS on a Raspberry Pi with a BerryGPS-GSM

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 BerryGPS-GSM 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 BerryGPS-GSM do this?

The two main components on the BerryGPS-GSM are;

The SARA-U201 can be configured to download GPS assist data and then pass this over the the GPS module. These two components speak to each other via i2c.

This assist data is downloaded by the SARA-U201 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-U201 will reach out to uBlox AssitNow servers and download the latest assist data. A valid token is needed to perform this, all BerryGPS-GSM have had this token pre-configured.

How to enable assisted GPS

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

Now connect to the SARA-U201 serial console on /dev/ttyACM1

pi@raspberrypi ~ $ minicom -b 115200 -o -D /dev/ttyACM1

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

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


The syntax for the above command is:
AT+UPSD=[profile_id],[param_tag], [param_val]
We are using profile '0'
Parameter tag 1 is used to set APN name
Parameter value is the APN name
Parameter tags 2 and 3 are username and password, if you need to set these values, you can use these commands.

 AT+UPSD: 0,2,"username"
 AT+UPSD: 0,3,"password"

If using a Hologram SIM, a username and password is not needed.

We now will create a connection using the Packet Switch Data Action (UPSDA)command;


We are using profile 0
The two actions we are interested in are;
3: activate; activates a PDP context with the specified profile, using the current parameters
4: deactivate; deactivates the PDP context associated with the specified profile.

If everything worked, you should just get an OK response.

You can use the +UPSND command to read the current network negotiated values, like IP address and DNS.

Here we are checking to see if the profile '0' is active. If profile is active the return value is 1, otherwise it is 0;


To check IP address;


Check DNS entry 1;


Check DNS entry 2;



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;



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

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


To turn off GPS


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



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);

+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.

To summarize, only four commands are needed to get assisted GPS working;

Connect to carrier
Enable error messages
Activate GPS and use assisted GPS

You can also configure assisted GPS from the bash terminal by using the three 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+UPSD=0,1,\"hologram\"\r\n" > /dev/ttyACM1
pi@raspberrypi ~ $ echo -e "AT+UPSDA=0,3" > /dev/ttyACM1
pi@raspberrypi ~ $ echo -e "AT+UGPS=1,4,71\r\n" > /dev/ttyACM1

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

#!/usr/bin/env python
import serial, time

port = "/dev/ttyACM1"
PAUSE = 0.1

def sendCommand(command):
    command = command + "\r\n"
    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 =
    print "response", response

ser = serial.Serial(port, baudrate = 115200, timeout = 0.2)

sendCommand("AT+UPSD=0,1,\"hologram\"")  	#Set APN
sendCommand("AT+UPSDA=0,3\r\n")			#Activate connection to carrier
time.sleep(PAUSE+3)				#Give the modem time to connect
sendCommand("AT+UGIND=1")			#Activate the unsolicited aiding result
sendCommand("AT+UGPS=1,4,71")  			#Turn on GNSS with online assistance and  use GPS+SBAS+GLONASS+Galileo

Other Guides and Tutorials for BerryGPS-GSM

One thought on “Get a GPS fix in seconds using assisted GPS on a Raspberry Pi with a BerryGPS-GSM”

  1. Does the BERRYGPS-IMU support Assisted GPS via the pi's internet connection? If so, how would I go about downloading and using that data?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.