RPi2 with GPS module(u-blox NEO-6M)
HW connection
PRi2 -- u-blox NEO-6M
VCC -- VCC(3v3 / 5V)
TX(GPIO8) -- Rx
Rx(GPIO10) -- Tx
Gnd -- Gnd
or
CP2102 -- u-blox NEO-6M
VCC -- VCC(3v3 / 5V)
TX -- Rx
Rx -- Tx
Gnd -- Gnd
Software
- Install raspbian
- Install tools
- scons-2.3.4
- gpsd-3.14
- sudo apt-get install scons libncurses5-dev python-dev pps-tools python-gobject python-gtks-dev
- sudo apt-get install gpsd gpsd-clients python-gps
- TTY issue
- RPi dominate /dev/ttyAMA0 as default serial console
- Vi /etc/inittab
#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
to:
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
- Vi /boot/cmdline.txt
- Remove “console=ttyAMA0,115200 kgdboc=ttyAMA0,115200”
- And, it would be looks like,
- dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
- Notes
- If your gpsd controled by systemctl
- edit /etc/default/gpsd and modify the DEVICES as you want
# Default settings for gpsd.
# Please do not edit this file directly - use `dpkg-reconfigure gpsd' to
# change the options.
START_DAEMON="true"
GPSD_OPTIONS=""
DEVICES="/dev/ttyAMA0"
USBAUTO="true"
GPSD_SOCKET="/var/run/gpsd.sock"
- It only starts working after gpsd attempts 4800, 9600, 19200 then finally 38400
- Solved by
- stty speed 115200 </dev/ttyAMA0
- Run
- sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
Result
First, you need to run gpsd with ur GPS module
connected by TTY serial, gpsd /dev/ttyAMA0
connected by USB, gpsd /dev/ttyUSB0
Grab geo info by gpspipe
#!/bin/bash
gpsdata=$( gpspipe -w -n 10 | grep -m 1 lon )
lat=$( echo "$gpsdata" | jsawk 'return this.lat' )
lon=$( echo "$gpsdata" | jsawk 'return this.lon' )
echo "You are here: $lat, $lon - https://maps.google.com/maps?q=$lat,+$lon"
Reference