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.

 

2 Responses to Raspberry Pi – Auto-Start rtl-sdr Server

  1. Shelaigh March 25, 2015 at 2:25 pm #

    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

    • admin March 25, 2015 at 2:40 pm #

      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

Leave a Reply

Powered by WordPress. Designed by WooThemes