Posts tagged ‘APRS’

Create an iGate with a Raspberry Pi and an SDR

I’ve been developing iGates (internet gateways for amateur radio APRS messages) for a few years. The first version (now known as the Mk I) used the OLPC XO-1 and a radio. I built a bunch of these for people. I then tried using the XO-1 with the SDR (software defined radio) in place of the radio. The SDR is a USB device which receives a broad spectrum of radio waves and it is up to software to pick out the useful stuff. It worked but not very well. As the OLPC computers started to become scarce (or expensive) I redesigned the iGate to use a Raspberry Pi – hence the piGate (now known as the Mk II). These still used a radio. My ultimate goal was a very low power, inexpensive iGate. I finally have it!

I introduce the rpiGateSDR  Mk III (a title coined by the recipient of the first of these to escape into the wild).

IMG_3528

The new model using all new software. This resolved the performance problems and hard to source older SDR (with an E4000 chip). Additionally, a new generation of SDR (with an R820T2 chip) came on the market last year with slightly better noise filtering and marginally getter reception.

DISCAIMER: If you are not comfortable with basic Linux commands and you don’t know if you have an SSH nor where to find one, then this project probably isn’t for you.

Assuming you are still reading, let’s get to the project!

Here is my shopping list (with several options):

Depending on what pieces you need, the above can run to $85. If you need everything, I’d suggest the uber kit and the appropriate antenna adapter/pigtail will connect the iGate to your antenna.

That reminds me, you will need a good antenna. There are many options but I suggest a J-Pole. I picked one up from KB9VBR. There are now a few vendors selling on eBay or elsewhere on the internet for similar or less money. If you are need something a bit more flexible, you will lose a little efficiency but a Slim Jim J-Pole is a good option.

For the truly adventurous (or cheap), you can build this iGate with parts from AliExpress and save up to 50% and waiting 3 weeks for stuff to come from China. This uses the $15 Orange Pi PC and a $7 knockoff SDR which still uses the R820T2 chip.

OK, that’s all of the parts. Now what do you do with them?

The piGateSDR Mk III consists of Raspbian, the rtlsdr library, and DireWolf. There are instructions for manually creating the iGate on GitHub. To that work, I added a web server for monitoring the traffic and made the whole system read-only so it will be resilient to power failures.

I’ll assume you don’t want to be bothered with that and just want to download a complete image. (It tuned out the image was not compatible with an RPi1 or an OPiPC, or …. well, you get the idea, not to mention I continue to tweak the code so the image is no longer current or available.) Once you have downloaded the compressed image (approximately 380MB), unzip the file. Write it to a microSD card which is at least 4GB. (On Windows computers, I use Win32 Disk Imager).

The only things you MUST change are in the /etc/direwolf.conf file. You need to change  your callsign, APRS passcode, and the latitude / longitude of the location where the iGate has been installed.

Here is what the direworlf configuration file looks like:

#
# Configuration for SDR read-only IGate.
#

LOGDIR /var/log/direwolf

# We might not have an audio output device so set to null.
# We will override the input half on the command line.
ADEVICE null null

CHANNEL 0
MYCALL N0CALL-0

# First you need to specify the name of a Tier 2 server.
# The current preferred way is to use one of these regional rotate addresses:

#       noam.aprs2.net          - for North America
#       soam.aprs2.net          - for South America
#       euro.aprs2.net          - for Europe and Africa
#       asia.aprs2.net          - for Asia
#       aunz.aprs2.net          - for Oceania

IGSERVER rotate.aprs.net

# You also need to specify your login name and passcode.
# Contact the author if you can't figure out how to generate the passcode.

IGLOGIN N0CALL-0 000000

# That's all you need for a receive only IGate which relays
# messages from the local radio channel to the global servers.

PBEACON sendto=IG delay=0:30 every=15:00 symbol="igate" overlay=R lat=00.000000 long=-00.000000 COMMENT="optional message text here | DireWolf 1.3 on RPi+SDR"

You will first need to find the IP address of the Raspberry Pi. You can use a number of techniques. I use an App on my smartphone called Fing. You can also find it by looking at the device list of your router. (On my old Actiontec, it is listed under Gateway Utilization as LAN Device Session Log).

WARNING: The image is very unsecure. The root account password is ‘root’. I strongly suggest you change it.

You will need to SSH into the Raspberry Pi to make a few changes.

The image is distributed as small as possible, the initial partition has been minimized. The first task is to expand the micro SD card. You will you need to make the SD card writeable using the ‘rpi-rw’ command. Next, use the ‘raspi-config’ command to start the configuration tool and choose the ‘expand filesystem’ option. When you finish it will prompt you to reboot. Once it reboots, you will need to log in again and use the ‘rpi-rw’ command again since the pigatesdr always starts in read-only mode.

PITA ALERT: After the reboot from expanding the filesystem, use the command ‘df’ and look at ‘/dev/root’ and the value for ‘Use%’. If it still shows 100%, then you need to use the command ‘resize2fs /dev/mmcblk0p2’ to force the expansion of the filesystem and then reboot again.

At this point, you should be connected to the raspberry pi via an SSH connection, logged in as ‘root’ and enabled the SD card for edits using the command ‘rpi-rw’.

Stop the iGate program using the command ‘/etc/init.d/direwolf stop’ and you should see the message “Stopping direwolf”.

You need to edit the iGate configuration. Use the command ‘nano /etc/direwolf.conf’ (here is a nano editor cheat sheet). Time to make this iGate your own:

  1. change MYCALL to replace N0CALL-0 with your callsign followed by a suffix (this needs to be changed in two places(
  2. change IGLOGIN N0CALL-0 000000 to your callsign and suffix and your passcode (use this passcode generator)
  3. change PBEACON  ‘lat=’ and ‘long=’ values to be the location where the piGateSDR is physically installed
  4. change PBEACON   to edit or remove the ‘optional message text here’ (some examples include: the URL for an associated website, a frequency that gets monitored, or the name of a club or group which maintains the iGate)

OPTIONAL:

You may wish to determine any error in your SDR. Most SDR’s have a small amount of error which can be compensated using a PPM (parts per million) correction. To test your SDR, use the command ‘rtl_test –p’ and let it run for at least two minutes. IT will average the error and give you a PPM value for your dongle.

You need to edit ‘/usr/sbin/direwolf.sh’ (seen below) and change the value of ‘20’ following the ‘-p’ option to use your specific PPM value.

root@pigatesdr:~##! /bin/sh
mkdir -p /var/log/direwolf
rtl_fm -f 144.39M -p 20 -o 4 - 2>/var/log/direwolf/rtl_fm.log | direwolf -c /etc/direwolf.conf -t 0 -n 1 -r 24000 -b 16 - 2> /var/log/direwolf/error.log 1>/var/log/direwolf/output.log &

Once you are finished, return the SD card to read-only using the ‘rpi-ro’ command.

Now reboot using the ‘reboot’ command and you are ready to start gating APRS messages!

FYI: the piGateSDR has a built-in web server which you can reach by entering its IP address into a web browser on your network.

 

One last thing – if you want to have a static IP address, I recommend you use the DHCP reservation feature of your router rather than attempt to change the network settings on the Raspberry Pi. This way, the piGateSDR will be accessible even if you move it to a different network.

UPDATE (04-Jun-2016): I found an issue with logging. When the iGate runs more than a couple days without a re-boot, the RAM disk used for logging overflows and the iGate will stop working correctly. I’ve changed the log rotation schedule to retain less log data. I will update the image link above. When the new link is ready, I’ll add a new update notice here.

The ‘A’ in APRS, doesn’t stand for amateur but it is

Technically, APRS stands for Automatic Packet Reporting System. While the ‘A’ stands for ‘automatic’, the entire system is an amateur radio-based system.

I know a number of pilots who use APRS as a method of tracking their airplanes. It’s fun. I have a ‘tracker’ in my airplane.

However, some of those same people consider it a piece of safety equipment and that is probably a bit over reaching.

I recently reviewed a track of packets that spanned about three days. I noticed this track exhibited three of the common problems with APRS packets. Here are images of the three anomalies …

aprs-not-perfect

In the upper left image, the track and position look fine until you realize that timestamp was 14 hours old. It suggests the airplane fell out of the sky. In the lower right, it would appear the airplane was hovering at 4:30 in the morning but I know for a fact he was sound asleep safely on the ground. The right side image looks as though the airplane was flying back and forth.

If anyone was using the tracker data to locate the airplane, the data would put the search in the wrong places.

I will admit the above is a rare case. Most often these glitches are infrequent.

So, what caused these issues?

Well, the first image could be one of two problems. First, the tracker could have failed. Alternately, there were no iGates (ground stations) in the area. I know this is an example of the latter.

What about the second image?

This is an example of an iGate delaying a packet. It is probably the most extreme case I have detected. Normally, when a packet is delayed, the result is the image on the right. Imagine removing all the lines and just leaving the dots then connecting the dots in the most obvious sequence. The resulting track is what the plane was actually flying. However, when the packets are received out of order – in this case that would be 1, 3, 2, 6, 4, 5, 8, 7, 10, 11, 12, 9, 13, … – the track jumps all over the place. The problem is not the transmitter but rather the iGates processing the packets to the internet. Some internet sites attempt to filter out these issues.

So my advice to everyone is to remember APRS is an amateur activity and is not guaranteed. Enjoy it but don’t bank your life on it unless you can verify its does what you expect.

piGate, piGate – get your Raspberry Pi iGate here !

I’ve create a downloadable image of the Raspberry Pi SD card with all of the installed and configured software for an iGate. I’ve also created a short video walking a user through the setup process.

UPDATE UPDATE UPDATE !!! Read to the very end. Things have changed as of 28-July-2014)

pigate-kitThe complete set of parts was detailed in my piGate post.  A few people asked for a copy of the SD card. I decided I would create a new piGate from scratch to insure I have all of the instructions and didn’t forget any steps.

I started with PA0ESH’s article. Erik has written and updated a PDF of the steps he used to create his iGate. The most recent version I found has “Sunday, 8 December 2013” near the top of the PDF. As a precaution, you can find a copy here.

Note: Erik has since published a guide and an install script which uses DXIPRS for the iGate. I stayed with APRX as my iGate software because I have used it for more than 20 iGates and it has been very stable and easy.

I use Win32 Disk Imager to create the initial SD card. I also use a simple ping tester which will quickly ping a range of IP addresses and tell me which ones reply. There are versions for Windows, Mac, and I have one on my iPhone. I use KITTY for my SSH terminal.

Addendum: For Windows users, here is a command that will help find the IP of your Raspberry Pi once it has booted:

FOR /L %x in (1,1,255) do ping -n 1 192.168.2.%x | find /I “reply”

 

After downloading the most recent Rasbian image from the internet, I write it to the SD card, insert the SD card into a Raspberry Pi, connect an Ethernet cable, and add power. I use the ping tester to locate the likely IP address(s) for the Raspberry Pi and then start KITTY with each IP address until I get the right one.

Once I have the SSH session, I use the default Rasbian account which is user=pi, password=raspberry. I run the command raspi-config and set the timezone, locale, and hostname. I did not expand the filesystem to fill the SD card but that was only because I was hoping to make the compressed download of the finished image as small as possible. It did help a little. For my own use, I would expand the filesystem.

With the base operating system up-to-date, I started with Erik’s instructions.

The first deviation I made was to not make the change to downgrade the USB from USB 2.0 to USB 1.0. The change was not needed with the USB audio adapter I used.

An improvement I made to the instructions occurs at the step to use arecord to test the configuration thus far. I used the Pofung radio set to 1/4 volume and connected with the audio cable to the microphone input on the USB audio adapter. I launched a second SSH window to the Raspberry Pi. In the second window, I started alsamixer. I started arecord in the first window. I then used alsamixer in the second window to adjust the CAPTURE level, while watching the character based VU meter from arecord. I adjusted the level until the meter was about 80% and not over modulating. Then I exited both programs, deleted the test recording, and closed the second SSH window.

When creating the ax25-up and ax25-down scripts, I gave then the “.sh” extension because that is what I usually do. No reason beyond my personal preference.

At the end of Erik’s guide, he describes generating a website using txt2html and a cronjob and a lot of steps. I went a much simpler route. I setup a CGI perl web page that sucks in the aprx-rf.log file on-the-file. This means, anytime the webpage is refreshed in the user’s browser, it has the most recent log data. There is not need to convert or have a scheduled job to convert stuff. I did need to create a symbolic link from /var/log/aprx to /var/www/aprxlog to make the logs accessible to the lighttpd web server.

To help keep the logs manageable, I setup log rotation for APRX logs. Here is the contents of /etc/logrotate.d/aprx

/var/log/aprx/*.log {
        daily
        rotate 2
        size 8k
        nocompress
        missingok
        notifempty
        create 644 root adm
}

Of course, you can skip all of that work and just download the 7z compressed piGate image (updated 25-Sept-2014) I created of the final product !

Watch the instructional video for setting up a iGate using my piGate image or download (50mb) a copy for reference.

UPDATE: 28-July-2014

One thing that I’ve experienced on more than one occurrence is a corrupted SD carad because of unexpected or incomplete shutdown. To mitigate this problem, I went through multiple writ ups to make the piGate SD card read-only for runtime. It turns out to be a bit messy to get right because various applications and start-up tasks assume the system is read-write.

The four hurdles were to first get the Raspbian operating system to function with the boot partition as read-only. Next was to get the iGate software working and logging to a ramdisk. Third was the little web server which makes reviewing the iGate log easy with a web browser. And forth was getting DHCP networking to behave.

The new compressed image (updated link above) has everything working so you don’t need to be bothered. The only new steps are the presence of rpi-ro and rpi-rw commands. Anytime you need to edit a file on the Raspberry Pi, you will need to make it read-write before you edit files and then make it read-only after. For example, to change the /etc/network/interfaces file to configure WiFi or to set a static IP address, you will run three commands: rpi-rw then nano /etc/network/interfaces then rpi-ro. I’ve updated the instructional video with this example.

a Raspberry Pi iGate which meets performance specs

My supply of OLPC XO-1 laptops has really dried up. I currently have two – the one that has faithfully been running my iGate for the past 3 years and a backup just in case.

Over the past 9 months, I built 15 iGates using that design. eBay was a good provider Smile

I still get requests for iGates. Given the laptop was the only “used” item, I started looking for a solution that was 100% off-the-shelf new parts. The Raspberry Pi was the logical choice.

pigate

After months of experimenting with combining a Raspberry Pi with and SDR (software defined radio), I concluded the design worked but required strong, nearly perfect radio transmissions. Since APRS is predominantly transmitter in motion, the signals are rarely perfect and seldom strong. Eventually, I caved to the realization that – while I could build such an iGate – it would not perform.

I went back to the drawing board and took my tried and tested iGate design. The laptop has four useful components built it – a computer, a screen, a keyboard, and wireless. While I could add all of those to a Raspberry Pi, it didn’t work from a cost stand point. With some basic computer skills, a “terminal” connection using SSH from a regular computer can access the Raspberry Pi to do the minimal configuration needed. That eliminated the need for a screen and keyboard. The network option of a wired connection vs a wireless connection was nearly 50:50 with the people who wanted and iGate – thus I consider it an option rather than a required part.

In the end, I was able to create an iGate using a Raspberry Pi that has the same software architecture of the XO-1 Laptop. I used Debian as the base linux operating system. I Used Soundmodem which turns a sound card into a TNC. I used APRX for the iGate software. I used a low cost handheld HAM radio to receive the transmission.

Here is a list of all the components which can be sourced from Amazon.com. If you had nothing lying around and you had to purchase everything, the cost is 47+5+4+5+4+30 = $95. Included in these prices is the antenna adapter for the radio. I included it because nearly everyone who asked for an iGate needed that adapter. FYI – The pictured system has an beefier radio (+$9) and WiFi (+$9).

I have an image of the final SD card. After I run it for a week as my primary iGate, I will de-personalize it, compress it, and try to post it to this blog.

Addendum: If you want more USB ports and want to avoid the SD card sticking out, there is the new Raspberry Pi Model B+ ($46) which uses a microSD card and has 4 USB ports. It does require a different case which have limited choices but expect the availability of the B+ and cases to become more prolific in the near future.

iGate Factory – current customers

Six months ago I offered to help some people setup iGates (internet gateways for APRS traffic). I quickly realized that what I needed to do was offer complete pre-built systems which were a close to “plug-in and go” as possible.

I’ve shipped out twelve systems (and have two still available). I could build more but there does not appear to be enough interest to invest in inventory.

Here are some interesting statistics …

  • 3 iGates have never been turned on
  • 4 iGates were shipped in the last 15 days
  • 5 iGates have relayed a total of 80,000 messages in the past 28 days (2 of the iGates account for 50,000 of those messages)

igates-20140428

The $75 iGate – (geek skills required)

I have successfully created an APRS iGate using a Raspberry PI, RTL-SDR, mini WiFi adapter, SD card, and 5v micro-USB power supply.

 

I used several set of instructions from the internet including Marco Kubon’s blog post, Jason Fitxpatrick’s How-to-Geek wifi article, ReadiesCards thread on mini-httpd,  and various debugging techniques that are best found by using Google if and when a problem exists.

The only reason I have the HTTP server integrated into the iGate is to make it easy to check the logs using any web browser, including from my iPhone and iPad. All maintenance is done using SSH. Like I said, “geek skills required”.

The hardware is all commonly available:

FYI: The cheaper and more common R820T based RTL-SDR dongles may work but I started with one of those and had issues. Then I switched to the E4000 tuner and managed to get things working. I did not go back and try to get the R820T based dongle working. Read into that what you want but given how much time I wasted on this project, I have not had the energy or desire to do more experimenting.

The one thing I will conclude with is that I do not yet fully trust this iGate. It seems stable but more than once – while getting the system working – I’d start up the software and it would not receive any messages. I think most of the issues are the lousy test antenna but I won’t know until I drop this in place of my stable 2m-radio based iGate.