Ok, so I switched to using an RTL SDR instead of a regular radio for the MSP one. It's about the same, but now I don't need the radio or sound card and it's on a Raspberry Pi 3 and I'm using this: http://www.nooelec.com/store/sdr/sdr-receivers/nesdr-mini-2-plus.html and I purchased a kit that includes an SMA adapter which have connected to an antenna in my attic. Here's what I used for the command line, I started it in screen so that I can detach from it:
rtl_fm -f 162.55M -s 48000 -l 0 | lame -s 48000 --lowpass 3200 --abr 64 --scale 9 -r -m m - - | ezstream -c /etc/ezstream.xml
Tim - Can you elaborate on what was needed to set this up? In particular, what is listening on port 8000? I'm trying to replicate your work, hoping to build a script to automate the installation so anyone can easily set up a NWS stream.....
Sure, so I started with a Raspberry Pi and installed the following (after updating of course):
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install screen, vim, htop, icecast2, lame, libmp3lame-dev, ezstream, rtl-sdr
Once all that is done, set up Icecast (it uses port 8000, but that can be changed):
sudo vim /etc/icecast2/icecast.xml
Find the authentication section and change the passwords and then restart the server:
sudo service icecast2 restart
Then you can browse to
http://ip-of-raspberry-pi:8000 to see the Icecast server, there won't be any streams yet. Next set up ezstream which will stream to Icecast. Create an ezstream.xml file somewhere on your filesystem, and then there's example xml files here:
https://www.apt-browse.org/browse/debian/wheezy/main/i386/ezstream/0.5.6~dfsg-1/file/usr/share/doc/ezstream/examples, I used this one as my base:
https://www.apt-browse.org/browse/debian/wheezy/main/i386/ezstream/0.5.6~dfsg-1/file/usr/share/doc/ezstream/examples/ezstream_mp3.xmlChange the sourcepassword element to the password you set in icecast.xml and change filename to stdin, update the url and change /stream to what you want your stream to be mounted to, also update the svrinfo elements:
<ezstream>
<url>http://localhost:8000/tim273/edina</url>
<sourcepassword>your_password</sourcepassword>
<format>MP3</format>
<filename>stdin</filename>
<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/samplerate/channels
information matches up with your input stream files. Note that
<svrinfoquality /> only applies to Ogg Vorbis streams.
-->
<svrinfoname>Minneapolis, Minnesota Weather Radio</svrinfoname>
<svrinfourl>http://www.wunderground.com</svrinfourl>
<svrinfogenre>Weather</svrinfogenre>
<svrinfodescription>NOAA Weather Radio KEC65 162.55Mhz</svrinfodescription>
<svrinfobitrate>64</svrinfobitrate>
<svrinfochannels>2</svrinfochannels>
<svrinfosamplerate>48000</svrinfosamplerate>
<!--
Prohibit the server to advertise the stream on a public YP directory:
-->
<svrinfopublic>0</svrinfopublic>
</ezstream>
Next create a shell script to do the streaming that looks like this:
#!/bin/sh
sleep 10
rtl_fm -f 162.55M -s 48000 | lame -s 48000 --lowpass 3500 --abr 64 --scale 9 -r -m m - - | ezstream -c ezstream.xml
Feel free to adjust the parameters, -s is for sample rate, --abr 64 uses an average bit rate of 64 --scale -9 boosts the volume, --lowpass helps filter out the high pitched noise.
Add this script to /etc/rc.local right before exit 0 so it starts on boot:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
screen -d -m /home/pi/weather-radio.sh
exit 0
This starts the script in screen, when you ssh into the Pi, you can type:
sudo screen -r
This attaches to the screen that was created, and then Ctrl+A, D to detach from it. Don't type Ctrl+C as that will kill it. Using screen is an alternative to using a service, but if you're good with service scripts, feel free to write one of those. I had to add the sleep in there to give all the other services time to start up.
If all goes well you'll see this when you go into screen:
Found 1 device(s):
ezstream: Connected to http://localhost:8000/tim273/edina
ezstream: Streaming from standard input
0: Realtek, RTL2838UHIDIR, SN: 00000001
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 162802000 Hz.
Oversampling input by: 21x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Sampling at 1008000 S/s.
Output at 48000 Hz.
Lastly, add a new file called /etc/udev/rules.d/20.rtlsdr.rules and add this to it:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"
If you type lsusb, it will give a list of what's on your USB system, look for Realtek:
Bus 001 Device 006: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
And then substitute the device ID of the RTL SDR dongle (obviously plug it into the USB port) for the ATTRS{idVendor} (0bda in this case) value and then the model in the ATTRS{idProduct} part (2838 in this case). In terms of order, this one should probably be done before installing everything. You'll need to reboot for it to take effect.
I'm using a Raspberry Pi 3 and the utilization is pretty good.
[ You are not allowed to view attachments ]
If all works well, you should see this:
[ You are not allowed to view attachments ]
I think that's it, let me know if you have any problems.
Thanks,
Tim