Build Raspberry Pi GPS location/navigation device
While every smartphone has GPS, the Pi can also be converted into a GPS receiver with a cheap Raspberry Pi GPS module. In many outdoor applications, especially those that move (Car-PC, weather balloon, etc.), the exact position is a big advantage. Mobility is achieved with a battery pack or a USB power bank.
In this tutorial, I’ll show you how tracking works with such a GPS module and what you need for it.
Required Hardware Parts
I have used the following parts:
- Minicon NEO-6M GPS Module
- 10000mAh Powerbank (alternatively follow this tutorial)
- Jumper cable
The wiring is very simple:
|GPS Modul||Raspberry Pi|
|VCC||3.3V (Pin 1)|
|RX||TXD/GPIO 14 (Pin 8)|
|TX||RXD/GPIO 15 (Pin 10)|
|GND||Ground (Pin 6)|
The Raspberry Pi pinout is here.
Release serial interface
If you have not already released the serial interface before, this must happen beforehand. For this we edit the following file:
sudo nano /etc/inittab
Here the following line (presumably the last one) has to be commented out (or deleted) by means of a rhombus # at the beginning. Storing is done with STR + O, finished with CTRL + X.
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Then there is the file/boot/cmdline.txt to be edited,
sudo nano /boot/cmdline.txt
the following entries are deleted:
The last entry does not seem to exist in all OS versions by default. Your file should look like this:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
For the changes to be accepted, a restart is absolutely necessary. This can also be done after installing the other software.
Raspberry Pi GPS Module – Software
We need a few programs to read the Raspberry Pi GPS module. Before that, however, we need to update the repositories.
sudo apt-get update sudo apt-get install minicom gpsd gpsd-clients
If you have not restarted before, this must be done now at the latest
sudo reboot now
Now everything should be ready and the module ready for the test. In addition, we inform the module that it should work with a baud rate of 9600:
stty -F /dev/ttyAMA0 9600
In this case, no (error) message should occur. Afterwards, we can have the current configuration output:
stty -F /dev/ttyAMA0
You start with the first test
minicom -b 9600 -o -D /dev/ttyAMA0
Here the baud rate, as well as the device is indicated (with CTRL + A, Q you finish). The list is a bit confusing, but it works well if only the raw data is needed.
To get a better look, we start gpsd. Again, we have to specify the baud rate
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock -n
before we can start:
Make sure that the reception to the GPS satellites can be made, so go outside, or at least to a window. Where the reception in the house tends to be good, you can test with your phone.