APRS igate installation guide

not for the faint of heart

M.T. Konstapel

2024-03-04

Abstract

This project is a collection of former (and some new) projects connected together to make an APRS digipeater, which doubles as an APRS weather station, with PE1RXF telemetry server capabilities.

Installation guide PE1RXF APRS igate and weather station

This guide assumes you are using the LoRa hat for the Raspberry Pi Zero from Mees Electronics.

Preparing the SD card

Download the latest 32 bit version of Raspberry OS. Do not use the 64 bit version. It will probably work, but some software I use might not work on 64 bit.

$ unxz image_name.img.xz
$ sudo dd if=image_name.img of=/dev/name_of_block_device bs=4M conv=fsync status=progress

Before the first boot

Mount the boot partition on a computer.

Create a file called “userconf” in /boot

$ nano userconf

This file should only have one line of text, with username:encrypted-password – that is, your preferred username, followed by a colon, and then an encrypted representation of the password you wish to use.

The simplest approach to generate the encrypted password is to use OpenSSL on a Raspberry Pi that is already running — Activate a terminal window and type: echo ‘frambozentaart’ | openssl passwd -6 -stdin This will generate what appears to be a random string of characters, but is really an encrypted version of the provided password.

This is the line that should go in userconf.txt:

taart:$6$wOOBx/uscFupsHDn$PSjutVwKxZyGa9.11NP/wpy4Wtn4qA0Xx3AY5KvuzmxOm7En5l2/O33yNWISmWxTlWHzLuVaPnJO0ccYVdDNu0

This defines user: ‘taart’ with password ‘frambozentaart’

Create an empty file called “ssh” in /boot

$ touch ssh

Create a file called “wpa_supplicant.conf” in /boot

$ nano wpa_supplicant.conf

Add the following text:

country=nl
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="Your WiFi Name"
psk="Your WiFi Password"
}

Insert the SD card in the Raspberry Pi and press the power button

During the first boot, the Pi will reboot once. Because of the external power button, this will not work: the Pi will shutdown. Power up the Pi by pressing the external power button again. (obsolete)

The Pi is booted for the first time

Search for the ip address of the Raspberry Pi (for exammple by logging into your router) and ssh into the Pi (user: taart, password: frambozentaart)

Create new user

$ sudo adduser user_name

Add the new user to all the groups of the default user (taart)

$ sudo nano  /etc/group

Replace taart by user_name ,taart (for example adm:x:4:taart becomes adm_x:username,taart)

Add user to sudo group

$ sudo usermod -aG sudo user_name

Reboot the system and log in as new user.

Test user’s sudo permissions by executing a random command as sudo (for example: sudo ls)

Remove default user taart

$ sudo deluser -remove-home taart

Disable auto-login.

$ sudo raspi-config

Set system-options / S5 Boot/Auto login / B1 Console

Login with ssh without password

Create key on local machine

$ ssh-keygen -t ed25519 -f ~/.ssh/aprs-weather-server -C "marcel aprs-weather-server-server"

Copy the key to the Raspberry Pi

$ ssh-copy-id -i ~/.ssh/aprs-weather-server.pub marcel@server_ip_address

Log in on the Raspberry Pi without password

$ ssh -o "IdentitiesOnly=yes" -i .ssh/aprs-weather-server <IP-adres>>

Optional: on the local machine edit .ssh/config and add the server/key combination. Now you can log in with just “ssh <server-name”

Housekeeping

Change login screen via motd (message of the day).

$ nano /etc/motd

Change hostname.

$ sudo nano /etc/hostname
$ sudo nano /etc/hosts

Setting the locale

$ sudo raspi-config

Edit Localisation options / change locale (en_US.UTF-8 UTF-8) And set time zone

For years now, Perl give Locale warnings. Fix it:

$ sudo nano /etc/default/locale

add:

LC_ALL=en_US.UTF-8
LANGUAGE=en_US.UTF-8

Update software

$ sudo apt-get update
$ sudo apt-get upgrade

Install firewall

$ sudo apt install ufw
$ sudo ufw allow ssh
$ sudo ufw enable
$ sudo ufw status

From a vanilla Pi to an APRS igate

Enable I2C RTC

$ sudo rapi-config

enable i2c

$ sudo reboot

$ sudo apt-get install i2c-tools

$ sudo i2cdetect -y 1

#68 is RTC

$ sudo nano /boot/firmware/config.txt

Add dtoverlay=i2c-rtc,ds1307

$ sudo reboot

$ sudo i2cdetect -y 1

If UU appears instead of 68 then we have successfully loaded in the Kernel driver for our RTC circuit.

Disable fake hardware clock:

$ sudo apt-get -y remove fake-hwclock
$ sudo update-rc.d -f fake-hwclock remove
$ sudo systemctl disable fake-hwclock

$ sudo nano /lib/udev/hwclock-set

Find

if [ -e /run/systemd/system ] ; then
    exit 0
fi

Replace with:

#if [ -e /run/systemd/system ] ; then
#    exit 0
#fi

Also comment out the two lines

/sbin/hwclock --rtc=$dev --systz --badyear

and

/sbin/hwclock --rtc=$dev --systz

Read RTC:

$ sudo hwclock -r

Set RTC from system time:

$ sudo hwclock -w

AX.25 support

$ sudo apt-get install libax25 ax25-apps ax25-tools
$ sudo nano /etc/ax25/axports

add:

ax0     PE1RXF-1        9600    255     2       144.800 MHz APRS (1200 bps)
ax1     PE1RXF-3        9600    255     2       433.775 MHz APRS (LORA)

Some commands must be called as sudo

but we don’t want to enter the password all the time. Especcially at boot time!

$ sudo visudo

Add:

marcel ALL = (root) NOPASSWD: /usr/sbin/kissattach
marcel ALL = (root) NOPASSWD: /usr/sbin/kissparms
marcel ALL = (root) NOPASSWD: /usr/bin/socat
marcel ALL = (root) NOPASSWD: /usr/local/bin/tncattach

1200bd packet modem

$ mkdir ham
$ cd ham
$ nano ~/ham/start_packetmodem_nano2.sh

Add (make sure USB port is correct):

#!/bin/bash

echo "Starting packet modem nano 2"

# Packet modem uses a CS340 chip, which does not have a serial number. If other USB devices
# with a CS340 chip are pluged in the software cannot distinquish between the various devices.
# But the modem is always connected to the same physical USB port. Use this port number
# instead of /dev/USBx.
serial_port=$(readlink -f /dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0-port0)
# Set serial port in RAW mode. Otherwise some charcters may be lost to the modem.
/usr/bin/stty -F $serial_port raw
sleep 1
sudo /usr/sbin/kissattach $serial_port ax0
sleep 1
sudo /usr/sbin/kissparms -p ax0 -t 500 -s 200 -r 32 -l 100  -f n

Make file executable:

$ chmod u+x ./start_packetmodem_nano2.sh

LoRa APRS modem

$ sudo apt-get install git
$ sudo raspi-config

Enable SPI

$ sudo apt-get install socat

clone LoRa driver:

$ cd ham
$ git clone https://git.meezenest.nl/marcel/RPi-LoRa-KISS-TNC.git

In start_all.sh the line with socat probably says ax2, change to ax1

Weather station

$ get the weather_station software, which is still under development (will be published on https://git.meezenest.nl/)

$ sudo apt install python3-pip

Install pythonax25, which can be found at ~/ham/weather_station/python-ax25:

$ cd ~/ham/weather_station/python-ax25
$ sudo ./install.sh

Install other libraries system wide, as the pe1rxf_aprs software has to run as root:

$ sudo pip3 install minimalmodbus --break-system-packages
$ sudo pip3 install retrying --break-system-packages
$ sudo pip3 install pyaml --break-system-packages
$ sudo pip3 install schedule --break-system-packages
$ sudo pip install aprslib --break-system-packages

Add /home/marcel/.local/bin to path:

$ nano .bashrc

add:
export PATH=/home/marcel/.local/bin:$PATH

Rnode

$ pip3 install rns --break-system-packages

If the Rnode modem firmware is not yet installed on the ESP32 board do:

$ rnodeconf /dev/ttyACM0 --autoinstall

Install tncattach:

$ cd ~/ham
$ git clone https://github.com/markqvist/tncattach.git
$ cd tncattach
$ make
$ sudo make install

$ mkdir ~/ham/rnode_hamnet
$ nano ~/ham/rnode_hamnet/start_rnode.sh

Add:

#!/bin/bash

# Set the Rnode in TNC mode on 434.25 MHz BW 500kHz Spreading Factor 7 Code Rate 4:5 Power 17dBm
# Ideally, this command should only be executed once.
/home/marcel/.local/bin/rnodeconf /dev/ttyACM0 -T --freq 434250000 --bw 500000 --txp 17 --sf 7 --cr 5

# Send station identification every 10 minutes
# mtu: 496 (PtP), 482 (ethernet) or 478 (ethernet with VLAN)
sudo /usr/local/bin/tncattach /dev/ttyACM0 115200 -d -e --mtu 482 --noipv6 --ipv4 192.168.44.2/24 --id PE1RXF -t 600

Make executable:

$ chmod u+x ./start_rnode.sh

Routing

To use this adapter for internet access change the default gateway:

$ sudo route add default gw 192.168.44.1 metric 30

This gives the new route priority, because the already defined default route has a metric of 100

Change metrics by removing the route and adding it again. The exammple makes the old gateway the one with the higest priority:

$ sudo route del default gw 192.168.44.1 metric 30
$ sudo route add default gw 192.168.44.1 metric 200

chech with:

$ ip route

And also, on the server site, enable forwarding and nat (NOT ON THE APRS IGATE

$ sudo iptables -A FORWARD -i eth0 -o tnc0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo iptables -A FORWARD -i tnc0 -o eth0 -j ACCEPT

NOTE: make these changes permanant….

$ sudo nano /etc/sysctl.conf

uncomment: net.ipv4.ip_forward=1

Maybe needed:

# Add the following statement somewhere at the beginning
# of /etc/dhcpcd.conf to prevent dhcpcd from changing MTU
denyinterfaces tnc0

Start script

$ nano ~/ham/start_aprs_server.sh

Add:

#!/bin/bash

echo "Starting AX.25 interfaces"
# initializing 1200bd packet modem
/home/marcel/ham/start_packetmodem_nano2.sh

# initializing LoRa modem
/home/marcel/ham/RPi-LoRa-KISS-TNC/start_all.sh

# initializing RNode network over LoRa
    echo "Starting LoRa network interface"
/home/marcel/ham/rnode_hamnet/start_rnode.sh

# Start weather station software
    echo "Starting weather station"
/home/marcel/ham/weather_station/start_weater_station.sh

And make executable

$ chmod u+x ./start_aprs_server.sh

Add to crontab:

$ crontab -e

Add:

# Start APRS server at boot time (for some reason a 60 second wait is necessary)
@reboot sleep 60 && /home/marcel/ham/start_aprs_server.sh

TODO:

network route over RNode if ethernet is down

Webinterface for sending and receiving messages over APRS (forward to e-mail?)

Backup SD card!

I use the script pishrink.sh to make an image.