Skip to main content

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. There are also some notes on the not so cheap, more advanced HackRF One dongle at the bottom of this article.


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.

Get rtl-sdr With Macports

The CubicSDR program can do everything I want with this widget, but the command line utilities mentioned above can also be very handy, especially when you want to log data for later analysis.

The rtl-sdr package provides the following command line utilities:
  • rtl_adsb: a simple ADS-B decoder
  • rtl_eeprom: an EEPROM programming tool
  • rtl_fm: a narrow band FM demodulator
  • rtl_sdr: an I/Q recorder
  • rtl_tcp: an I/Q spectrum server
  • rtl_test: a benchmark tool
  • rtl_power: a spectrum analyzer
So, I used Macports https://www.macports.org/ and updated 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


ATC Transponders and rtl_adsb

So the test passes, now try to receive ADS-B data:
$ /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 list/map the planes with dump1090 or cocoa1090.

Cocoa1090 for ADS-B Transponders

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

Start the rtl_tcp 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.

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

You can get Malcolm Robb's dump1090 from github.  If you need to ask how, 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.


HackRF One

The HackRF One is a more advanced Tx/Rx dongle that works up to 6 GHz.  Get it from Great Scott Gadgets (https://greatscottgadgets.com/hackrf/) or Sparkfun Electronics.  It is not exactly cheap...


Once you have Mac Ports working, you can install rx_tools and gqrx to make it useful:
$ sudo port selfupdate
$ sudo port upgrade outdated
Go and get some coffee...

$ sudo port search gqrx

$ sudo port install Gqrx
Go and get some more coffee...

$ sudo port search rx_tools
Not found

Hmm, you need Linux for that one.  I think I need to buy me a new Macbook and put Linux on it!
(It can work on a Linux virtual machine on Virtualbox though).

The author of rx_tools published a good article here: https://medium.com/@rxseger/rx-tools-command-line-sdr-tools-for-rtl-sdr-bladerf-hackrf-and-more-rx-fm-rx-sdr-rx-power-2e74f59a9e79

La voila!


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

Cheers,

Herman

Comments

Popular posts from this blog

Parasitic Quadrifilar Helical Antenna

This article was reprinted in OSCAR News, March 2018:  http://www.amsat-uk.org If you want to receive Satellite Weather Pictures , then you need a decent antenna, otherwise you will receive more noise than picture. For polar orbit satellites, one needs an antenna with a mushroom shaped radiation pattern .  It needs to have strong gain towards the horizon where the satellites are distant, less gain upwards where they are close and as little as possible downwards, which would be wasted and a source of noise.  Most satellites are spin stabilized and therefore the antenna also needs circular polarization, otherwise the received signal will flutter as the antennas rotate through nulls. The helical antenna, first proposed by Kraus in 1948, is the natural solution to circular polarized satellite communications.  It is a simple twisted wire - there seems to be nothing to it.  Various papers have been published on helix antennas, so the operation is pretty well understood. Therefore,

Weather Satellite Turnstile Antennas for the 2 meter Band

NEC2, 2 m band, 146 MHz, Yagi Turnstile Simulation and Build This article describes a Turnstile Antenna for the 2 meter band, 146 MHz amateur satcom, 137 MHz NOAA and Russian Meteor weather satellites.  Weather satellite reception is described here .  A quadrifilar helical antenna is described here .   Engineering, is the art of making what you need,  from what you can get. Radiation Pattern of the Three Element Yagi-Uda Antenna Once one combine and cross two Yagis, the pattern becomes distinctly twisted. The right hand polarization actually becomes visible in the radiation pattern plot, which I found really cool. Radiation Pattern of Six Element Turnstile Antenna Only a true RF Geek can appreciate the twisted invisible inner beauty of a herring bone antenna... Six Element Turnstile Antenna Essentially, it is three crosses on a stick.  The driven elements are broken in the middle at the drive points.  The other elements can go straight throug

Patch Antenna Design with NEC2

The older free Numerical Electromagnetic Code version 2 (NEC2) from Lawrence Livermore Lab assumes an air dielectric.  This makes it hard (but not impossible) for a radio amateur to experiment with Printed Circuit Board Patch antennas and micro strip lines. Air Spaced Patch Antenna Radiation Pattern You could use the free ASAP simulation program , which handles thin dielectrics, you could shell out a few hundred Dollars for a copy of NEC4 , You could buy GEMACS if you live in the USA, or you could add distributed capacitors to a NEC2 model with LD cards (hook up one capacitor in the middle of each element.), but that is far too much money/trouble for most. More information on driving an array antenna can be found here: https://www.aeronetworks.ca/2019/03/driving-quad-patch-array-antenna.htm l Air Dielectric Patch   The obvious lazy solution is to accept the limitation and make an air dielectric patch antenna. An advantage of using air dielectric, is that the antenn