Posted on 4 Comments

Raspberry Pi – Auto-Start rtl-sdr Server

 

Raspberry Pi Tips

Auto-Starting rtl_tcp during boot

To avoid having to use ssh to access the Pi and start the rtl_tcp stream, we can hook into the rc.local script to automatically start the server if an IP address is available and the dongle is connected.

The rc.local service is used to run commands at boot time. In the current Raspbian build, the rc.local service includes a script to detect a network connection and print-out the IP address on the terminal. We can use that same script to automatically run rtl_tcp, if an IP address is available. All that needs to be done is to add the following new line between the printf…. and fi statements of the existing script.

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

To edit the rc.local file type: sudo nano /etc/rc.local

When finished, hit control-x followed by y and return to save the changes and close the file.

Providing the Pi detects a network connection and has a USB connected dongle on boot, the RTL TCP server will be automatically started.

WiFi Connections

Although Wi-Fi connections aren’t really fast enough to make the most of SDR dongles, they can be used at the lower sample rates. For the auto-boot to work with a Wi-Fi dongle, you need to add a 10 second delay (‘sleep 10’) prior to checking the IP address. This is to allow time for the Wi-Fi to complete its connection and negotiate an IP address.

Here’s the complete, modified rc.local script:

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 configure network access via a WiFi Dongle you need to do the following:
Edit the wpa-supplicant file:
type: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following to the end of the file:
network={
     ssid="your network SSID"
      psk="your wifi password"
}
Press ctl x followed by y then Enter to close the file.

That's it! Reboot the Pi and it should find and connect to your WiFi and start the RTL Server.

 

4 thoughts on “Raspberry Pi – Auto-Start rtl-sdr Server

  1. This was so helpful! Thank you for the info, I have been looking for a way to do this.
    Is there a way to get only the audio from the tuner over TCP? I want to tune in a station remotely over the web, while recording the audio both locally into a file on the Pi and remotely in a 24 hour loop. My shed has been getting vandalized and I think this will help, Thanks in advance,
    Shelaigh

    1. Hi Shelaigh – I haven’t seen anything for that using a Pi. In the existing server setup, the Dongle outputs its IQ data to the Pi using the USB port and the Pi then forwards the data to the host PC over the local network. The host PC needs to run SDR receiver software such as SDRSharp or SDR-Console to control the dongle and demodulate the signal using the IQ data. However, you could remote access your host PC using TeamViewer or other remote access software. That would allow you to operate your PC remotely. Mike

  2. I have an old Pi1 mod.B rev.2 and I installed rtl_tcp, as Spy Server would overload it.

    It has a Wifi dongle and I added the scritpt described in “Auto-Start rtl-sdr Server”. I plan to connect the Pi to the open Wifi of the entreprise network. Shall I add also the wpa-supplicant or would the Auto-Start rtl_sdr Server automatically connect to the only AP which has no password to enter ?

    When I look at the local IP, it gives (partly, there are UDP ports not printed) the following (I don’t see anywhere any 1234 port) :

    10.29.128.180:44376

    tcp 0 0 10.29.128.180:36939

    tcp 0 0 10.29.128.180:48170

    tcp 0 0 10.29.128.180:48994

    tcp 32 0 10.29.128.180:59561

    tcp 0 0 10.29.128.180:53874

    tcp 0 0 10.29.128.180:32963

    tcp 32 0 10.29.128.180:55113

    tcp 0 0 10.29.128.180:48352

    tcp 0 0 10.29.128.180:51570

    tcp 0 0 10.29.128.180:47186

    tcp 0 0 10.29.128.180:54866

    tcp 0 0 10.29.128.180:42538

    tcp 0 0 10.29.128.180:45049

    tcp 0 0 10.29.128.180:35737

    tcp 0 0 10.29.128.180:54643

    tcp 0 0 10.29.128.180:58588

    tcp 0 0 10.29.128.180:45943

    tcp 0 0 10.29.128.180:45384

    tcp 0 0 10.29.128.180:50447

    tcp 0 0 10.29.128.180:34991

    tcp 0 0 10.29.128.180:60194

    tcp 0 0 10.29.128.180:34979

    There is a common public IP address, wherever I connect on the various AP in the premises. Do you think the Pi would be accessible from outside?

    Shall I change the listening ports of both SDR# and Pi conf?

    I hope I am not bothering you.

    Thank you and best regards.

    Tony

    1. Hi Tony,

      Sorry for the late reply. I don’t recommend trying to use a Pi-1 for RTL-SDR over WiFi. It’s unlikely to work well as it’s asking too much of the very low power processor in the original Pi.

      Regards,

      Mike

Leave a Reply to Tony Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.