It is a bout time for an update on my Raspberry Pi APRS project.
Two raspberry pi computers, a 32″ display, and a messy desk!
(Part 01)
Many months ago I was working on getting a Raspberry Pi working for APRS work. I was experiencing a ton of issues with getting soundmodem to decode aprs signals that were known to be good (ie. ideal recording played back as an MP3 file, no RF involved).
Raspberry Pi (Model B) in a clear protective case.
Most recently, I have managed to get the Raspberry Pi and soundmodem to play nicely with a USB soundcard (the Creative SB1140)! Finally some success – some of which I attribute to a more polished distribution.
In my previous attempts, I tried advanced commands such as setting the dwc_otg.speed=1 flag in (/boot/cmdline.txt) which did not solve the issue(s).
I installed a new image of the Wheezy Raspbian distro (2013-09-25-wheezy-raspbian.zip), and so a software update was in order. To facilitate the update, I logged into the shell and issued the following commands:
sudo apt-get update
sudo apt-get upgrade
SSH shell connection to Raspberry Pi
It should be noted that you do not need to connect the Raspberry Pi to an external display to complete this work – yes it may be easier, however, there is another way! You can connect to the Pi by using an SSH client such as Putty. All you need is the local IP address of the Pi (as a tip, log in to your router and look for the clients listed in the DHCP table).
Once the core operating system was updated, I installed some of the components which would be needed for operating an APRS gateway:
sudo apt-get install screen build-essential python-serial sqlite3 python-dev soundmodem libax25 libax25-dev ax25-tools ax25-apps libax25-dev
The above command downloads and installs ~47Mb of binaries and takes some time to complete. Once the desired software was installed, I had some fiddling to do with how the system recognizes the USB sound card.
To eliminate as many variables as possible, I told the system to ignore the on-board sound card (output only, so useless) by modifying /etc/modules as follows:
sudo vi /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.
#snd-bcm2835
snd-usb-audio
Next, I modified /etc/asound.conf as follows:
sudo vi /etc/asound.conf
pcm.dmixer{
type dmix
ipc_key 1024
slave {
pcm “hw:0,0”
period_time 0
period_size 1024
buffer_size 8192
rate 48000
}
bindings {
0 0
1 1
}
}
pcm.asymed {
type asym
playback.pcm “dmixer”
capture.pcm “hw:0,0”
}
pcm.dsp0 {
type plug
slave.pcm “asymed”
}
pcm.!default {
type plug
slave.pcm “asymed”
}
pcm.default {
type plug
slave.pcm “asymed”
}
ctl.mixer0 {
type hw
card 0
}
Next, a basic soundmodem configuration is established. This is the core of the software TNC so take some time to learn the ins and outs of this configuration file.
sudo vi /etc/ax25/soundmodem.conf
<?xml version=”1.0″?>
<modem>
<configuration name=”AX25″>
<chaccess txdelay=”250″ slottime=”100″ ppersist=”40″ fulldup=”0″ txtail=”100″/>
<audio type=”alsa” device=”plughw:0,0″ halfdup=”1″ capturechannelmode=”Mono”/>
<ptt file=”none” hamlib_model=”” hamlib_params=”” gpio=”0″/>
<channel name=”sm0″><mod mode=”afsk” bps=”1200″ f0=”1200″ f1=”2200″ diffenc=”1″ inlv=”8″ fec=”1″ tunelen=”32″ synclen=”32″/>
<demod mode=”afsk” bps=”1200″ f0=”1200″ f1=”2200″ diffdec=”1″ inlv=”8″ fec=”3″ mintune=”16″ minsync=”16″/>
<pkt mode=”MKISS” ifname=”sm0″ hwaddr=”NOCALL-05″ ip=”44.128.0.2″ netmask=”255.255.255.0″ broadcast=”44.128.0.255″ file=”/dev/soundmodem0″ unlink=”1″/>
</channel>
</configuration>
</modem>
Be sure to replace the NOCALL-05 with your own call-sign to ensure that the APRS packets conform to regulations! The txdelay=250 and txtail=100 are to add a time-delay for VOX operation – these values could be tweaked if you are using a hardware PTT.
Raspberry Pi GPIO (general purpose input / output) header & serial adapter.
Speaking of hardware PTT – it is a somewhat common problem when working with a Pi that a USB to serial adapter may malfunction. It would be advisable to use one of the GPIO pins of the Pi in order to toggle the PTT for your radio.
I may use a GPIO to serial adapter which was purchased on eBay for less than the cost of the materials. It is simple enough to use the GPIO pin directly, just be aware that the Pi is not able to source a large current so it would be prudent to use a transistor to drive an optocoupler for galvanic isolation of the Pi from the radio.
Edit the axports file to include a statement for soundmodem and your callsign(with SSID – ie. -05). This file assists in setting up an AX.25 port which acts as a network adapter. We will use this functionality later to produce AX.25 packets which we can use / listen to in order to verify functionality and to set output levels.
sudo vi /etc/ax25/axports
# /etc/ax25/axports
#
# The format of this file is:
#
# name callsign speed paclen window description
#
sm0 VE3BUX-05 1200 255 2 VHF APRS (1200 bps)
#1 OH2BNS-1 1200 255 2 144.675 MHz (1200 bps)
#2 OH2BNS-9 38400 255 7 TNOS/Linux (38400 bps)
Next I modified the alsa-base.conf file found in /etc/modprobe.d so that it was as follows:
sudo vi /etc/modprobe.d/alsa-base.conf
# autoloader aliases
install sound-slot-0 /sbin/modprobe snd-card-0
install sound-slot-1 /sbin/modprobe snd-card-1
install sound-slot-2 /sbin/modprobe snd-card-2
install sound-slot-3 /sbin/modprobe snd-card-3
install sound-slot-4 /sbin/modprobe snd-card-4
install sound-slot-5 /sbin/modprobe snd-card-5
install sound-slot-6 /sbin/modprobe snd-card-6
install sound-slot-7 /sbin/modprobe snd-card-7
# Cause optional modules to be loaded above generic modules
install snd /sbin/modprobe –ignore-install snd && { /sbin/modprobe –quiet snd-ioctl32 ; /sbin/modprobe –quiet snd-seq ; : ; }
install snd-rawmidi /sbin/modprobe –ignore-install snd-rawmidi && { /sbin/modprobe –quiet snd-seq-midi ; : ; }
install snd-emu10k1 /sbin/modprobe –ignore-install snd-emu10k1 && { /sbin/modprobe –quiet snd-emu10k1-synth ; : ; }
options snd slots=snd_bcm2835,snd_usb_audio
options snd_usb_audio index=0
#options snd_bcm2835 index=-2
# I commented the above line out as I found it was ineffective at blocking the snd_bcm2835 from being loaded
# Prevent abnormal drivers from grabbing index 0
options bt87x index=-2
options cx88_alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
The intent in the alsa-base.conf file is to preemptively load the USB sound card, blocking the built-in one from taking index=0 (the default device).
Audio test bench for soundmodem testing.
So by this point, all should be going well and your system will likely work just fine. We can now start testing by recording and playing back audio handled by the USB sound card. For my initial tests, I simply plugged the USB sound card’s mic jack into the speaker output of my computer and played some audio. I recorded the incoming audio as follows:
arecord -vv ~/testaudio.wav
You can then play back the audio to check your levels by issuing the following command:
aplay ~/testaudio.wav
If you wish to adjust the levels, simply run:
sudo alsamixer
Press F5 to display all “devices” associated to your USB sound card. Using the arrow keys, select the parameter you wish to change and exit by pressing “ESC”.
To check that soundmodem will handle AX25 network traffic, issue the following commands:
sudo screen -dmS sm soundmodem
sudo /sbin/route add -net 44.0.0.0 netmask 255.0.0.0 dev sm0
ping -i 5 44.128.0.1
You should now hear the familiar sound of packtets, provided you are monitoring the output audio of the USB sound card using a speaker or headphones. To see what soundmodem is doing in the background, you can “attach” to the screen as follows:
sudo screen -r sm
To exit the screen without killing the soundmodem daemon, press Ctl-A then while holding Ctl, press D
If you have local APRS traffic, by all means connect your radio to the sound card’s input (mic) jack and try to decode the packets. You can see any decoding by running the following command:
sudo axlisten -a -c
You should see something similar to the following:
AX.25 test packets from audio recording
If you do not have local APRS traffic which is frequent enough to use for real-world testing, you can download and play any audio file containing APRS (or packet) data. Here is a good resource that I used: WA8LMF Test CD
We will now install and configure dixprs. Start by creating the install directory, and then populate it with a configuration file.
sudo mkdir /usr/local/dixprs
sudo vi /usr/local/dixprs/config.txt
In the config.txt file, you will need to modify it to suit your particular details. Be sure to change the callsign, latitude and longitude at a bare minimum!
[GENERAL]
# Mandatory parameters
# Your callsign with SSID
CALLSIGN=NOCALL-5
# Degrees; West is negative, East is positive
LONGITUDE=-75.00
# Degrees; South is negative, North is posittive
LATITUDE=45.00
# Optional parameters
# Station height abvove the see level in meters; no default
#ASL=
# Owner name and contact; no default
#OWNER=
# Spool directory to import packets; no default
#SPOOL= # Station symbol; default is S#
#SYMBOL=
# UDP port base number; default is 31110
#UDPBASE=
# Beacon frequency in minutes; default is 30
BCNTIME=30
# Beacon text; %v replaced with actual version string; default is %v
# Used as default for ISGW and RADIO
BCNTXT=Raspberry Pi Soundmodem APRS gateway
# Select km/mi on monitor and in DX list; default is y (km)
#METRIC=<y/n>
# Max number of digis passed for local stations
# Used as message gating condition for gating to Rf
# Default value is 2
#LOCALHOPS=
# Range in km within messages gated to Rf
# If defined, checked after hop count (local) check
# No default
#MSGRANGE=
#################################################################
#
# IS gateway settings; remove this section to disable GW #
#
#################################################################
[ISGW]
# Mandatory parameters
# Domain name of IS server to connect
host=noam.aprs2.net
# Optional parameters
# Port number; default is 14580
#PORT=14501
# Filter; default is r/@/150
# @ is replaced with station position
FILTER=r/@/30
#################################################################
#
# WRB server settings; remove this section to disable it #
#
#################################################################
[WEBSERVER]
# Mandatory parameters
# WEB server port, no default
port=9999
################################################################# #
#
# Radio port configuration settings; repeat section for #
# multiple ports #
#
#################################################################
[RADIO]
# Mandatory parameters
# Interface type
INTERFACE=AX25
# Device; as listed by ifconfig; it is nbot the ax.25 port name!
DEVICE=sm0
# Optional parameters
# Modem speed, default is 1200
#SIGNALRATE=1200
# Enable/disable NWS WX bulletin and object gating from IS to Rf
# Disabled by default
#GATENWS=<y/n>
# Enable/disable BOM WX bulletin and object gating from IS to Rf
# Disabled by default
#GATEBOM=<y/n>
# Descripton of port; no default
#DESCRIPTION=
# Via used to send locally generated packets; default is WIDE1-1,WIDE2-2
#AXVIA=
# Digipeaters processed with WIDEn-n algorithm; default is WIDE1,WIDE2
#WIDEN=
# Blacklisted stations; they are not digipeated, not gated; default is NOCALL,N0CALL
# PHG string, do not mix with range; no default
#PHG=
# Range value in miles, do not mix with PHG; no default
#RNG=
# Enable/disable transmission; change it to PTTON=1 to enable trasmission; default is no
#PTTON=<y/n>
# Gate locally generated frames to IS gateway; default is no
# Useful for rx-only radio ports
# Experimental, use carefully
#GATELOCAL=<y/n>
# Gate digipeated frames to IS gateway; default is no
# Experimental, use carefully
#GATEDIGI=<y/n>
# Beacon text; %v replaced with actual version string; default is %v
#BCNTXT=
# Enable/disable digipeater; default is enabled
#DIGIPEATER=<y/n>
# Modem/TNC setup parameters 0…255; no defaults
# Use to setup modem/TNC by DIXPRS
#TXD=
#PPERSIST=
#SLOTTIME=
#TXTAIL=
#DUPLEX=
# Below these are the traffic shaping settings for gating messages
# From IS to Rf
#
# For advanced users only; do not change if you do not know how
# traffic shaping works and if you do not have good reason !!!
# Traffic shaping high treshold, default is 0.75
#TRAFFICHIGH=
# Traffic shaping low treshold, default is 0.5
#TRAFFIClow=
# Traffic shaping transmission delay, default is 5.0 sec
#TRAFFICDELAY=
# Comma separated list of addresses to send receveid/transmitted frames
# in hostip:port format. No default.
#UDPCC=
The following steps are a one-shot quick and dirty installation of the dixprs software package:
cd ~
mkdir pyax25
cd pyax25
wget https://sites.google.com/site/dixprs/downloads/pyax25.tar.gz
tar -xzvf pyax25.tar.gz
./compile_ax25.py build
sudo ./compile_ax25.py install
sudo rm -rf pyax25
cd /usr/local/dixprs
sudo wget https://sites.google.com/site/dixprs/downloads/dixprs-2.2.2.tar.gz
sudo gzip -d dixprs-2.2.2.tar.gz
sudo tar -xvf dixprs-2.2.2.tar
sudo rm -f dixprs-2.2.2.tar
sudo chown -R pi:pi /usr/local/dixprs
sudo chmod 755 *.py
sudo chmod 644 *.txt
cd ~
With dixprs installed, test the package as follows:
/usr/local/dixprs/dixprs.py -c /usr/local/dixprs/config.txt
Now be aware, if you are still streaming your test audio to the Pi, the decoded packets may be sent out to the APRS tier2 servers if your connection is working! This may be a bit annoying for those who rely on actual RF-gateway tracking (ie. you are mis-reporting positions for anyone whose callsigns are decoded).
Well, this is a ton of information as it is, so I will leave it here for now. My immediate plans are to add GPS receiver functionality and to dabble with aprx again (software that I have used successfully in the past).