RTL_TCP Server - Advanced Capability
Ok. We all know I love SDR Radios by now.
$30 gets you basically every radio frequency that you can imagine and there is no shortage of geeks out there to write software to listen to or decode or make use of all those radio signals. One really cool thing you can do is to set up a server which you can connect to from anywhere. Some possible uses would be that you are on the road and your favorite radio station or program is on but your station doesn't stream on the internet.
Lots of local sports are broadcast on local radio only. Maybe your son is playing high school football and you are halfway across the globe. Or you can set a baby monitor or other microphone device up and listen to its frequency from anywhere. Also around 160 MHz is your local weather broadcasts. Maybe you are an airport junkie and listen to the local airport chatter, etc.
If you are like I am I work about 30 miles from home. There is a radio station at work I can't get at home and it doesn't stream on the internet. I can use this method to listen to that station that is just out of range of me at home.
There are a lot of reasons you might want to grab a local radio signal!
So the ability to do this is GREAT! But like all great things there are some gotchas. There are basically two ways (yeah I know there are probably more)......two popular ways to do this. Through a program called RTL_TCP and a program called Spyserver.
RTL stands for Realtek which is the chipset in the device. Other devices don't use Realtek chips. For example in the pic above........that device contains a Realtek chipset. Sooooooo....I can use RTL_TCP as a server. Here's one gotcha. That device above has a range of about 550 KHz to about 1.7 GHz or so. That's a lot!
BUT, there is always a but.........the frequencies are kind of broken up. HF or high frequency stuff (AM Radio, Shortwave) require the device to be placed into something called Direct Sampling Mode. If not you get about 30 MHz to 1.7 GHz (FM, fire, police, weather, cell phone, and about a million other things). So while it has all the range you have to decide what you want to listen to. You can't have it all at once.
Well, ya can't. You could buy an Airspy One and Spyverter combo which costs over $200 and it has a program called Spyserver but you kind of have the same thing going on. If you configure it for HF listening then you're right back to where you started from. Also with Spyserver you can ONLY connect with client software called SDR# (and another Windows program). I use Mac. This won't work for me, and it is too expensive. You could buy an SDRPlay which has the frequency range you need but it isn't really supported by RTL_TCP or Spyserver. There are github repositories where people have tried but they seem to be dead projects and an SDRPlay costs big bucks as well. That stick in the picture at the top of this blog post costs $30.
So with economy in mind lets go the $30 route and I'll show you how you can have it all. But it isn't automatic. You have to choose but you can shut down one and start the other remotely so it isn't all that bad.
Lets do this on a Raspberry Pi (it can be done on an Orange Pi or Beagle Board Black or I suppose any other small board computer that runs Linux).
Start with a fresh install of Raspian (on raspberry pi) and make sure it is updated.
NOTE: You also have to be able to connect to your Pi via SSH or have direct access via keyboard, mouse, and monitor.
sudo apt-get update
sudo apt-get upgrade
I'm using directions from this web site and you'll need a file from there too. I guarantee you I didn't figure this out. This is NOT MY WORK. Download the file named rtl_tcp.c from his web site.
Once that is done do these commands:
sudo apt-get install -y cmake pkg-config libusb-1.0.git
git clone git://git.osmocom.org/rtl-sdr.git
Now at this point you need to take that file rtl_tcp.c and replace it with the same named file located at /home/pi/rtl-sdr/build/src (your path may be different)
I used a program called Cyberduck and did an SFTP transfer
Locate then upload your file!
Now that the file is replaced let's get back to the building. Run these commands:
cmake ../ -DINSTALL_UDEV_RULES=ON
sudo make install
sudo cp ../rtl-sdr.rules /etc/udev/rules.d/
Now once you have rebooted type:
You should see this below. Take note of the -i command which is new. Had you not replaced that file it would not be there.:
This will let you set your sampling mode.
To just listen to normal FM radio and non-HF listening type the following command (make sure to use YOUR ip address):
rtl_tcp -a 192.168.20.83
You'll be able to tune from about 30 MHz on up.
Now lets get our Shortwave Radio and AM radio fix on, shall we?
rtl_tcp -a 192.168.20.83 -i 2
Now I can listen to shortwave or FM bands. I just have to know which one I want to listen to so I can start in regular or Direct Sampling Mode. To do this at boot or to swap them you can make service files. I'll call my service files rtltcp.service and rtltcphf.service
sudo nano /etc/systemd/system/rtltcp.service
paste in the following making sure YOUR IP adress is correct:
ExecStart=/usr/local/bin/rtl_tcp -a 192.168.20.83
Hit Ctl + X then Y to save.
To make the service file for hf just do this:
sudo nano /etc/systemd/system/rtltcphf.service
Paste in this:
Description=RTLTCP HF Listening
ExecStart=/usr/local/bin/rtl_tcp -a 192.168.20.83 -i 2
Hit Ctl + X then Y to save.
to start one or the other (don't run them both at the same time)
sudo systemctl start rtltcp.service (or the hf one)
To stop and start the other one
sudo systemctl stop rtltcp.service
sudo systemctl start rtltcphf.service
to start one at boot time
sudo systemctl enable rtltcp.service
To load the other one after boot
sudo systemctl disable rtltcp.service
sudo systemctl enable rtltcphf.service (or you could just start it here)