Monday, November 13, 2017

Software Defined Radios With a Macbook Pro

I finally succumbed to the temptation and bought a couple of RTL SDR dongles.  These thingies are so cheap, they really open the art of amateur radio to the masses again.


CubicSDR on a Macbook Pro

These gadgets are wide band digital receivers, which make them much fun.  Effectively, RTL-SDR with CubicSDR provides you with a wide band DIY Spectrum Analyzer that works from about 1 MHz all the way up to about 3 GHz.

Read all about RTL-SDR here:
https://www.rtl-sdr.com/

If you have no idea what to do with SDR toys, go here:
https://www.hfunderground.com/board/

or here:
https://amsat-uk.org/funcube/funcube-dongle-sdr/

or, of course here:
http://www.aeronetworks.ca/2017/07/cube-satellites.html

BTW, if you use Linux or BSD, skip to the bottom of the page.

Where to Buy an SDR Widget

Get your own RTL-SDR kit for the enormous sum of $26 here:
https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/

For a proper transceiver, you can get the HackRF wotzit at Sparkfun, but it costs a rather more hefty amount - about 10x more:
https://www.sparkfun.com/products/13001

Receiver Software

On my Macbook Pro, the CubicSDR program works like magic.  I can sincerely recommend using it:
http://cubicsdr.com/

There are a few things I would like to do with these SDR thingies:
  • Hook to my BitX40 radio to verify the HF performance at 7 MHz, 
  • Listen to ATC aircraft band radio at 118 to 136 MHz and 
  • Decode ADSB from ATC transponders at 1090 MHz.
  • Decode GPS at 1575.42 MHz
The receiver is wide band so things fold back, which makes it a bit confusing, but even the simplest antenna will pull in many FM stations.  I would recommend using a tuned antenna for HF listening though.

AM and FM Radio

So far I managed to tick off the BitX40 (and Abu Dhabi Classic!) with CubicSDR.  This should also work with the ATC voice radio band, I just haven't gotten round to trying it yet.

Air Traffic Control ADS-B Transponders

For Air Traffic Control transponder ADS-B information, I experimented with Cocoa1090:
http://www.blackcatsystems.com/software/cocoa1090.html
http://www.blackcatsystems.com/software/cocoa_rtl_server.html

Start the server first and connect to the dongle, then run cocoa1090.

The frequency is of course 1.090 GHz, so a half wave dipole antenna needs to be 275 mm overall, or each 1/4 wave arm needs to be138 mm.  Grab a ruler and tweak the telescopic antenna that you got with the SDR for best results.

However, I got absolutely sweet nothing, even when I was at the airport and could see and hear the aircraft!

Get rtl-sdr with Mac Homebrew

In desperation I tried homebrew for the rtl-sdr package.  It should provide the following command line utilities:
  • rtl_adsb: a simple ADS-B decoder for RTL2832 based DVB-T receivers
  • rtl_eeprom: an EEPROM programming tool for RTL2832 based DVB-T receivers
  • rtl_fm: a narrow band FM demodulator for RTL2832 based DVB-T receivers
  • rtl_sdr: an I/Q recorder for RTL2832 based DVB-T receivers
  • rtl_tcp: an I/Q spectrum server for RTL2832 based DVB-T receivers
  • rtl_test: a benchmark tool for RTL2832 based DVB-T receivers
So here goes nuthin: 
# brew install rtl-sdr

It did something, but with Homebrew, it is always hard to figure out what exactly went down.

# rtl_test
-sh: rtl_test: command not found

Grrr... not totally unexpected though.  Homebrew and I respect each other, but we do not speak the same language.


Get rtl-sdr With Macports

Next, I tried Macports https://www.macports.org/ and update it, since I already have it installed:

$ sudo port -v selfupdate
sudo: port: command not found

Aargh...

Why is everything so clunky on my Mac?  I can add /opt/local/bin to the path, but that is also a security concern.

Let's try again, this time with the full path to the utility:
$ sudo /opt/local/bin/port -v selfupdate

and this time it worked.

Try to install the rtl-sdr package:
$ sudo /opt/local/bin/port install rtl-sdr
Error: The installed version of Xcode (7.3) is too old to use on the installed OS version. Version 8.2.1 or later is recommended on Mac OS X 10.13.

Bah, humbug...

Open the App Store, search for xcode and Get it all over again, which of course takes foreeever (TM)...  So I clicked the Caffeine coffee cup to keep the Mac from going to sleep and let it upgrade overnight.

Then try to install the rtl-sdr package again:
$ sudo /opt/local/bin/port install rtl-sdr
--->  Computing dependencies for rtl-sdr
The following dependencies will be installed:
 bison
 bison-runtime
 bzip2
 cmake
 ...
Continue? [Y/n]: y

...
Fetching - installing... getting somewhere now!

What hath god wrought?
$ ls /opt/local/bin/rtl*
/opt/local/bin/rtl_adsb        /opt/local/bin/rtl_power    /opt/local/bin/rtl_test
/opt/local/bin/rtl_eeprom    /opt/local/bin/rtl_sdr
/opt/local/bin/rtl_fm        /opt/local/bin/rtl_tcp


OK, let's test it.

Plug the widget in and:
$ /opt/local/bin/rtl_test
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 0


So the test passes, now try to receive ADS-B data again:
$ /opt/local/bin/rtl_adsb
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 1090000000 Hz.
Exact sample rate is: 2000000.052982 Hz
Sampling at 2000000 S/s.
*8d896c9399001756282f02516497;
*8d7609895839c7f3dc483eb47eca;
*aec00327548cc8385eb439daf3df;
*a00012113000020000080047fe32;
*a82001910201000000000028ab15;

...

OK, now to make it a little more friendly...

When all else fails, read the manual:
$ /opt/local/bin/rtl_adsb --help
/opt/local/bin/rtl_adsb: illegal option -- -
rtl_adsb, a simple ADS-B decoder

Use:    rtl_adsb [-R] [-g gain] [-p ppm] [output file]
    [-d device_index (default: 0)]
    [-V verbove output (default: off)]
    [-S show short frames (default: off)]
    [-Q quality (0: no sanity checks, 0.5: half bit, 1: one bit (default), 2: two bits)]
    [-e allowed_errors (default: 5)]
    [-g tuner_gain (default: automatic)]
    [-p ppm_error (default: 0)]
    [-T enable bias-T on GPIO PIN 0 (works for rtl-sdr.com v3 dongles)]
    filename (a '-' dumps samples to stdout)
     (omitting the filename also uses stdout)

Streaming with netcat:
    rtl_adsb | netcat -lp 8080
    while true; do rtl_adsb | nc -lp 8080; done
Streaming with socat:
    rtl_adsb | socat -u - TCP4:sdrsharp.com:47806


So, let's try again, this time verbose and with short messages also:
$ /opt/local/bin/rtl_adsb -g49 -V -S
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to 49.60 dB.
Tuned to 1090000000 Hz.
Exact sample rate is: 2000000.052982 Hz
Sampling at 2000000 S/s.
*7918f0d9ca82d6;
DF=15 CA=1
ICAO Address=18f0d9
*57052d75970122;
DF=10 CA=7
ICAO Address=052d75
*530c80731ead47;
DF=10 CA=3
...


Apparently, there are bazillions of planes in the desert sky, but if I look up, I cannot see any! 

Now I need to figure out how to map the planes with dump1090 or some such.

ADS-B for Linux Lovers

You need to do one of the following:
$ sudo apt install rtl-sdr
$ sudo apt-get install rtl-sdr
# dnf install rtl-sdr

If you need to ask who has to do what, then you have to hand your Geek card back.

ADS-B for BSD Devils

All that FreeBSD devil worshippers need to do is:
# pkg install install rtl-sdr
# pkg install dump1090
# dump1090 --net --aggressive


Then, point a webserver at http://localhost:8080/ and watch...

The OpenBSD Calgary Cowboys are SOL though - it doesn't work fully.

Antennas

The RTL SDR wotzit works perfectly from inside my house with just a simple little dipole antenna.   It is very sensitive, so you don't need any fancy antennas, unless you want to do HF DX.


-. --- / .-- .. -. -.. --- .-- ... --..-- / -. --- / -.-. .-. -.--

Cheers,

Herman

No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.