Adding a USB GPS Receiver to Direwolf to create an APRS Tracker

I recently posted a tutorial on Installing Direwolf on a Raspberry Pi to run an APRS node. The included direwolf.conf example assumed the node was operating as a static iGate or Digipeater, so the location (In Longitude and Latitude) was hard coded, however Direwolf also supports connecting to a GPS receiver for real time location tracking.

As I have a handheld radio with inbuilt GPS / APRS support I don't have an immediate need to use Direwolf as an APRS tracker, but curiosity got the better of me and I ordered a Cheap USB GPS receiver from Amazon (Apparently I ordered the last one, but any standard USB GPS receiver outputting NMEA formatted data should work). Its now up and running so I thought I'd document the processes.
USB GPS Receiver
Click read more for the configuration instructions.

Its assumed you've already got Direwolf up and running and interfaced with a radio. If not, its worth checking out this blog post. Its also assumed you installed Direwolf from source rather than a package, and you're using Raspbian or Debian based OS.

GPSD Support

Direwolf uses gpsd to handle the GPS receiver. gpsd is nice because it simplifies the GPS data for consumption by other "clients", and also means multiple clients can share a single receiver.

Direwolf only has the required gpsd support if the correct libraries were available when it was compiled, so first of all its worth confirming if it was built with gpsd support.

Run the following:
direwolf -t 0 -h 2>/dev/null  | grep Includes

And you should see something like:

If Direwolf wasn't built with gpsd support you will need to recompile it after installing the required packages.

First of all install the packages:
sudo apt-get install gpsd libgps-dev

Change to the direwolf source code directory. Mines in /usr/src:
cd /usr/src/direwolf/

Make and Install direwolf:
sudo make
sudo make install

Run the following (again):
direwolf -t 0 -h 2>/dev/null  | grep Includes

Hopefully you now see support for gpsd:

Before going to the effort of configuring Direwolf its worth confirming that the GPS receiver is working properly. To function correctly it will likely need a view of the sky. On a window sill should work fine. Plug the receiver into an available USB port.

Run the following command to connect to gpsd and show some basic details:
cgps -s

You should see something like the screenshot below. The most important section is "status" - it should say fixed.  If it doesn't try moving the receiver closer to a window, or you may have to put it outside:
cgps output
Once you've got a fix, we can begin configuring Direwolf to poll its position from gpsd.

Configuring Direwolf

Previous configuration examples have used the PBEACON (Position Beacon) configuration to periodically beacon a static location. As we're moving to tracking our position with GPS we need to delete or comment out these PBEACON lines, and instead add the required TBEACON  configuration.

The TBEACON configuration supports the same options as PBEACON, however you don't need to supply latitude, longitude, course, or speed as are obtained from the GPS receiver. If you set the altitude to greater than 0, the actual altitude will be taken from the GPS location.

First of all lets test it with something simple. Open up your direwolf.conf file, delete or comment out any PBEACON entries, and enter the following:

Then restart Direwolf to reload the config:
sudo systemctl restart direwolf

If you check the Direwolf logs, you'll hopefully see that the GPS has got a fix:
Direwolf Logs
Leave Direwolf running and after approximately 30 seconds the attached radio should key up and transmit the position over RF.


Beaconing your location at a set interval doesn't really make sense - if you're stationary its a waste of RF spectrum, energy etc and if you're travelling at speed it might not give the required resolution to track your journey. This is where SmartBeaconing™comes in, by automatically adjusting the interval between transmissions according to your current speed or change of direction.

To enable SmartBeaconing, remove the DELAY and EVERY parameters from your TBEACON entries, and add the following on a new line:

Then restart Direwolf to reload the config:
sudo systemctl restart direwolf

You should now see that the transmit interval varies according to your speed. Its worth noting that the SmartBeaconing intervals can be tweaked, please see the Direwolf Documentation for more information.

No comments:

Post a Comment