Tag Archives: sdr

Tracking gliders, airplanes, helicopters and baloons, part 3 – FLARM

We already know how to track airplanes using DVB-T USB dongle and Orange Pi or Raspberry Pi. Let’s move on to a new system that allows tracking of light aircrafts:

  • gliders
  • helicopters
  • baloons
  • smaller airplanes
Sender/reciever for glider (photo by: Sebastian Lampart)
Sender/reciever for glider (photo by: Sebastian Lampart)

FLARM – is a collision avoidance system for light aircrafts, popularized and approved by EASA, gaining traction, used mainly on gliders in Poland and Europe. We’re not going to use it to avoid collision – but to receive position and track light aircrafts – so we can share them on the OGN procest’s map – OPEN GLIDER. There are few station in Poland – let’s build a more robust network, so that gliders can be safer and their records – recorded.

What will you need?

Hardware:

  • Orange Pi Zero or RPI Zero W” rel=”noopener” target=”_blank”>Raspberry Pi Zero W
  • DVB-T USB Dongle. Look for the upgraded version in blue chassis – AKA “DVB-T RTL2832U+R820T2” – it offeres better sensitivity in interesting frequency – and will give you extra range. The most important part in that equation is the new R820T2 (version ‘2’) and of course the included antenna
  • Micro SD – could a cheap 8G for $4, but better is to use Sandisk Extreme/Ultra – at least 4GB
  • Power supply – at least 1.5 to 2A @5V with micro USB (i.e.: old charger from cellphone)
  • Two small heatsinks (radiators) for CPU and controller – for Orange Pi Zero
  • ALTERNATIVE: Raspberry Pi 2 or 3 – they have enough of CPU power, but triple the price
  • Antenna 868MHz. The one you got with USB dongle is OK for start – gives me around 50km of range without any modification. You can cut it to the lenght of single segment

Software:

    li>Armbian for Orange Pi – the best at this point is to use the Xenial NIghtly, developer/beta version, with 4.9.x kernel from https://www.armbian.com/orange-pi-zero/
  • ogn-decode i ogn-rf – software to be downloaded – ARM CPU version
  • Free ports on the Orange Pi/Raspberry Pi – 8080 and 8081 – if there’s nothing else there installed – they should be free to use.
Cokpit with FLARM  (photo by: Sebastian Lampart)
Cokpit with FLARM  (photo by: Sebastian Lampart)

Installation

First – if not installed already – we need SDR and some system libraries as well as binaries from glidernet.org:

cd /home/pi
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install rtl-sdr
sudo apt-get install libconfig-dev fftw3-dev libjpeg-dev libconfig9 libjpeg8

To allow usage of the raw feed from airplanes we need to turn off the automatic loading of the DVB-T:

nano /etc/modprobe.d/rtl-sdr-blacklist.conf

paste:

blacklist dvb_usb_rtl28xxu
blacklist e4000
blacklist rtl2832
blacklist r820t
blacklist rtl2830
blacklist dvb_usb_rtl28xxu
blacklist dvb_usb_rtl2832u

Reboot the Orange Pi/Raspberry Pi
Now, lets download from glidernet.org the correct file, unpack it:

wget http://download.glidernet.org/arm/rtlsdr-ogn-bin-ARM-latest.tgz
tar xvzf rtlsdr-ogn-bin-ARM-latest.tgz

Create a FIFO to allow communication between both parts of the OGN software:

cd rtlsdr-ogn
mkfifo ogn-rf.fifo

View from glider (photo by: Sebastian Lampart)
View from glider (photo by: Sebastian Lampart)

Next, calibration of the USB dongle – cheap DVB-T USB tuners are not always good at tuning with high precision to given frequency – we need to correct the skew. To do that use the gsm_scan, that will give the ppm and gain correction values:

cd rtlsdr-ogn
./gsm_scan --ppm 50 --gain 20

Change values so that the deviation is around 10ppm (check the best GSM frequency GSM) – write them down.
Create own configuration based on the example:

cp Template.conf EPXX_OGN.conf
nano EPXX_OGN.conf

The example file contents based on my tuner: enter CORRECT values for FreqCorr, GSM: CenterFreq Gain – based on gsm_scan:

RF:
{
  FreqCorr = +87.060;          # [ppm]      "big" R820T sticks have 40-80ppm correction factors, measure it with gsm_scan

  GSM:                     # for frequency calibration based on GSM signals
  { CenterFreq  = 938.4;   # [MHz] find the best GSM frequency with gsm_scan
    Gain        =  25.0;   # [dB]  RF input gain (beware that GSM signals are very strong !)
  } ;
} ;

Position:
{ Latitude   =   +51.1514; # [deg] Antenna coordinates
  Longitude  =   +18.4642; # [deg]
  Altitude   =        150; # [m]   Altitude above sea leavel
  GeoidSepar =         48; # [m]   Geoid separation: FLARM transmits GPS altitude, APRS uses means Sea level altitude
} ;

APRS:
{ Call = "EPXX1";     # APRS callsign (max. 9 characters)
                      # Please refer to http://wiki.glidernet.org/receiver-naming-convention
} ;

Finally – start in background two programs using very basic (or other by your choosing method) thanks to cron:
Create two files:

cd /home/pi
nano /home/pi/rtlsdr-ogn/run_ogn-rf

with:

#!/bin/bash
cd /home/pi/rtlsdr-ogn
/home/pi/rtlsdr-ogn/ogn-rf /home/pi/rtlsdr-ogn/EPXX_OGN.conf

Add rights to execute:

chmod 755 /home/pi/rtlsdr-ogn/run_ogn-rf

Second file:
nano /home/pi/rtlsdr-ogn/run_ogn-decode

with:

#!/bin/bash
cd /home/pi/rtlsdr-ogn
/home/pi/rtlsdr-ogn/ogn-decode /home/pi/rtlsdr-ogn/EPXX_OGN.conf

Rights to execute:

chmod 755 /home/pi/rtlsdr-ogn/run_ogn-decode

Now edit your crontab:

crontab -e

Wklejamy:

*/5 * * * * if [ `pgrep ogn-rf | tr '\n' ' '| awk '{print $1}'` ]; then echo "ogn-rf works"; else screen -dmS ognrf /home/pi/rtlsdr-ogn/run_ogn-rf; fi > /tmp/ognrf.log 2>&1
*/5 * * * * if [ `pgrep ogn-decode | tr '\n' ' '| awk '{print $1}'` ]; then echo "ogn-decode works"; else screen -dmS ogndecode /home/pi/rtlsdr-ogn/run_ogn-decode; fi > /tmp/ogndecode.log 2>&1

Of course in our example we’re using username “pi”.
Verify the operation by attaching screen: screecn -r XXX, or enter the URLs in we browsers: http://ADDRESS_OF_PI:8080/ oraz http://ADDRESS_OF_PI:8081/. Your station will be listed at: http://ognrange.onglide.com/, along with the range. Since FLARM changes – check every 6 months for new version.

That’s it!

Glider's tail (photo by: Sebastian Lampart)
Glider’s tail (photo by: Sebastian Lampart)

Tracking airplanes with ADS-B & MLAT revisted- building a better and cheaper reciever for Flightradar 24 and Flightaware

[Update 2017-08-22 – Sharing data with friendly radars]
A lot has changed since the last entry about tracking the aircraft using ADS-B messages. There are new options for data sharing, greatly simplified installation procedure and – optionally new equipment. This allows you to build a new receiver with an emphasis on simplicity, yet lower cost of purchase and maintenance with new feature (MLAT). Moreover, in addition to the aircraft you can now track other aircraft – i.e. meteorological balloons! I call that progress!

Malasian 747 @ RNAV
Malasian 747 @ RNAV – picture thanks to first run of FR24

What will you need?

Hardware:

  • Orange Pi Zero. It’s a competition to Raspberry Pi – board that gives a lot for $10 – four CPU cores, 256 or 512MB RAM. Onboard you will find Ethernet and WiFi along with single USB. There’are extension available – extra USB/IR/CVSB Out HAT or new USB2SATA HAT
  • DVB-T USB Dongle. Look for the upgraded version in blue chassis – AKA “DVB-T RTL2832U+R820T2” – it offeres better sensitivity in interesting frequency – and will give you extra range. The most important part in that equation is the new R820T2 (version ‘2’) and of course the included antenna
  • Micro SD – could a cheap 8G for $4, but better is to use Sandisk Extreme/Ultra – at least 4GB
  • Power supply – at least1.5 to 2A @5V with micro USB (i.e.: old charger from cellphone)
  • Two small heatsinks (radiators) for CPU and controller – for Orange Pi Zero
  • ALTERNATIVE: Raspberry Pi 2 or 3 – they have enough of CPU power, but triple the price
  • In summary: Our new reciever should be around 25-30$ in total!
Orange Pi Zero
Orange Pi Zero

Software:

  • Armbian for Orange Pi – the best at this point is to use the Ubuntu Xenial with legacy kernel, you can also try developer/beta version, with 4.9.x kernel. Go to https://www.armbian.com/orange-pi-zero/
  • piaware and fr24feed – software to recieve, decode and share the data about plane flyovers. Free ports on the Orange Pi – 8080 and 3000-30010 – if there’s nothing else there – they should be free to use.

MLAT – new functionality

MLAT is short for multilateration. Airships without ADS-B transponders do not advertise their latitude and longitude, so the Mode S they use is not useful for us. Thankfully those Mode S transponder messages can be used by means of multilateration – based on the delay of the received messages in at least 3 different receiving Mode S. A very precise clock synchronization is required – which means you have another oportunity to ask friends living so-so close by to start their own radars!

BAE 747
BEA 747 – fantastic visability at that day

Orange Pi Zero

As you noticed – we have been using mainly Raspberry Pi. The unprecedented success of this small computer spurred a number of “compatible” boards – Orange Pi Zero is very cheap, able, but the software is not yet quite there or stable. Well, it’s whatever $10 can buy!

The antenna

Start with the included antenna. Next use google to find out the optimal length – and cut it. From there to increase coverage – you will ned to dive into the wonderful world of pro antennas!
The roof top is the best place for antenna, but don’t forget that if you place your Orange Pi in the attic – it may get very hot!

Installation

Before first run of the Orange Pi Zero – please install the heatsink on the H2+ CPU, and on the chip next to it. With the heatsinks and no chassis the CPU works at 42-48C. Without it 60-65C – which can shorten the life of both Orange Pi and the micro SD card.

Let’s install – just as in the first blog entry about SDR – Armbian  with 4.9.x (Xenial) – using dd or win32diskimager.

On the first run Armbian allows you to login as root with the password “1234”, and immediately asks to change this default password, and create a user. Could be ‘pi’ user of course.

Let’s login now as pi and change the credentials to root:

sudo su -

Now – every commend we issue we do it as root, so be careful!

First: update and upgrade of the armbian system.:

apt update && apt upgrade

To allow usage of the raw feed from airplanes we need to turn off the automatic loading of the DVB-T:

nano /etc/modprobe.d/rtl-sdr-blacklist.conf

and paste:

blacklist dvb_usb_rtl28xxu
blacklist e4000
blacklist rtl2832
blacklist r820t
blacklist rtl2830
blacklist dvb_usb_rtl28xxu
blacklist dvb_usb_rtl2832u

Next comes the Flightaware – Pi Aware software – first part of our radar:

wget http://flightaware.com/adsb/piaware/files/packages/pool/piaware/p/piaware-support/piaware-repository_3.1.0_all.deb

Install it:

dpkg -i piaware-repository_3.1.0_all.deb
apt update
apt install piaware
apt install dump1090-fa

Add auto upgrade of the piaware itself:

piaware-config allow-auto-updates yes
piaware-config allow-auto-updates yes

Now let’s turn to Flightradar24:

sudo bash -c "$(wget -O - http://repo.feed.flightradar24.com/install_fr24_rpi.sh)"

As with the first blog entry – please enter your data, key. postion of the antena.
Let’s connect FR24 with Pi Aware:

nano /etc/fr24feed.ini

and paste:

receiver="avr-tcp"
fr24key="YourFr24Key"
path="/usr/bin/dump1090-fa"
bs="yes"
raw="yes"
logmode="2"
mlat="yes"
mlat-without-gps="yes"

Enable’em all!:

systemctl enable piaware
systemctl enable fr24feed

reboot:

reboot

After reboot – check out your new map!

http://ip_address_of_orange_pi:8080/

Example:

Prezentacja odebranych danych z mapą z dump1090-fa
Data presentation using dump1090-fa

Go ahead and check this US military airplane… Nice example why MLAT is usefull! Couple of minutes later I found out circling… AWACS

Status “fr24feed” i “piaware” can be seen here:

tail -f /var/log/fr24feed.log /var/log/piaware.log

Or

piaware-status

That is it!

Sharing data with friends

Together we are strong! There’s always someone who has resources, server and is able to recieve multiple radar data and present them on web. Usually, by sharing you will get the access to such service, also to the data that is based on MLAT. How to connect? You should get the IP address and port (socket) from the server provider to connect to – all you need to do is one line to redirect (copy actually) the traffic and data from your radar.
First let’s install socat

apt-get install socat

Now – test the connection:

/usr/bin/socat -d -T 90 TCP4:localhost:30005 TCP4:IP_ADDRESS_OF_SERVER_WITH:PORT

If that works fine – break the operation using CRL+C and set-up the permanent connection via crontab:

crontab -e

add line:

*/20 * * * * /root/bin/share_flight_data.bash

Now crate the file/root/bin/share_flight_data.bash:

mkdir -p /root/bin
touch /root/bin/share_flight_data.bash
chmod 755 /root/bin/share_flight_data.bash
pico /root/bin/share_flight_data.bash

Put in the file:

#!/bin/bash
if [ `/usr/bin/pgrep -f "friend_feed_port_30005" | /usr/bin/tr '\n' ' '| /usr/bin/awk '{print $1}'` ]; then echo "friendly_feed works"; else /usr/bin/screen -dmS friend_feed_port_30005 /usr/bin/socat -d -T 90 TCP4:localhost:30005 TCP4:IP_ADDRESS_OF_SERVER_WITH:PORT; echo "Starting  friend_feed_port_30005"; fi >> /tmp/share_data.log 2>&1

That’s it – every 20 minutes the system will check if the feed works.