Getting up an ADS-B receiver on a Raspberry PI

This post describes how I setup a basic ADS-B receiver on a Raspberry PI Zero W using a USB RTL2832U based Software Defined Radio so that you can see any ADS-B equipped aircraft in your local area and present it on your own website.

Equipment used

  1. Raspberry PI Zero W
  2. RPI Power supply
  3. SD card – I used a SanDisk Ultra 32GB UHS-1 card as I have a few as spares lying around but any one for a PI will do
  4. micro-B USB to USB A female cable to connect the SDR to the PI Zero
  5. Realtek RTL2832U based USB SDR. I had one on the shelf for a few years but you can get suitable ones for about £10-£20 online, think I paid about £15 for it
  6. USB keyboard, mini-HDMI to HDMI adaptor & HDMI cable (for setup only)

Now I used a PI Zero W was I wanted something small and dedicated to this but you can use any PI for this as long as there’s a network connection available for it (so a Zero W or a PI 2B & up)

Note: In this article I use vi as the editor, but there are others – the most common one used is pico which you might be more used to – just replace vi with pico in the commands below if you want to use that editor instead.

Initial setup

To setup the PI get the latest version of NOOBS from https://www.raspberrypi.org/downloads/noobs/ and install it on the SD card.

Next connect the keyboard, HDMI & SD card into the PI then plugin the power & turn on.

Once NOOB’s starts select Raspbian Lite – you don’t actually need to use a mouse here although some keyboards can accept a USB mouse or use a hub if you get stuck.

During the install It’ll ask you for the wifi details, just select the correct one and it will then download Raspbian Lite & reboot once it’s done.

Configuring the networking

Once Raspbian has booted you need to setup the networking, so login as pi with the default password of raspberry.

Right now change the password by typing

passwd

Then enter raspberry for the existing password & then choose a new one

sudo raspi-config

Select Network Options then Wifi then enter your Wifi SSID (it’s name) and password.

Optionally you can also select Hostname here & if your PI a more memorable name – advisable if like me you have quite a few!

Next go to Interfacing options and enable SSH so you can log in remotely.

Now reboot & log back in to the pi with the keyboard.

Now look for your IP address:

ip addr show

Under wlan0 you should see something like:

2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.2/24 brd 192.168.0.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever

192.168.0.2 is what you want so from your normal desktop machine:

ssh pi@192.168.0.2

IPv6 support

I use IPv6 on my local network so rather than using the DHCP address I use a fixed V6 address instead. Now if you use IPv6 then this will be created automatically however the default is for a random address to be generated every time. To get a static one based on the PI’s Mac Address, you need to:

sudo vi /etc/dhcpcd.conf
then find the following block:

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

and change it so it looks like this:

# Generate SLAAC address using the Hardware Address of the interface
slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
#slaac private

Once you have done this then reboot. Once it’s back when you run ip addr show you should see


inet6 2001:db8::ba27:ebff:fe11:2233/64

The important part if the ff:fe part which means the address is based on the mac address. I would then take 2001:db8::ba27:ebff:fe11:2233 and add it to my local dns then I can access the pi by name.

Software installation

Now the software:


sudo apt-get update
sudo apt-get install dump1090-mutability

When prompted if you want dump1090 to run on startup select yes

Next you have to add some rules to allow that program access to the sdr:

sudo wget -O /etc/udev/rules.d/rtl-sdr.rules "https://raw.githubusercontent.com/osmocom/rtl-sdr/master/rtl-sdr.rules"

Now shutdown the pi, unplug the HDMI & Keyboard and plugin the SDR into the USB socket, power it on and log into it from your desktop then run:


systemctl status dump1090-mutability.service

You should see something like:

The main part is that it states it’s active. If it states it’s failed or exited then there’s a permission problem – comment here if you hit that.

Next test it by running view1090-mutability which after a few seconds should show

Press Control C to exit that view.

Viewing on a map

If you’ve got this far then you should be able to view this on a map, simply enter http://192.168.0.2/dump1090/gmap.html into a browser (where 192.168.0.2 is your PI’s IP address, wrap withn [ ] if using IPv6, e.g. http://%5B2001:db8::ba27:ebff:fe11:2233]/dump1090/gmap.html) and you should get a map.

Right now it won’t be centred on your location as it’s got default config in it so zoom out then back in to where you are located and you should start seeing aircraft

Customising the map

There’s some simple config you can configure:

sudo vi /etc/dump1090-mutability/config.js

The useful settings in here are:

  • DefaultCenterLat & DefaultCenterLon – change these to a location near you so the map opens up centred on your location (you don’t have to be precise, I use my local town’s coordinates)
  • DefaultZoomLvl is the zoom level. I use 10 on the example below but you might find anything from 8 to 12 useful, depending on how far your receiver is picking up aircraft.
  • SiteShow – This defaults to false but if set to true then the SiteLat & SiteLon settings are used to show a marker of where you are. It’s also used to determine the distance of the aircraft from the receiver. Again you don’t have to be precise, especially if you don’t want people to know exactly where you are. SiteName is shown as the tool tip on the marker
  • PageName is shown on the page when a plane isn’t selected.

Performance

I’m using the standard tiny antenna that came with the SDR (which was originally marketed as a TV receiver) & that antenna isn’t suited for the 1090MHz used by ADS-B, but I do find it work’s pretty well as long as it’s high up.

I’ve got it in an upstairs window facing West so I tend to see as far as Billingshurst in Sussex about 70km away to the South West & to Huntingdon in Cambridgeshire 126.6km to the North West (the record I’ve seen so far). East doesn’t fair as much as the bulk of the house is in the way but I’ve tracked as far as Folkestone 44km to the South East.

If I used a proper antenna mounted outside I’d probably get further and more planes being visible.

Online Example

I’ve made my setup accessible online via https://adsb.map.lu/

This entire site is running on a Raspberry PI Zero W with some minor changes to the map, I’m using my own tile layers rather than the main OpenStreetMap ones (I’ve got a new set coming out soon, that’ll be in a future post) & I’ve removed the US only ones as no point in having them.

I’ve also made some changes to the lighttpd config so that the URL’s are more suited for a standalone website.

4 Comments

  1. This is cool. A lot of stuff in this post that I don’t understand, but what you’re doing looks interesting. I never heard of SDR before. I’ve looked it up and started learning about a lot of neat stuff that I never knew existed. I’m still a Pi n00b, so I’m just beginning to explore the many possibilities this device offers. Anyway, this was a very educational read for me.

  2. Are you posting data to Flightradar24 or Flightaware? I somehow managed to set mine up to both to both and I’m now scared to update anything incase I can’t do it again.

    1. I’m not but it shouldn’t be difficult. I did see there was a couple of entries in the config to set it up so I suppose you should ensure you have a backup first before trying to update it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s