Last year I finally decided to take a foundation and intermediate level amateur radio course. One of the reasons I got interested in amateur radio was APRS (Automatic Packet Reporting System), a system designed to track the position of radio amateurs, provide two way text messaging and alert messages. APRS is a digital mode that uses AFSK1200 encoding that’s very similar to the old Bell modem protocols used by early 1200 baud dialup modems. APRS is often used by radio amateurs who are out in cars or on foot to report their positions, although it can do a lot more than this. APRS packets can be repeated (or “digipeated” in APRS terminology) by other stations that receive them and one option is for these digipeaters not just to repeat the packet over the air but also over the internet. A system known as APRS-IS (APRS Internet System) captures these packets and makes them available to anyone on the internet. Several websites such as aprs.fi, openaprs and find-u will show you raw packets from APRS-IS. The gateways that bridge APRS to the internet are known as IGates and some just receive packets and relay them to APRS-IS, while others will relay packets claiming to be nearby over the radio as well. In the UK setting up a station to repeat packets from the internet onto the air will probably require a notice of variation (at least for unattended use), which in turn requires a full license that I don’t have (yet). Although there are a few people interested in APRS in the Aberystwyth area we have no local IGates or permanent digipeaters anywhere nearby, as my house is reasonably high up and has views over much of Aberystwyth, a few of the hills and mountains to the east and a bit of the Rheidol valley I thought i’d try and set up a receive only IGate.
I have been looking at various ways to setup an IGate using cheap Realtek RT2832U TV tuner/Software defined radio dongle running on a Raspberry Pi Model A. Although these devices are designed as TV tuners, they also work as software defined radios capable of receiving any signal between 22 and 1700 MHz with a channel width up to 3.2 MHz. There’s a lot more information about these devices on osmocon wiki. The rtl_fm program included with the rtlsdr software from osmocon allows the decoding of FM audio transmissions including both wideband broadcast FM as used by radio stations and narrow band FM used by most walkie talkies and often used by radio amateurs in the VHF and UHF bands. The audio output from this can also be piped to other programs for them to process the audio stream.
I tried a few different programs to decode APRS. The first one was multimon-ng, which is capable of decoding many formats including AFSK1200 that’s used by APRS. I struggled to get multimon-ng to decode anything produced by my hardware TNC, although on a few occasions I managed to get a partial decode of a packet. Next I tried to use Soundmodem combined with an ALSA Loopback device that essentially created a virtual soundcard with the audio from the APRS frequency. However this gave me problems with it either working in the configuration mode but not when actually deployed or even failing all together. I found that when I didn’t select a transmit modulation type (its not like I needed one as I only had a receiver) the whole program would crash. Selecting one made this problem go away, but it still felt like an uphill struggle to get working.
Somebody at work had mentioned a program called Direwolf (https://home.comcast.net/~wb2osz/site/) so I thought i’d give it a try instead and had a lot more success.
To get Direwolf running on the Rapsberry Pi I had to build it from source on the Pi itself (a cross compiler would have probably worked as well). To compile it, I downloaded Direwolf onto my Raspberry Pi, compiled the source by running make to compile the source using the command “make -f Makefile.linux”. Before it would run successfully Direwolf required some changes to its config file, to set the callsign, APRS-IS passcode and beacon settings. Below is my config file. The MYCALL line sets my callsign, the IGLOGIN sets my login and passcode (its not my real passcode!) to the APRS-IS server and the PBEACON line sets the parameters of the beacon packets which are sent to APRS-IS. The TXDELAY and TXTAIL options are transmit settings which are irrelevant to this receive only setup, but Direwolf didn’t want to start without them. The AGWPORT and KISSPORT settings specify port numbers to allow other devices on my LAN to connect to Direwolf and bring the data into another APRS client such as Xastir.
ARATE 44100
ACHANNELS 1
CHANNEL 0
MYCALL MW6SZE-10
MODEM 1200 1200 2200
TXDELAY 30
TXTAIL 10
AGWPORT 8000
KISSPORT 8001
FIX_BITS 1
IGSERVER euro.aprs2.net
IGLOGIN MW6SZE 123456
PBEACON sendto=IG delay=0:30 every=60:00 symbol=”igate” overlay=R lat=52^24.0N long=004^04.0W power=0 height=0 gain=0 comment=”Receive only iGate”
IGFILTER m/50
IGTXLIMIT 6 10
To start the whole process I had to pipe the audio from rtl_fm to direwolf. For some reason I can’t figure out, Direwolf requires a soundcard to be present on the system and my Raspberry Pi image doesn’t seem to have drivers for the Pi’s actual sound card. However my previous experiments with soundmodem had taught me a bit about the ALSA loopback and simply loading the module (snd_aloop) for this made everything work, i’ve now got this loading on boot by adding the line “snd-aloop” to the config file /etc/modules. To run the whole thing I found I have two different options, the first is to run rtl_fm with its default sample rate of 24 KHz and tell Direwolf to use 24 KHz. The command to achieve this is the following:
rtl_fm -f 144787300 | ./direwolf -n 1 -r 24000 -b 16 -t 0 –
The other option is to have rtl_fm upsample the data to 44 KHz and the command to do this is:
rtl_fm -f 144787300 -s 44100 | ./direwolf -n 1 -r 44100 -b 16 -t 0 –
Note that the APRS frequency is specified as 144.7873 Mhz, despite actually being 144.800, this is due to a small offset that the RTL2832U seems to suffer from. I arrived at 144.7873 through trial and error from listening to the output and using the graphical output of GQRX on my desktop PC. The -n 1 option to direwolf specifies that there is only 1 audio channel, -b 16 specifies that its a 16 bit sample rate and -t 0 turns off Direwolf’s horrible text colouring that I find makes it almost unreadable.
The downside of using a 24 KHz sample rate is that Direwolf has several decoders and the best of these (decoder F) only works with a 44 KHz sample rate. Both configurations seem to work reasonably well, although the in 44 KHz Direwolf uses around 20% of the CPU time and rtl_fm another 20%, in 24 KHz mode Direwolf’s CPU usage drops to less than 10% but rtl_fm remains at around 20%. This is probably mostly due to the different decoders. I haven’t extensively tested the performance difference between the decoders, both seem to work reasonably well and i’m normally running in 44 KHz mode with decoder F.
All this runs on a Raspberry Pi model A with a powered USB hub to let me plugin both Wifi and the Realtek dongle. A new model B+ and or B2 would probably work without the powered hub, but the model A only has 1 USB port. The antenna that comes with the Realtek dongle isn’t great, so using a couple of converters to give me an SMA connector i’m using a cheap ebay clone of a Nagoya NA-771. This still isn’t optimal and I do intend to replace it with a better antenna in future.
Here is a photo of my setup showing the antenna, powered USB hub and Raspberry Pi.