Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
OzzMaker
Published

Get a GPS Fix in Seconds Using Assisted GPS

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

IntermediateProtip1 hour5,278
Get a GPS Fix in Seconds Using Assisted GPS

Things used in this project

Story

Read more

Code

Python code to enable assisted GPS on BerryGPS-GSM

Python
Python code to enable assisted GPS on BerryGPS-GSM
#!/usr/bin/env python
import serial, time
 
port = "/dev/ttyACM1"
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+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

Credits

OzzMaker
6 projects • 1 follower

Comments