I have been using the Raspberry Pi 2 for quite some time and now have a project where I wanted to make it location aware through the addition of a GPS module. Since USB ports are limited, and i also had a UBlox NEO-6m-001 device I thought it made sense to connect this to the device through the inbuilt hardware UART pins to free up the USB ports.

Since i found information spread across a few places I thought it might be useful to include my workings within this document so that others may use this to set their system up if they want to emulate a similar thing. Beyond GPS location, I have also integrated the system with NTP (Network Time Protocol) to allow the device to update it's own time should there be no internet access which is handy given the raspberry pi does not have a real time clock.

*WARNING, this tutorial requires you to connect to the GPIO pins which can destroy your Raspberry pi, I take no responsibility for any damage that may occur*

By default, the Raspberry Pi is set to use the Hardware UART as a serial console output and if you connect the GPS to that pin then it will crash so first we need to disable the Console output to the hardware UART pins, this is done by the below;

  1. At the shell enter “sudo nano /boot/cmdline.txt”
  2. Find the line “dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait”
  3. Change this to remove console=serial0,115200 e.g.; “dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait”
  4. Since power can be an issue, I also recommend modifying the boot/cmdline to add “smsc95xx.turbo_mode=N” after rootwait, this may slow down the ethernet but does improve reliability.
  5. Save the file (Ctrl + O)
  6. At the shell enter “sudo nano /etc/inittab”
  7. Find the line “TO:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100” and put a # in front of it.
  8. Save the file (Ctrl + O)
  9. At the shell enter “sudo systemctl stop serial-getty@ttyAMA0.service && sudo systemctl disable serialgetty@ttyAMA0.service
  10. Restart the Raspberry Pi
  11. We are now ready to install the GPS daemon and NTP, do this by “sudo apt-get update && sudo apt-get install gpsd gpsd-clients python-gps ntp”
  12. At the shell enter “sudo dpkg-reconfigure gpsd”
  13. At the shell enter “sudo nano /etc/default/gpsd”
  14. Change USBAUTO=true to false, in Devices enter “/dev/ttyAMA0”, in GPSD_OPTIONS enter “-n”
  15. Turn off the raspberry pi, and disconnect power. Now connect the raspberry pi Rx pin to the Tx pin of the uBLOX module, also connect the raspberry pi Ground pin to ground for the GPS, and the VCC to the raspberry pi 5v pin. (The website https://pinout.xyz/ gives great examples, BCM 15 (Rxd) is the recieve pin for the RPi Serial / UART, Pin 2 & 4 are 5v power, and Pin 6 is ground, just check the board is facing the right way!).
  16. Ensure no terminals are bridged, and then start back up the raspberry pi
  17. You may have to restart the raspberry pi, and at the shell hit “cgps -s”, if you see it update then it means the GPS is sucessfully set up.
  18. Next to setting up the NTP, at the shell enter “sudo nano  /etc/ntp.conf”
  19. above the server line, enter this line “server minpoll 4 maxpoll 4”
  20. Below that line, enter “fudge time1 +0.350 refid GPS stratum 15
  21. Save the file “Ctrl + O”
  22. At the terminal enter “sudo systemctl restart ntp”
  23. you should be able to now enter at the terminal “ntpq -pn” and if you see remote and .GPS. all is working.


This was set up on Debian Jessie, so other operating systems and versions might behave differently. It was also run on a Raspberry Pi 2, these instructions will not work for a Raspberry Pi 3!. Another note, if you get errors on your Raspberry Pi about SysRq : HELP check to make sure you have removed the console references in the /boot/cmdline.txt file, and the /etc/inittab file and finally that the serial-getty service has been stopped and disabled.


Prev Under the Microscope: Sporophyll of Pteridium
Next Lakeside Pakenham

Comments are closed.

%d bloggers like this: