This article has been granted reprint permission by BD7IPA teacher.
Cause: When participating in outdoor hiking activities, functions such as location, track, and direction are needed. Although smartphones have relatively complete functionality, they are not ideal due to limited battery life, incomplete 4G/5G signal coverage, and weak signals in some mountainous areas. Therefore, the goal is to use wireless APRS (Automatic Packet Reporting System) to report location. In addition, for family members who live far away, it can also be used to track their own location in real-time, which can assist in rescue if an emergency occurs. This is particularly valuable for people who enjoy outdoor activities and cannot be compared to smartphones.
Goal: To build a small base station with a Raspberry Pi, USB sound card, and handheld radio, incorporating functions such as gateway, relay, and tracking (location).
This allows for: a person to set up a mobile base station, and a vehicle (or a location with an unobstructed view, high elevation, and 4G/5G signal) to be used as the main base station.
- The location information of the handheld device can be reported to the APRS map server via the base station's gateway (the base station needs to have Wi-Fi connectivity, wired networks also work, but outdoor wired connections are not practical). Family members can then obtain your location through the map server.
- Between two handheld devices, if they cannot communicate due to signal coverage issues, they can exchange location information through the base station's relay function, making it easier to contact team members during outdoor activities.
- The base station itself has positioning functionality and sends its coordinates to the outside at regular intervals, which is helpful for outdoor activities where maps are not readily available or when you get lost, providing a clear directional reference.
Initially, I acquired a finished DIY project from a senior member on the "Yan Yu" platform. However, it lacked Wi-Fi and GPS functionality. During the process of adding GPS, I went through extensive modifications, starting from scratch, installing the system, compiling software, replacing the sound card, replacing the desk, and adding a GPS module. I meticulously documented each step, encountering numerous pitfalls along the way. With the spirit of "persistence," I compiled the entire process to help fellow enthusiasts avoid common mistakes during their DIY projects.
Let's get started right away. Before we begin, let's summarize the necessary hardware and software:
- Hardware:
a) A Raspberry Pi (1B is sufficient; installing the system and compiling software will be slower, but I have also tried using a 4B. Besides faster compilation, there are no other differences. Some online experts say that an Orange Pi can also be used, but I don't have one, so I haven't tried it. Theoretically, if you can install Linux on it, it should work.)
b) USB sound card, you can find them on Taobao for around ten or twenty yuan. Search for "CM108 sound card," and I've tried both the full-size and mini versions, and they both work perfectly. It depends on your preference.
c) I already had a handheld radio when I bought it, but I replaced it with the BaoFeng UV5R for convenience. The ability to manually tune and receive on two bands is particularly useful outdoors, and makes it easier to communicate with other hikers by changing frequencies as needed.
d) GPS module, I purchased a "Vitte Smart" GPS+Beidou module from Taobao, which is the external antenna version.
e) 3.3V relay module (make sure it's a 3.3V relay, the Raspberry Pi GPIO ports only provide 3.3V voltage; modules that require 5V cannot be powered). This was purchased from Xianyu and connected to the PTT using a transistor + resistor. When I later switched to the UV5R, for some reason, the sound card would reset every time it transmitted, causing the program to exit. After switching to relay control, this issue disappeared. However, the noise generated by the relays when activated is quite noticeable, so those who are sensitive can consider using solid-state relays to see if they can achieve a better result.
f) Two adjustable DC-DC step-down modules, because I am using a 12V power supply. The Raspberry Pi requires 5V power, and the handheld device requires 7.4V power, so I use two.
g) The USB wireless network card I'm using is a card based on the RTU8188SU chip that I found at the bottom of the box. You can purchase one from Taobao, and it doesn't require any additional drivers to work in Linux.
h) Audio adapter board, search for "APRS handheld radio to phone adapter" on Taobao (BH4TDV workshop). Also, TDV's products include TNC gateways and other APRS-related devices. If you don't want to assemble everything yourself, you can purchase the finished product directly.
i) Intercom handset cable.
- Software:
a) Operating System: DietPi, a mini system based on Debian, which is ideal for low-spec computers. Official website: https://dietpi.com/
b) Direwolf: Dire Wolf is an open-source software "sound card" AX.25 data modulator/TNC and APRS encoder/decoder. It can be used independently to monitor APRS traffic, as a tracker, digipeater, APRS-tt gateway, or internet gateway (IGate). Website:https://github.com/wb2osz/direwolf/
Next, I will guide you step-by-step through building this small base station from scratch. This requires some basic hands-on skills (soldering wires, which is not difficult), as well as some Linux fundamentals. If you have a foundation, you can better understand the process; if not, you should be able to succeed by following the steps one by one. When encountering problems, search online frequently. It seems that there are relatively few people in China who play APRS, possibly due to policy reasons. However, many people still play it abroad, so searching for information on foreign websites will make it easier to find answers to your questions.
First, let's look at two overall pictures so you can better understand it.


First, we need to set up the hardware:
- After receiving the 12V DC power, it first passes through two voltage reduction modules to supply power to both the Raspberry Pi and the handheld device (the handheld device can also directly purchase a converter from Taobao, which has a built-in 12V to 7.4V voltage reduction board).
- The Raspberry Pi has two USB ports: one for the wireless network card, and another for the USB sound card. Because I needed to connect a 3.5mm audio jack to the sound card afterwards, the space was a bit tight, so I directly soldered a wire to the USB port of the sound card.
- Raspberry Pi GPIO pins:
a) 5V + GND is the VCC + GND for the GPS module.
b) GPIO14 and GPIO15 are for the GPS module's RxD and TxD.
c) GPIO18, 3.3V, GND are the IN, DC+, DC- terminals of the relay module.
d) GPIO23 + GND is connected to one of the LEDs on the case. A 680-ohm resistor is connected in series between the positive terminal of the LED and GPIO23.
e) The indicator lights for the sound card and network card should be soldered to one of the LEDs on the case using extension wires.
f) Manufacture audio cables for K-head, and solder them onto the audio adapter board according to the defined cable order.



Next up are the software aspects:
First, install the operating system:
- Prepare an SD card with at least 8GB of storage (if using a Raspberry Pi 4B/3B, use a microSD card; the operation is exactly the same, so just follow along).
- Go to the official DietPi website to download the system image (remember to download the version that corresponds to your Raspberry Pi board). After downloading, extract it and save it as a backup. The filename should be DietPi\_RPi-ARMv6-Bookworm.img. If you have a Raspberry Pi 4, the corresponding filename is DietPi\_RPi-ARMv8-Bookworm.img.

- System flashing: Download Rufus portable version (official website:https://rufus.ie/zh/), insert the SD card, open Rufus:
a) Choose the SD card. If you have multiple USB drives or SD cards plugged into your computer, please make sure you select the correct one.
b) Choose the system image file that was just extracted.
c) All other settings remain default; click "Start" and wait for the process to complete.
d) After burning, do not immediately eject the SD card. Open the `dietpi.txt` file on the SD card using Notepad (Windows), and find...
Change `AUTO_SETUP_NET_WIFI_ENABLED=0` to `AUTO_SETUP_NET_WIFI_ENABLED=1`, save and close. This will automatically enable Wi-Fi on the first boot.
e) Then open the dietpi-wifi.txt file and find...
The line `aWIFI_SSID[0]=''`, within the single quotes after the `=` sign, should contain your Wi-Fi name. (Note that it appears to be case-sensitive and may not support Chinese; it is recommended to use an English network name.)
aWIFI_KEY[0]='', This line requires you to enter your Wi-Fi password within the single quotes after the '=' sign.
f) Other files should be left unchanged and closed.

- Remove the SD card from the computer, insert it into the Raspberry Pi, and power on.
- After a couple of minutes, connect to your router and check if the device named "DietPi" has obtained an IP address. Note down its IP address.
- Connect to the Raspberry Pi using an SSH tool (such as PuTTY), username: root, password: dietpi
- This requires a short wait; the system will run a series of scripts during its initial startup, so you don't need to interfere with it. However, be aware that during the first startup, it will connect to GitHub to obtain the latest version number. My home broadband connection (China Unicom) sometimes works and sometimes doesn't; try several times or at different times. If it still doesn't work, use a VPN. The specific steps are not included in this article, so I won't elaborate further; please search on Baidu.
- During this process, you will also be asked some simple questions, such as whether you would like to participate in user research or change the default password. Please take your time and carefully read the on-screen prompts, and make your selections accordingly.
- Then, you will be prompted to configure some software and hardware settings. In this case, we should keep all the default settings and simply select the last option "Install System" (as shown in the figure).

- Once everything is ready, you should see an interface similar to the one below, which confirms that the DietPi system has been successfully installed.

Next, we install the software. All subsequent operations will run with root privileges by default.
First, open the USB sound card and serial port:
dietpi-config
The following interface appears; select Audio Options -> Sound card


Select "hw:0,0 Device USB Audio", and press Enter to install.

Once completed, navigate back to the top level without exiting yet. Next, configure the serial port so that the GPS and Raspberry Pi can communicate properly.
Select "Advanced Options" on the top level.

Select "Serial/UART: Manage available devices"

Select according to the image; console selection: off, device selection: on

Once completed, navigate back to the top level using "Back", then exit.
At this point, you can verify your sound card by running the following commands to see if it correctly recognizes audio playback and recording devices.
aplay -l
arecord-l
If you see the following interface, then the sound card is working properly.

Then configure the domestic sources to enable faster software installation.
nano /etc/apt/sources.list
Change the file content to be as follows:
#deb http://raspbian.raspberrypi.org/raspbian/ bookwormmain contrib non-free
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/bookworm main non-free contrib
Then run the update command once: apt install update
Once completed, begin installing the software by running the following command:
apt install cmake make build-essential libasound2-dev udev-dev git gpsd libgps-dev gpsd-clients
This process will take some time, as it involves a first-generation Raspberry Pi. Just be patient and wait. The process will be much faster with a Raspberry Pi 4B.
Once everything has been installed correctly, you can configure the gpsd service.
nano /etc/default/gpsd
The content has been modified to:
START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyAMA0"
GPSD_OPTIONS="-n"
Configure gpsd to start automatically
dpkg-reconfigure gpsd
Running:
systemctl enable gpsd
systemctl start gpsd
Next, you can verify whether the GPS module is functioning correctly by entering the following command:
First, set the serial port baud rate to 115000.
stty -F /dev/ttyAMA0 115200
Then run the GPS client to view the GPS information.
cgps
If you see a lot of output scrolling, it means that the serial port and GPS module are communicating normally. Press the "q" key to exit the software.
Next, download and compile direwolf by running the following commands in order:
cd ~
git clone https://www.github.com/wb2osz/direwolf
cd direwolf
Sometimes, connecting to GitHub here can be unreliable; try a few times if you experience issues.
Once downloaded, you can proceed with compiling and installing it by running the following commands in order:
mkdir build
cd build
cmake -DUNITTEST=1 .. <-- Note: Don't forget the two ".." here.
make -j4
make test
make install
make install-conf
The compilation process for the Raspberry Pi 1B can be a bit slow. All of the commands above will take approximately 1 hour to complete, so just be patient and run one command at a time. If you're using a Raspberry Pi 4B, it will be much faster; you should be able to complete everything in about 20 minutes.
Once completed, you can try running it to see if it works correctly. To do this, run the following command:
direwolf -c direwolf.conf
Seeing information similar to the image below confirms that both the software and hardware are running correctly. The large amount of warnings above can be ignored; they simply emphasize not running with root privileges. If you have time, you can experiment with running the program as a regular user.

First, press Ctrl+C to exit.
Next, you can adjust the configuration file to ensure that the system runs as desired. Run the following command:
mv direwolf.conf direwolf.conf.bk
First, rename the original configuration file to save it as a backup.
Then create a new configuration file:
nano direwolf.conf
Next, I will explain each of them individually.
#使用GPSD服务
GPSD
#使用智能信标,下面的意思是运动时速大于60km/h时,每2分钟发送一次信标,低于5km/h时,15分钟发送一次。
#后面的应该是跟转向角度有关,具体没仔细研究,有兴趣的可以看看官方手册,不需要的请注释掉它
SMARTBEACONING 60 2:00 5 15:00 15:00
#日志配置,请在/root目录下手动创建log文件夹,它会每天创建一个日志文件
LOGDIR .
LOGDIR log-files
LOGDIR /root/log
#下面设置的是一些时间参数,比如发送正式数据包的前后发送多长时间的空码等
#因为树莓派的一些问题,貌似USB声卡会有一定的随机延迟,有时会把正式数据包的头给截掉
#这时可以适当演唱TXDELAY的值。具体的需要大家亲测,这里的数值是系统默认值
#x10 mSec per unit = 0 mSec.
DWAIT 50
#x10 mSec per unit = 100 mSec.
SLOTTIME 10
#probability for transmitting after each slottime.
PERSIST 63
#x10 mSec per unit = 300 mSec.
TXDELAY 30
#x10 mSec per unit = 100 mSec.
TXTAIL 10
#Half Duplex.
FULLDUP OFF
#声卡设置,如果你上面一直跟着我的步骤操作,0,0就对了,如果系统有多张声卡,请根据实际情况配置
ADEVICE plughw:0,0
#单声道还是立体声,这里我们用单声道即可。立体声是2
ACHANNELS 1
CHANNEL 0
#设置台站呼号
MYCALL NONAME
#调制解调器速率,对于大多数对讲机来说,设置1200就可以了,不需要修改
MODEM 1200
#PTT控制端口,如果按照我上面的硬件连接操作的,就是18,否则请根据实际情况修改
PTT GPIO 18
#数据载波指示端口(收到信标的时候会亮灯)。如果按照我上面的硬件连接操作的,就是23,否则请根据实际情况修改
DCD GPIO 23
#如果需要用APRS客户端来连接到本机,在这里设置端口
AGWPORT 8000
KISSPORT 8001
#APRS无线信标
#TBEACON 是GPS信标,当GPS成功定位后才会发送
#delay是当软件启动后延迟多少分钟开始发送信标,这里是1分钟,也可以写成1:00
#every是发送频率,这里是5分钟发送一次,也可以写成5:00
#symbol是在地图上显示的图标
#alt=1是发送海拔信息,如果不想发送设置为0即可
#freq 是
#comment是要发送的附加信息,用户手册上建议不要在此处写上频率信息,频率信息用freq参数设置
TBEACON delay=1 every=5 symbol="CAR" alt=1 freq=144.640 comment="APRS DIGIPEAT From RaspberryPi 1200bps"
#PBEACON是固定信标,比GPS信标多了lat、long、height等位置信息
#用TBEACON还是PBEACON可以自行决定
#PBEACON delay=0:30 every=1 symbol="CAR" lat=23^10.120344N long=113^17.119954E height=420 freq=144.640 power=05 gain=6 comment="APRS DIGIPEAT from RaspberryPi 1200bps"
#中继设置,如果要打开中继功能,则需要这行参数,可以照抄
#具体的参数含义我也没有仔细研究,有兴趣折腾的可以参考官方手册
DIGIPEAT 0 0 ^WIDE[3-7]-[1-7]$|^TEST$ ^WIDE[12]-[12]$ TRACE
#网关服务器设置
IGSERVER asia.aprs2.net:14580
#登录服务器的呼号及验证码,
IGLOGIN BD7IPA 123456
#向网关发送的信标信息,与APRS无线信标参数设置一样,可以自行调整。
#留意这里多了一个 sendto=IG 的参数,这就表明这个信标是发送给互联网的,不会发送到手台
TBEACON sendto=IG delay=1 every=5 symbol="CAR" alt=1 freq=144.640 comment="APRS iGate From RaspberryPi"
#PBEACON sendto=IG delay=0:30 every=1 symbol="CAR" lat=23^10.120344N long=113^17.119954E height=420 freq=144.640 power=05 gain=6 comment="APRS iGate from RaspberryPi 1200bps"
#Route to the gateway, copy as is, no need to modify
IGTXVIA 0 WIDE1-1,WIDE2-1
#Sending limits, restrictions to avoid excessive channel usage
#The two parameters correspond to the maximum number of transmissions that cannot exceed within 1 minute and 5 minutes respectively
#This indicates that no more than 6 transmissions can be made within 1 minute, and no more than 10 transmissions within 5 minutes. You can adjust these values according to your actual needs.
IGTXLIMIT 6 10
This software also has many configurable parameters that interested users can download from the official website. For example, parameters like IGFILTER are very useful and allow you to restrict the repeater to only receive information related to specific call signs.
https://github.com/wb2osz/direwolf/tree/master/doc
Next, if everything is OK, run:
direwolf -c direwolf.conf
I should be able to see my beacon on websites like aprs.cn in a short while.
Finally, let's set up the automatic startup.
First, install the screen software.
Install screen using apt.
After installation, run the following commands to edit the scheduled execution file.
crontab -e
Added two lines:
@reboot stty -F /dev/serial0 115200
* * * * * /root/dw-start.sh >/dev/null 2>&1
The first line indicates that the serial port baud rate should be set to 115200 each time the system is started.
The second line specifies that a script should be run every minute. If the `direwolf` script is already running, the process should exit. Otherwise, it should wait for 30 seconds before starting `direwolf`.
This ensures that the program can automatically restart if it crashes unexpectedly.
Each time it starts up, through
screen -D -r direwolf
The command can be used to view the status of a program's execution.
At this point, please do not use CTRL+C to exit, as this will interrupt the program.
If you want to exit the screen normally, simply press CTRL-A and then press the 'd' key.
Okay, that concludes all the steps for setting up an APRS gateway from scratch. I hope everyone can easily set up their own gateways.
73 BD7IPA