tinker.fulhack.info

- where Henrik's tinkering resides

Raspberry Pi + RTL2832U streaming receiver

For the past 7 years or so I've had a icom PCR-100 hooked up to first a PC and then to a beagle board (as seen in the other pages to the left), enabling me to remotely tune to any frequency between 0-1300MHz and streaming the audio to an Icecast server for me to listen to. Mostly used for air/marine 2M bands but some NOAA WX satellite DXing along with POCSAG snooping as well. But all good things come to an end, and during the last year of operation the trusted PCR-100 slowly deteriorated, and one by one squelch, s-meter, FM wideband recepition and finally the serial port stopped working. A sad, sad day that was. And since I've grown accustomed to it, clearly a replacement was needed!

So, after browsing around on ebay and radio outlet stores after a replacement PCR-100 without success I stumbled upon the stories about an inexpensive DVB-T receiver USB dongle that in reality was a highly programmable and hackable SDR (software defined radio), with tuners able to receive 25-1700MHz. And the best part - a cost of only about $10 from China (free shipping, of course!)

So, I ordered a few different dongles with different tuners and eventually came to the conclusion that for airband reception (and other projects that were receiving stations which might come in very weak and the next one very strong, like in the airbands where overhead aircraft is close to saturating the radio while distant stations are amost not audible) the combination of RTL2832U + FC0013 was the best combination available (the E4k tuner might have been the better choice but it's hard to come by nowadays) due to the R820T's magical AGC that could not be disabled. However, the R820T has been used by friends for the same type of projects with good results, so YMMV..

So, the reciever was found. Next up was streaming the result to the net, or do processing directly on the host. The beagle board has severd me well, but the Raspberry Pi was felt to be the better choice in the 2013-era.

Said and done, the ezCap cheap china dongle was plugged in to the raspberry pi, a modified version of rtl-fm from the rtl-sdr project was built, allowing me to remotely tune the center frequency and choose modulation method for rtl-fm. Patches for this is all over the net, and mine is hackyhacky so I won't publish it. But with some additional python code for gluing a simple web interface originally built for the PCR-100 server, everything was working!

The current setup is as described above, with rtl-fm running in a screen (terminal emulator) on the raspbian Debian based Linux distribution on the raspberry pi, sending raw pcm frames to LAME for mp3 encoding and then piping the MP3 data to ezstream which sends it onwards over the internet to an icecast server.

Command sequence for achieving all this is (inside the screen):

while true; do rtl_fm -E swagc-aggressive -M am -f 129.275M -g 17.9 -s 24k -l 90 | lame -r -s 24.0 -m m - - | ezstream -c ~/ezstream.xml; done

Some explaination of the commands for rtl_fm:
  • -E swagc-aggressive - New aggressive software AGC which will keep strong AM signals from saturating everything, and make listening to the airband a bit more enjoyable. Use it!
  • -M - AM demodulation. Can be changed runtime.
  • -g - tuner gain. Set to 7.1 for the FC0013. For R820 it was higher. Use trial and error method for determining a good value for your setup.
  • -l - squelch. 90 was good for this gain level, but depends on noise, environment, etc.
  • -s - Sample rate. Ideally for airband reception this should be lower, but 24k seems to give good results for me.
Simple as that.


Henrik Persson, 2013-10-15
(Update 2015-11-09: Changed parameters to use swagc-aggressive which was recently added to rtl_fm)