Saturday, August 31, 2013

Software Defined Radio on Raspberry Pi

I've been playing around with this USB dongle for software defined radio.  I got it to work in Kali Linux (VM).  I was able to send ADS-B packets from the Kali VM to the windows host which was running adsbSCOPE 2.63.  I saw that some people have used a Raspberry Pi to receive the signals and rebroadcast over a network, so I wanted to try that next.

I first looked for the rtl-sdr drivers using apt-get in Raspian.  Of course, that package wasn't there.  Thankfully, there are some simple instructions for getting the source code for the driver and building it here.

Here is what I did.

  1. Update my version of Raspian.  This updates the package lists and then installs any updated packages.
    • root@rapberrypi:~# apt-get update
    • root@rapberrypi:~# apt-get uprade
  2.  Install packages needed to build packages from source.
    • root@rapberrypi:~# apt-get install git
    • root@rapberrypi:~# apt-get install cmake
    • root@rapberrypi:~# apt-get libusb-1.0-0-dev
    • I tried to install build-essential, but it was already installed
  3. Create a new directory.  I used the pi home directory.
    • root@rapberrypi:~# cd /home/pi
    • root@rapberrypi:/home/pi# mkdir src
    • root@rapberrypi:/home/pi# cd src
  4. Get the source code
    • root@rapberrypi:/home/pi/src# git clone git://git.osmocom.org/rtl-sdr.git
  5. Build and install it
    • root@rapberrypi:/home/pi/src# cd rtl-sdr
    • root@rapberrypi:/home/pi/src/rtl-sdr# mkdir build
    • root@rapberrypi:/home/pi/src/rtl-sdr# cd build
    • root@rapberrypi:/home/pi/src/rtl-sdr/build# cmake ../
    • root@rapberrypi:/home/pi/src/rtl-sdr/build# make
    • root@rapberrypi:/home/pi/src/rtl-sdr/build# make install
    • root@rapberrypi:/home/pi/src/rtl-sdr/build# ldconfig
ldconfig updates shared libraries cache.  It is useful in that it keeps programs from having to search through all of the library paths to find the correct version of a shared library.
  1. Test it.  I ran rtl_test and then rtl_adsb to see if I got any output.
    • root@rapberrypi:/home/pi/src/rtl-sdr/build# rtl_test
      Found 1 device(s):
        0:  ezcap USB 2.0 DVB-T/DAB/FM dongle
      ETC...
    • root@rapberrypi:/home/pi/src/rtl-sdr/build# rtl_adsb
      Found 1 device(s):
        0:  Realtek, RTL2838UHIDIR, SN: 00000001

      Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
      Found Rafael Micro R820T tuner
      Tuner gain set to automatic.
      Tuned to 1090000000 Hz.
      Sampling at 2000000 Hz.
      Exact sample rate is: 2000000.052982 Hz
      *aa7b30d2cec4af08045508ad3d47;
      ETC...
Once I got that working, I tried to send it to adsbSCOPE on the windows machine using netcat.  The command is given in the rtl_adsb help.
root@raspberrypi:/home/pi# rtl_adsb | netcat -lp 7000

Then in adsbSCOPE under 'other | Network' menu, I set the network setting to listen to the Raspberry Pi's IP address and port 7000 for the RAW-data-client.  I made sure the the RAW-data-client was active under the 'other | Network' menu.  
adsbSCOPE Network Setup Window

I was receiving packets and displaying aircraft location.  Not too many, but that might have to do with the antenna and location that I was receiving from.

adsbSCOPE Main Window, Decoding Location of One Airplane





1 comment:

  1. The latest raspian has DVB drivers that conflict. The solution is to blacklist them in ‘/etc/modprobe.d/raspi-blacklist.conf’ and then reboot.

    # blacklist the DVB drivers to avoid conflict with the SDR driver
    blacklist dvb_usb_rtl28xxu
    blacklist rtl2830
    blacklist dvb_usb_v2
    blacklist dvb_core

    ReplyDelete