Address
304 North Cardinal St.
Dorchester Center, MA 02124

Work Hours
Monday to Friday: 7AM - 7PM
Weekend: 10AM - 5PM

Raspberry Pi GPS

Raspberry Pi GPS – Easy Value-Add to Wireless Engagements

During a wireless engagement awhile back, I decided to test out a Raspberry Pi GPS solution.

Raspberry Pi GPS – Introduction

I can’t find the exact link to what I used, but it was something like this GlobalSat BU-353-S4 USB GPS Receiver.

My initial goal was to have some sort of heat-map with the airodump ‘-gpsd’ flag, but was never able to get this working.

That said, I had plenty of gear to use during my engagement, so things went fairly well. I still plan on eventually releasing my slides/notes/image for my WiFiPi, so stay tuned for that.

Raspberry Pi GPS - Gear setup

More wireless gear

Let me know if you have any suggestions for packages or tools to map out the information that I collected this way!

YouTube Version of this Post

If you prefer video and audio over just reading the text, then you can find the YouTube version of this post below.

That said, don’t forget to hit those like and subscribe buttons to help support the blog and channel!

Installation and Configuration

First, I installed the gpsd packages as well as the python-gps package.

root@raspberrypi:~# apt-get install gpsd gpsd-clients python-gps
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gpsd is already the newest version (3.16-4).
gpsd-clients is already the newest version (3.16-4).
python-gps is already the newest version (3.16-4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Next, I connected the USB GPS receiver, and was ready to collect data.

Pi GPS setup

Troubleshooting

First, when I tried to run cgps, I was not receiving any data.

root@raspberrypi:~# gpsd -nN /dev/ttyACM0 /var/run/gpsd.sock 
gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:ERROR: can't bind to IPv6 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
root@raspberrypi:~# cgps -s
�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"�    Time:       n/a                �"��"�PRN:  Elev:  Azim:  SNR: Used: �"�
�"�    Latitude:   n/a                �"��"�                               �"�
�"�    Longitude:  n/a                �"��"�                               �"�
�"�    Altitude:   n/a                �"��"�                               �"�
�"�    Speed:      n/a                �"��"�                               �"�
�"�    Heading:    n/a                �"��"�                               �"�
�"�    Climb:      n/a                �"��"�                               �"�
�"�    Status:     NO FIX (0 secs)    �"��"�                               �"�
�"�    Longitude Err:   n/a           �"��"�                               �"�
�"�    Latitude Err:    n/a           �"��"�                               �"�
�"�    Altitude Err:    n/a           �"��"�                               �"�
�"�    Course Err:      n/a           �"��"�                               �"�
�"�    Speed Err:       n/a           �"��"�                               �"�
�"�    Time offset:     n/a           �"��"�                               �"�
�"�    Grid Square:     n/a           �"��"�                               �"�
�""�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��""�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�

After my searching, I found a few posts describing similar issues to what I was seeing:

Finally, I stopped the service and properly set the TTY and the control socket.

root@raspberrypi:~# service gpsd stop
root@raspberrypi:~# gpsd -nN /dev/ttyACM0 /var/run/gpsd.sock &
[1] 1080
root@raspberrypi:~# gpsd:ERROR: device open of /var/run/gpsd.sock failed: No such device or address - retrying read-only
gpsd:ERROR: read-only device open of /var/run/gpsd.sock failed: No such device or address
gpsd:ERROR: initial GPS device /var/run/gpsd.sock open failed
gpsd:ERROR: device open of /var/run/gpsd.sock failed: Permission denied - retrying read-only
gpsd:ERROR: read-only device open of /var/run/gpsd.sock failed: Permission denied
gpsd:ERROR: /var/run/gpsd.sock: device activation failed.
gpsd:ERROR: /var/run/gpsd.sock: activation failed, freeing device
root@raspberrypi:~# systemctl stop gpsd.socket 
root@raspberrypi:~# systemctl disable gpsd.socket 
Removed /etc/systemd/system/sockets.target.wants/gpsd.socket.
root@raspberrypi:~# gpsd /dev/ttyACM0 -F /var/run/gpsd.sock 
root@raspberrypi:~# cgps -s
cgps: GPS timeout

Working and Data Collecting

With everything properly configured, I was able to use gpsmon to finally collect some data.

root@raspberrypi:~# gpsmon /dev/ttyACM0 
/dev/ttyACM0 9600 8N1         NMEA0183> 
�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"�Time: n/a                      Lat: n/a               Lon: n/a            �"�
�""�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"� Cooked TPV �"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"� GPTXT GPRMC GPVTG GPGGA GPGSA GPGSV GPGLL                                �"�
�""�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"� Sentences �"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"�Ch PRN  Az El S/N �"��"�Time:                   �"��"�Time:                   �"�
�"� 0   8   0  0  21 �"��"�Latitude:               �"��"�Latitude:               �"�
�"� 1  10   0  0  19 �"��"�Longitude:              �"��"�Longitude:              �"�
�"� 2  14   0  0  21 �"��"�Speed:                  �"��"�Altitude:               �"�
�"� 3  15   0  0  21 �"��"�Course:                 �"��"�Quality:   0   Sats: 00 �"�
�"� 4                �"��"�Status:    V   FAA: N   �"��"�HDOP:      99.99        �"�
�"� 5                �"��"�MagVar:                 �"��"�Geoid:                  �"�
�"� 6                �"��""�"��"��"��"��"��"��"��"��"��"��"� RMC �"��"��"��"��"��"��"��"��"��""�"��"��"��"��"��"��"��"��"��"��"� GGA �"��"��"��"��"��"��"��"��"�
�"� 7                �"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"� 8                �"��"�Mode: A1 Sats:          �"��"�UTC:           RMS:     �"�
�"� 9                �"��"�DOP: H=99.99 V=99.99    �"��"�MAJ:           MIN:     �"�
�"�10                �"��"�TOFF:                   �"��"�ORI:           LAT:     �"�
�"�11                �"��"�PPS:                    �"��"�LON:           ALT:     �"�
�""�"��"��"��"��"��"� GSV �"��"��"��"��"��"��"��"��""�"��"��"��"��"��"��"��"� GSA + PPS �"��"��"��"��"��"��""�"��"��"��"��"��"��"��"��"��"��"� GST �"��"��"��"��"��"��"��"��"�
(45) $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30

... <snip> ...

(42) $GPGSV,1,1,03,15,,,21,16,,,07,

Unfortunately, I was still getting a few errors when I tried to use gpsd.

root@raspberrypi:~# gpsd /dev/ttyACM0 -N -D3 -F /var/run/gpsd.sock 
gpsd:INFO: launching (Version 3.16)
gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:ERROR: can't bind to IPv6 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:INFO: command sockets creation failed, netlib errors -1, -1

After finding a StackOverflow answer, I changed my gpsd command after debugging and restarting everything.

root@raspberrypi:~# vi /etc/default/gpsd
root@raspberrypi:~# killall gpsd
root@raspberrypi:~# gpsmon /dev/ttyACM0
root@raspberrypi:~# systemctl enable gpsd.socket
root@raspberrypi:~# systemctl start gpsd.socket
root@raspberrypi:~# gpsd /dev/ttyACM0 -F /var/run/gpsd.sock -n

With everything fixed, I was able to successfully collect GPS data!

root@raspberrypi:~# cgps -s
�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
�"�    Time:       2017-xxxxxxxxxxxxxxxxxxx �"��"�PRN:   Elev:  Azim:  SNR:  Used: �"�
�"�    Latitude:    xx.xxxxxx N             �"��"�   2    30    104    38      Y   �"�
�"�    Longitude:   xx.xxxxxx W             �"��"�   4    05    293    27      N   �"�
�"�    Altitude:   42.8 m                   �"��"�   5    37    042    46      Y   �"�
�"�    Speed:      0.2 kph                  �"��"�  13    63    092    38      Y   �"�
�"�    Heading:    0.0 deg (true)           �"��"�  15    64    183    40      Y   �"�
�"�    Climb:      0.0 m/min                �"��"�  20    59    317    36      Y   �"�
�"�    Status:     3D FIX (2 secs)          �"��"�  21    23    312    35      Y   �"�
�"�    Longitude Err:   +/- 19 m            �"��"�  22    00    000    22      N   �"�
�"�    Latitude Err:    +/- 63 m            �"��"�  25    00    000    22      N   �"�
�"�    Altitude Err:    +/- 50 m            �"��"�  29    68    265    29      Y   �"�
�"�    Course Err:      n/a                 �"��"�  31    00    000    22      N   �"�
�"�    Speed Err:       +/- 456 kph         �"��"� 138    47    225    34      N   �"�
�"�    Time offset:     -2328759.122        �"��"�                                 �"�
�"�    Grid Square:     EL88vi              �"��"�                                 �"�
�""�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��""�"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"��"�
Add Comment

Raspberry Pi GPS – Conclusion

While this was a simpler post, it was still really fun getting the GPS receiver to work with my Raspberry Pi.

I wasn’t able to get anything useful out of my airodump ‘gpsd’ output, so this is something that I want to add in the future.

This could be a great value-add for larger wireless engagements, so let me know if you are doing anything similar!

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.