Using the Raspberry Pi as an RTL-SDR dongle Server

Installing RTL SDR Software

NB: UPDATED 5th August 2017

The instructions listed below show you how to set up a Raspberry Pi for use as an RTL-SDR dongle server. If you would like a ready made solution, I have pre-configured and tested SD cards complete with printed instructions available via my Web Shop here.

To make installation as easy as possible, I’ve written a bash script that automates the entire process. You can download the zip file here: rtlsdr-install

  1. Download and unzip the rtlsdr-install file to the /home/pi directory on your Pi.
  2. Open an LXterminal session and type ./rtl-sdrinstall.sh
  3. The script will run and show progress messages as it installs.
  4. When complete, restart the Pi and you’re in business!

Manual Installation

The first step is to install a few packages that are required by the dongle server. You may already have some of these so don’t worry if you see a message that you already have the latest version.

To install these packages, type the following at the LXTerminal command line.

sudo apt-get install -y  cmake pkg-config libusb-1.0

Now you can download the RTL-SDR code from osmocom by typing the following at the command line:

git clone git://git.osmocom.org/rtl-sdr.git

The next step is to build RTL-SDR using the following commands. NB: Some of these may take a while so it’s probably time for a beer!

  1. cd rtl-sdr/
  2. mkdir build
  3. cd build
  4. cmake ../ -DINSTALL_UDEV_RULES=ON
  5. make
  6. sudo make install
  7. sudo ldconfig

Blacklist the DVB-T Drivers

The later versions of Raspbian include standard drivers so that the Dongles can operate in their original role as a USB Radio/TV device. Unfortunately, these drivers prevent access to the dongle by the rtl-sdr software. The solution is to create a dedicated blacklist file to prevent the unwanted drivers from loading.  Here’s the process:

From the command line enter the following:

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

 

This creates a new file so enter the following lines:

blacklist dvb_usb_rtl28xxu

blacklist rtl2832

blacklist rtl2830

Press control-X followed by Y to exit and save the modified file.

Now reboot the Pi: sudo reboot

That completes the build and you can run a quick test by making sure your dongle is connected and typing: rtl_test -t

To start the server you need to access the Pi command line and type: rtl_tcp -a ‘your Pi’s IP address’. As a practical example, the start command for my setup is:

rtl_tcp -a 192.168.1.100

Auto Boot

It is very easy to configure the Pi to automatically run the SDR server when it powers-up. This is done by modifying the rc.local file that automatically runs on boot. We need to include two new lines in the file. The first delays execution for 10 seconds whilst the network starts and the second runs the command to start the server. The delay is necessary because the new Jessie release runs rc.local before the network is up so we won’t have the vital IP address. Here’s the updated rc.local file with the additions in red:

sleep 10
_IP=$(hostname -I) || true
if [“$_IP”]; then
printf”My IP address is %s\n” “$_IP”
/usr/local/bin/rtl_tcp -a $_IP &
fi
exit 0

To open the rc.local file for editing type:

sudo nano /etc/rc.local

Now update the content as shown above.

Type control X followed by Y and Enter to save the changes.

That’s it – you should have an RTL-Server that auto-boots. I don’t recommend using a Wi-Fi dongle but if you do you will need to increase the sleep time as the network setup will take longer.

 

Good Luck,

 

Mike – G4WNC

 

43 Responses to Using the Raspberry Pi as an RTL-SDR dongle Server

  1. Art September 4, 2016 at 5:09 pm #

    What software would I use as a client in Windows?

    Tried SDR# with no luck so far.

    • admin September 4, 2016 at 5:45 pm #

      Hi Art,

      Sorry to hear you are having problems. SDR# is the most common SDR software that’s used with the dongle server. When you use SDR# you have to select RTL-SDR(TCP) as the Source and you have to click the Cogs icon and enter the Raspberry Pi server’s IP address as the host and 1234 as the port. Not sure if you purchased one of my cards or are doing it yourself but all my cards are individually tested with SDR# before despatch.

      Let me know how you get on – I’m happy to help.

      Regards,

      Mike – G4WNC

  2. Stefan Bader September 28, 2016 at 6:10 pm #

    Hi Mike,

    thanks a lot for simply the best tutorial I could find to get the rtl-server running.

    It works very well on a RPi 3 B from a technical point of view but I have some strange noisy peaks (kind of rhythmic appearance) on some frequencies (118-137 Mhz), even more than before, when the dongle was connected to the pc, half a meter to the left. I guess I have to look into that over the weekend. Maybe a relocation will do…

    I can open a connection with SDR Touch on Android and SDR# and the service doesn’t crash if I’m shutting down the connection (I’ve read about that somewhere else), but, who knows – I’ve set up a PUTTY SSH favorite to restart the service if necessary.

    As I’m new to Linux there is a simple question, because you didn’t mention it in the tutorial.

    I would like to change the default port 1234. How should “/usr/local/bin/rtl_tcp -a $_IP &” look like?

    /usr/local/bin/rtl_tcp -a $_IP -p port number &

    or

    /usr/local/bin/rtl_tcp -a $_IP & -p port number &

    Thanks,

    Stefan

    • admin September 28, 2016 at 9:34 pm #

      Hi Stefan,

      Glad to hear you found the tutorial useful. The crash you read about that follows a link shut down was due to Raspbian using an older version of libusb – that’s now fixed.
      Changing the port is simply a case of adding a colon : followed by the new port number after $_IP but before the &. As an example, the new line for using port 4321 would be:

      /usr/local/bin/rtl_tcp -a $_IP:4321 &

      Hope that helps,

      Mike – G4WNC

  3. Stefan Bader September 29, 2016 at 4:54 am #

    Hi Mike,

    great, thanks a lot.

    Have a nice day!

    Stefan

  4. Vendel Boeree/ K2DSI October 8, 2016 at 4:10 am #

    Hi Mike, I had a problem with some of the commands. I’ll cut and paste some of the error responses…

    pi@raspberrypi:~ $ cd rtl-sdr/
    -bash: cd: rtl-sdr/: No such file or directory
    pi@raspberrypi:~ $ mkdir build
    pi@raspberrypi:~ $ cd build
    pi@raspberrypi:~/build $ cmake ../ -DINSTALL_UDEV_RULES=ON
    CMake Error: The source directory “/home/pi” does not appear to contain CMakeLists.txt.
    Specify –help for usage, or press the help button on the CMake GUI.
    pi@raspberrypi:~/build $ cmake ../ -DINSTALL_UDEV_RULES=ON
    CMake Error: The source directory “/home/pi” does not appear to contain CMakeLists.txt.
    Specify –help for usage, or press the help button on the CMake GUI.
    pi@raspberrypi:~/build $ make
    make: *** No targets specified and no makefile found. Stop.
    pi@raspberrypi:~/build $ sudo make install
    make: *** No rule to make target ‘install’. Stop.
    pi@raspberrypi:~/build $ sudo ldconfig
    pi@raspberrypi:~/build $ sudo nano /etc/modprobe.d/raspi-blacklist.conf
    pi@raspberrypi:~/build $ sudo reboot

    I did create the blacklist file. I’m running Debian GNU/ Linux.
    I didn’t create the auto boot file and booted it manually.

    pi@raspberrypi:~ $ rtl_tcp -a 192.168.1.12
    -bash: rtl_tcp: command not found

    I’m just learning linux. Thanks in advance.

    • admin October 8, 2016 at 5:51 pm #

      Hi Vendle,

      The fault seems to be with the clone operation. The git clone line downloads the software on to your machine and puts it in a new directory called rtl-sdr. The fact that your cd rtl-sdr/ line fails indicates that the directory hasn’t been created so the software won’t have been downloaded. Do you get an error when you type the clone line?
      All the subsequent lines fail because the code they are working on doesn’t exist.

      Hope that helps,

      Mike

  5. Vendel/ K2DSI October 8, 2016 at 7:12 pm #

    As much as I would like to figure out what went wrong, I took the easy way out and ordered one of your preconfigured SD cards. Time permitting I’ll try again in the future. Thanks for your assistance.

  6. Vendel Boeree/ K2DSI October 31, 2016 at 11:03 pm #

    Hi Mike, I followed your instructions a little better and was able to get the server up and running ;). Your pre-configured SD card arrived and worked flawlessly. Is there a way to stream directly from the server using the wifi dongle, ad hoc style? (I may be using the wrong term)
    Thanks again, Vendel/ K2DSI

  7. Richard William Ehrenberg November 17, 2016 at 10:47 pm #

    wondering why my pi is streaming on a different port (never 1234) each time?

    works great when it works!

    • admin November 18, 2016 at 9:21 am #

      Hi Richard,

      I’ve never come across that. Are you using one of my pre-configured cards or have you set it up yourself?
      This is the line that sets the IP address:

      /usr/local/bin/rtl_tcp -a $_IP &

      You could try modifying to the following to force the port No:

      /usr/local/bin/rtl_tcp -a $_IP :1234 &

      Let me know how you get on.

      Mike – G4WNC

  8. TulsaTV November 29, 2016 at 1:35 pm #

    Mike,

    I was able to get the server working on a Pi 3, and use a gigabit-connected Windows 10 PC running SDR# to listen.

    I would like to get my Pi 1, which is running OSMC/Kodi on the same switch, to stream from the server. Is there a way, like with a .strm file?

    I also wonder if Kodi;s RADIO section could access the server. Them I would be able to record shows on schedule.

    • admin December 4, 2016 at 4:49 pm #

      Thanks for your comments. Whilst it’s fine to use a Pi3 and Gigabit LAN, it’s a bit overkill for this simple server as it will run quite happily on an old Pi-1 and its 100Mb/s Ethernet port. You could save your Pi-3 for doing more interesting things :-).
      The RTL-SDR Dongle server simply supplies raw IQ samples over the network and these can only be handled by dedicated SDR software such as SDR Sharp. This software uses the processing power of the host PC to select the desired station and extract the demodulated audio. If you want to record stations, you could use one of the audio recorder plug-ins that are available for SDR Sharp. You could then make the resultant audio files accessible by OSMC.

      Mike – G4WNC

  9. David Byres December 11, 2016 at 7:33 pm #

    Instructions work great, trying on a new RPi3. Connecting over wlan0 and getting some minor audio issues (audio intermittently cuts out) but will troubleshoot later. Thank you for posting these instructions.

    David – KK6GPM

    • admin December 11, 2016 at 7:52 pm #

      Hi David,

      Glad to hear the instructions were helpful.Wlans are generally too slow to handle the IQ data rate, hence the drop outs. You can try a lower sample rate but I always recommend using Ethernet.

      ’73 Mike G4WNC

  10. David Byres December 12, 2016 at 4:15 pm #

    Mike thanks, yes switched to ethernet and better audio, though I still have to lower to sample rate to get decent quality. New topic: now trying to stream IQ data over the Internet. Added rule to my firewall/router to forward port 1234 to the RPi’s static internal IP, but when I try to connect SDR# using the WAN IP (assigned by my ISP) I get “connection actively refused” error message. What am I missing?

  11. Artur January 2, 2017 at 2:39 pm #

    Hello can i ask somethings ?
    I try do autostart when system is reboot ( when mayby power is Off and a few minutes is On)

    Do you need to manually enter the IP address of the file is changed? My raspberry address is 192.168.0.104 and the port 1234

    I mean this piece of code:
    sleep 10
    _IP=$(hostname -I) || true
    if [“$_IP”]; then
    printf”My IP address is %s\n” “$_IP”
    /usr/local/bin/rtl_tcp -a $_IP &
    fi
    exit 0

    Is this causes the console will move itself?

  12. Neal Bailey January 13, 2017 at 8:40 pm #

    I cannot for the life of me get this to work. I have tried so many different options and about to give up on it.
    SDR# will not connect at all. Even opened up the port on my router.

  13. Neal Bailey January 13, 2017 at 9:13 pm #

    Just figured out my errors. Was an IP address mistake on my part.

  14. TomW January 19, 2017 at 1:58 am #

    Excellent tutorial pretty much copy paste and you are set. Used. It on 3 RPis. Takes very little time.

    Thanks

    TomW

  15. Aaron VanAlstine February 8, 2017 at 2:38 pm #

    1. cd rtl-sdr/
    2. mkdir build
    3. cd build
    4. cmake ../ -DINSTALL_UDEV_RULES=ON
    5. make
    6. sudo make install
    7. sudo ldconfig

    When I enter # 7 I get “sudo: Idconfig: command not found”

    Jessie is fully up-to-date.

    • admin February 8, 2017 at 2:54 pm #

      Hi Aaron,

      You’re making a simple typo, the first letter of the command is a lowercase L 🙂

      Regards,

      Mike

      • Aaron VanAlstine February 9, 2017 at 1:40 am #

        Thanks, that worked. 😉

  16. Kiko Santos February 17, 2017 at 2:29 am #

    Can someone point me to the right procedure?

    $ sudo killall -9 openwebrx rtl_mus csdr rtl_sdr
    openwebrx: no process found
    rtl_mus: no process found
    csdr: no process found
    rtl_sdr: no process found

    followed this procedure from start to finish…
    using an RPI2 with up-to-date raspbian

    thanks for the assistance

    • admin February 17, 2017 at 9:23 am #

      Hi – I’m not sure I understand what you’re trying to do here. The response you’ve supplied just confirms that the processes you listed are not running on the Pi.
      An explanation would help.

      Regards,

      Mike – G4WNC

      • Kiko Santos February 17, 2017 at 9:26 am #

        I followed the procedures on your page…but seems i missed something or did not cpmply…
        when I try to kill the process thats the error…
        after a reboot now wont able to run the openwebrx.py

  17. G8NXD February 17, 2017 at 12:16 pm #

    also may have found an error in /etc/rc.local as released in Jessie 2016-11-25
    in your example rc.local starts…

    _IP=$(hostname -I) || true

    but in the issued rc.local I have

    IP=$(hostname -I) || true
    ## NOTE THE MISSING UNDERSCORE

    without the underscore it won’t work. you need to add the underscore as well as your RED highlighted text.

    HTH, G8NXD

    • admin February 17, 2017 at 2:37 pm #

      Hi,

      I just checked the latest Raspbian image and the underscore is present and so is the raspi-blacklist.conf file from your other comment. I’d be suspicious about the image you’ve used. Might be worth downloading the latest build to get back on track.

      Regards,

      Mike -G4WNC

  18. Aoife February 22, 2017 at 5:10 pm #

    Thanks a million Mike, it works Brilliant 🙂
    I have a raspberry pi B+, the only bit I couldn’t get working was the git clone git://git.osmocom.org/rtl-sdr.git, so I went on to github, and downloaded the zip file to the pi, and then unzipped it. Then it worked great. I used it for SSTV: Recieved by SD# on the laptop via TCP, and piped through to RX-SSTV to decode. The images were perfect.
    Regards,
    Aoife

  19. Iulian April 14, 2017 at 9:40 am #

    Hello.
    Thank you for this information.
    Works great.
    But one question please.
    How can multiple users connect to the SDR server that is on ?
    I tried to connect from two devices in the same time with no results.

    Thank you !

    • admin April 22, 2017 at 3:27 am #

      Unfortunately, the server only supports a single connection.

      • Iulian April 22, 2017 at 6:25 am #

        I understand, thank you !

        I have the following error:

        usb_claim_interface error -6
        Failed to open rtlsdr device #0.

        How can I resolve it ?
        The SDR is working but I cannot use any command in SSH to change port, sampling rate etc. Also I want to transmit on another port. The command line from previous post does not work for me.

        Thank you !

  20. Iulian April 22, 2017 at 4:27 pm #

    I formatted the SC card and reinstall the application.
    Now is connected, the USB error mentioned above does not appear any more but the server does not start automatic at boot. I edit rc.local file with the text from this site, but no luck. The application needs to start manually to work.
    Where is the problem ?

    • admin May 26, 2017 at 9:43 pm #

      Hi Sorry for the late reply, I’ve been away from home for a while. I suspect you have a typing error in the rc.local file. The instructions have been tested by many people so I’m confident that they are correct.

      Regards,

      Mike – G4WNC

  21. Andres May 26, 2017 at 3:04 pm #

    Hello:
    It would be interesting to create an sd card for the use of AIRSPY, similar to the RTL DONGLE SERVER
    regards

    • admin May 26, 2017 at 9:40 pm #

      Hi Andres,

      As it happens I’m just in the final stages of preparing a card for the AirSpy. I’m using the AirSpy SpyServer and that will run on the Pi-3 but only with the AirSpy set to 2.5MSPS. It should be up on the site in the next couple of weeks. Mike – G4WNC

  22. Alan July 27, 2017 at 9:29 am #

    DItto to all comments on this tutorial. Thank you.
    One question and one problem ..
    Question: Would it not be a good idea to fix the i/p address of the RPi so that SDR# can be run with the same settings each time?

    Problem (I think): When I run rtl_test, I get a response to say “No supported tuner found”. This line follows “Using device 0: Generic RTL2832U OEM and is followed by “Enabled direct sampling mode, input 1”

    Alan

  23. Alan July 28, 2017 at 8:44 am #

    Made a bit of progress …
    As mentioned above, I get an error to say that no supported tuner has been found. However, if I run the following steps, I can get it to work:
    1. sudo apt-get install librtlsdr0
    2. sudo reboot
    3. rtl_tcp -a 192.168.1.8

    Now at this stage, the tuner is found as FC0012 which is progress. However, I now get an error: undefined symbol: rtlsdr_set_bias_tee

    So…. I then run the following command: sudo apt-get remove librtlsdr0
    When that has finished, I can run the command at point 3 above and everything works! I can now attach SDR# on a remote laptop connected to the same network as the RPi and receive radio.

    However … if I reboot the Rpi, I am back to square 1. I am not at all sure of what is going on here but the problem is clearly software.

    I need to make some sort of change to the build of the RPi so that it accepts the FC0012 tuner in my dongle without going though all the kerfuffle above.

  24. kieran gio August 4, 2017 at 9:46 am #

    I get this error when running rc.local but not if I run manually rtl_tcp -a 192.168.1.66.
    Any ideas on what I am doing wrong please.
    [“192.168.1.66: not found

    • admin August 12, 2017 at 5:21 pm #

      Hi Kieran,

      Your command looks ok but here are a few things to check:
      Make sure your have the correct IP address for the Pi.
      This type of problem usually turns out to be due to typing error so double check your typing of the command

      Let me know how you get on.

      Mike – G4WNC

  25. Bill KD4VAZ August 12, 2017 at 7:51 pm #

    Like the fellow above I get the error msg ,

    usb_claim_interface error -6
    Failed to open rtlsdr device #0

    I can’t get pass that. Thanks for the tutorial, good stuff!

    • admin August 16, 2017 at 3:57 pm #

      Hi Bill, Sorry for the delay replying. The usb_claim error means the kernel DVB-T drivers have grabbed the stick. This is caused by an error in the blacklist file. Take a very close look at it and make sure there are no typos. In the latest update to these instructions I’ve recommended making a new blacklist file as follows:

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

      This creates a new file so enter the following lines:

      blacklist dvb_usb_rtl28xxu

      blacklist rtl2832

      blacklist rtl2830

      Press control-X followed by Y to exit and save the modified file.

      Now reboot the Pi: sudo reboot

  26. Bill KD4VAZ August 18, 2017 at 3:17 pm #

    I think I got through the blacklist problem but now when I run “rtl_test -tngg” I get the following:

    Found 1 device
    0: Realtek, RTL2838UHIDIR, SN 00000001
    Using device 0: Generic RTL2832U OEM
    Found Rafael Micro R820T tuner
    Supported Gain Values (29): ….etc

    [R82xx] PLL not locked!
    Sampling at 2048000 s/s
    NO E4000 Turner Found, aborting.

    Thanks for putting up with this old man.

Leave a Reply

Powered by WordPress. Designed by WooThemes