Building an ADS-B receiver with a Raspberry Pi, a DVB-T stick and some bits._

🇺🇦 Resources to help support the people of Ukraine. 🇺🇦
August 15, 2014 @15:25
This post has been restored from an archived copy. Links may have changed or be broken.

Being a student pilot I have been aware of the FAA's NextGen project which happens to include ADS-B. Most of what I have been poking around at has been the in-cockpit stuff, evaluating various "ADS-B in" (broadcasts TO airplanes in flight) products that provide things like FIS-B and TIS-B (weather and traffic, for non-pilot types). A few months ago I ran into a number of projects for making receivers that allow you to receive the "ADS-B out" traffic (broadcasts FROM airplanes in flight) and was interested. I then found out that FlightAware (my favorite flight tracking website) is interested in consuming the data streams from ADS-B receivers. So I built one.

Step 1: Bill of Materials

QTY Description Source Net Cost
1 RaspberryPi Model B Kit Amazon $58.99
1 NooElec NESDR Mini USB RTL-SDR & ADS-B Receiver Set Amazon $21.95
1 4 port USB Hub Monoprice $3.70
1 TP-LINK TL-POE10R Gigabit PoE Splitter Adapter Amazon $13.99
1 Orbit 57095 Sprinkler System Weather-Resistant Outdoor-Mounted Control Timer Box Cover Amazon $28.87
1 IP67 RJ-45 weatherproof coupler Amazon $12.99
1 HABAmp 1090Mhz/ADS-B Filter & Preamp For Dongles HAB Supplies £50.39 (approx $92.00)
1 Humidity and Temperature Sensor Breakout - HIH6130 SparkFun $29.95

Add a handful of double sided tape, velcro, a few random barrel connectors, hookup wire, and a couple of RF pigtails (MCX to SMA and SMA to N female bulkhead) off eBay and you are ready to go.

Step 2: Assemble the hardware

Inside of the enclosure, top layer. Blurry cam shot of the inside of the enclosure, bottom layer.

So the pictures should speak louder than words but basically you want to connect everything up and make them fit in the box. I am intending to mount this outdoors so I added the temperature / humidity sensor to the enclosure. I am also not situated in the best location to get clear views of the sky so I am adding the low noise amplifier and filter along with a better antenna once I get all the bits in and move this outside. I am hoping this will help overcome the signal attenuation by the building and improve the effective gain on the USB radio

I ran the unit without the filter and with the stock antenna indoors on my desk for quite a while and I seem to get decent results. I get about 150km to the east and south but only to about 50km to the west. Given that my office is on the east facing side of my apartment, the results make a lot of sense.

FlightAware ADS-B Stats Indoors

Since I am powering all of this from the 5V output of the 802.3af (PoE) splitter, I wanted to know how much of the 15.4 watts of power I'm actually using.

PoE Power Consumption

A little over 6 watts isn't so bad, I'm impressed at the efficiency of the splitter.

Step 3: Install the software

I'm not going to go into huge details here, there are plenty of documents out there on how to setup the various pieces and parts, so I'll just link you to them.

Step 4: Monitoring Scripts

Since I am intending on putting this guy outside I did add a number of Nagios checks, and while a number of these are out of the scope of this, I'll talk a little bit about a couple of them.

ADS-B Nagios Checks

I'm using check_procs (a stock Nagios check) to look for the various daemons that need to be running for my feed to be up and going. I wrote a check to look at CPU temperature and at the temperature and humidity data from the HIH 6130 chip. All of these checks are run via NRPE so we'll start with the config for that:

/etc/nagios/nrpe.d/local.cfg:

# Process Checks
ncommand[check_procs_dump1090]=/usr/lib/nagios/plugins/check_procs -c 1:1 -C dump1090
command[check_procs_faup1090]=/usr/lib/nagios/plugins/check_procs -c 1:1 -C faup1090
command[check_procs_fr24feed]=/usr/local/bin/check_process fr24feed
command[check_procs_piaware]=/usr/local/bin/check_process piaware

# System Health Checks
command[check_rpi_temp]=/usr/local/bin/check_rpi_temp
command[check_environmental]=/usr/local/bin/check-hih6130.py

/usr/local/bin/check_rpi_temp:

#!/bin/sh

set -e

usage()
{
    echo "check_rpi_temp [-h] -c critical_temp -w warning_temp"
}

CRIT=140
WARN=110

_args=""

while getopts c:hw: _args; do
    case $_args in
    c)
        CRIT="$OPTARG"
        return
        ;;
    w)
        WARN="$OPTARG"
        return
        ;;
    *)
        usage
        return 2
        ;;
    esac
done

_cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
_cputemp=$(( _cputemp / 1000 ))
if [ "$_cputemp" -gt "$CRIT" ]; then
    echo "CPU Temperature $_cputemp is CRITICAL (over $CRIT)"
    exit 2
fi

if [ "$_cputemp" -gt "$WARN" ]; then
    echo "CPU Temperature $_cputemp is WARNING (over $WARN)"
    exit 1
fi

echo "CPU Temperature $_cputemp is OK."

/usr/local/bin/check-hih6130.py

#!/usr/bin/python -tt

import smbus
import sys
import time

BUS = smbus.SMBus(0)
DEV = 0x27
BUS.write_quick(DEV)
time.sleep(0.05)
data = BUS.read_i2c_block_data(DEV, 0)

health = (data[0] & 0xC0) >> 6
humidity = (((data[0] & 0x3F) < < 8) + data[1]) * 100.0 / 16383.0
tempC = ((data[2] << 6) + ((data[3] & 0xFC) >> 2)) * 165.0 / 16383.0 - 40.0
#tempF = tempC * (9.0 / 5.0) + 32.0

if health >= 2:
    print "HIH6130 DEVICE NOT READY."
    sys.exit(3)

if tempC >= 85.0:
    print "HIH6130 - CRITICAL TEMPERATURE %.2f degC" % tempC
    sys.exit(2)

if humidity >= 100.0:
    print "HIH6130 - CRITICAL HUMIDITY %i %%" % humidity
    sys.exit(2)

if tempC >= 65.0:
    print "HIH6130 - WARNING TEMPERATURE %.2f degC" % tempC
    sys.exit(1)

if humidity >= 85.0:
    print "HIH6130 - WARNING HUMIDITY %i %%" % humidity
    sys.exit(1)

print "HIH6130 OK - Temp %.2f degC, RH %i %%" % ( tempC, humidity )
sys.exit(0)

Conclusion

At the moment I still have the system sitting on my desk waiting for the last few bits before I go mount it outside but it's been a fun project so far and all-in-all fairly easy. If you decide to build one, dump1090 runs a web server on port 8080 and you can watch planes fly overhead! I often leave this open in a window behind everything else just so I can peek at it from time to time. Of course by 2020 all civilian aircraft in the US will have to be transmitting ADS-B, so when that happens I expect to see a lot more targets.

Once I get this outside and some data collected I'll post an update to see how the antenna and better sky view has affected my reception.

Comment via e-mail. Subscribe via RSS.