Setting up GPS
A simple USB GPS receiver will do just fine for this project. I'm using an old Microsoft USB GPS. In order for the Pi to read the GPS data we'll install gpsd.
sudo apt-get install gpsd gpsd-clients
Setting up the local web server
The main PHP script will read the gpsd information through a JSON file. We'll need to install apache and PHP to serve the JSON file locally.
sudo apt-get install apache2 -yDrop this file from the gpsd project into the web server directory, /var/www/ and name it gpsd.php
sudo apt-get install php5 libapache2-mod-php5 -y
Execute gpsd.php from the command line to build a needed configuration file.
cd /var/wwwIf you open a web browser on your Pi and navigate to http://localhost/gpsd.php?
sudo php gpsd.php
op=json with your GPS connected and a clear shot of the sky, you should see position information appear. This is where the main PHP script will be reading the GPS data.
Install Python modem
I mentioned earlier I'm not using a traditional APRS application to generate messages. Instead I'm using a simple Python library called afsk modem. Install this using pip.
sudo apt-get install python-pip python-devYou may need to add the option: --index "https://....." on older builds of pip.
sudo pip install afsk
The optional PyAudio libraries are not required.
This library takes a properly formatted APRS message string as input and generates a Bell 202 AFSK audio sample and AFSK encoded APRS/AX.25 packet.
Make sure the Pi's sound output level is turned up. I set mine to 88.
alsamixerAlso, I turned up the squelch on my UV-5R since there was some interference on 144.39 and it was preventing the VOX from kicking in early enough to catch the entire packet.
And finally, be sure Raspi Config is set to play audio through the 3.5mm port, not HDMI.
sudo raspi-configThe main script
Start gpsd with
gpsd /dev/ttyUSB0or whatever your port is called. You can use cgps or gpsmon to check for good data. It should start automatically when the USB initializes or is plugged in.
Download the the main PHP script (you may need this one) and place it in your Pi's home folder. You'll want to modify the first two variables entering your callsign and any extra message you want transmitted with your position.
Running this file from the command line will show you what's happening.
php aprs-position-beacon.phpReading in the GPS data, the script converts that to an APRS message string, runs the message through the modem library, outputs a WAV file and then plays the audio file through the Pi's onboard sound card. That triggers the VOX enabled UV-5R and you're now transmitting your position via APRS over RF.
There are several methods to run this script automatically at startup.
I had to run through some troubleshooting, like setting the /dev/ttyUBS0 speed to 4800 with
stty -F /dev/ttyUSB0 4800I also killed all other instances and removed any old socks.
sudo killall gpsdThat's it.
sudo rm /var/run/gpsd.sock