RTL-SDR NOAA Weather Radio Streamer in Linux
If you’re into amateur radio you’ve probably heard of these cheap DVB-T tuner dongles re-purposed as software defined radios. They’re very popular for building scanners and streaming setups. I’ve got a couple of models that I use with Gqrx for listening to traffic on the local repeaters, weather radio and a few other things.
This weekend I finally had enough time to sit down and setup rtl_fm and try out a streaming solution for listening to NOAA weather broadcasts. I’ve streamed scanner and weather radio traffic using Icecast before but that was with a external radios and a mic input. This time I wanted to use a machine with no sound card (my home server machine). All of this was done on Debian Linux 8, to get started we need three pieces of software:
rtl-sdr ezstream icecast2
All are available in the default repositories so just install them with apt.
Next I had to configure icecast2, the most basic configuration should work but at least change your admin and source password in the authentication block:
<authentication>
<!-- Sources log in with username 'source' -->
<source-password>password123</source-password>
<!-- Relays log in username 'relay' -->
<relay-password>password123</relay-password>
<!-- Admin logs in with the username given below -->
<admin-user>admin</admin-user>
<admin-password>password123</admin-password>
</authentication>
That should at least allow you to connect and get up and going. There are other options to secure and/or tweak but I’m not going to cover those here.
I used my NooElec Nano SDR as a test source. The rtl-sdr package comes with a program to handle FM tuning called rtl_fm. There are a few options to tinker with here but only too options are critical for operation here:
rtl_fm -f 162.500m -M fm -
-f 162.500m: sets the tuner frequency to 162.500Mhz
-M fm: tells the tuner to use standard narrow FM tuning, if you want to listen to commercial radio you’d use wbfm or wideband FM.
-: directs output to stdin
Send that output to lame to encoding:
lame -r -s 24 -m m -b 64 --cbr - -
-r: assume raw pcm input
-s 24: set the sample rate to 24K
-m m: mono mode, NOAA doesn’t broadcast in stereo
-b 64: set bitrate to 64kbps, it’s more than enough for this
--cbr: constant bitrate
- -: stdin/stdout
A quick note here, you’re going to have to mess with the sample rate in LAME to get things sounding right most likely. I arrived at 24K, much higher or lower and the pitch is off. It may not work with your model SDR, etc.
Lastly ezstream needs configuring. It took a while to get a working MP3 configuration sorted out but I eventually arrived here:
<ezstream>
<url>http://localhost:8000/WNG588</url>
<sourcepassword>password123</sourcepassword>
<format>MP3</format>
<filename>stdin</filename>
<!--
Important:
For streaming from standard input, the default for continuous streaming
is bad. Set <stream_once /> to 1 here to prevent ezstream from spinning
endlessly when the input stream stops:
-->
<stream_once>1</stream_once>
<!--
The following settings are used to describe your stream to the server.
It's up to you to make sure that the bitrate/quality/samplerate/channels
information matches up with your input stream files.
-->
<svrinfoname>WNG from Mt Jefferson, NC</svrinfoname>
<svrinfourl>https://hubble.buttonhost.net</svrinfourl>
<svrinfogenre>Public Information</svrinfogenre>
<svrinfodescription>NOAA Weather Radio from Mt Jefferson NC</svrinfodescription>
<svrinfobitrate>64</svrinfobitrate>
<svrinfochannels>1</svrinfochannels>
<svrinfosamplerate>44100</svrinfosamplerate>
<!-- Allow the server to advertise the stream on a public YP directory: -->
<svrinfopublic>0</svrinfopublic>
</ezstream>
Save this to /etc/ezstream using your favorite text editor and pass it to eztream thusly:
ezstream -c /etc/ezstream.xml
The whole thing piped together looks like this:
rtl_fm -f 162.500m -M fm - | lame -r -s 24 -m m -b 64 --cbr - - | ezstream -c /etc/ezstream.xml
I just stuck that whole string into a shell script. If you want it to start at boot time you can shove it into /etc/rc.local for a quick and dirty solution.
Once all that is done it’s a simple matter of navigating to your Icecast server at http://whatever_url_u_have.com:8000 and clicking the m3u icon by the stream listed there. Open that file in whatever music player you want and enjoy. I use VLC, Rhythmbox or iTunes (when I find myself on a Mac) myself. Otherwise you can just check the weather app on your phone like a normal person. Next up I want to work on getting frequency scanning working so I can get the scanner back online.
Oh and you can check out the fruits of my work here: http://hubble.buttonhost.net:8000/WNG588.m3u