JTK – Notes and Ramblings Things we have found …

1/3/2019

Pi Weather Radio w/SAME

Filed under: General,Home Automation,RTL-SDR — taing @ 11:35 pm

So I have been planning to use the SDR dongle as a weather radio for some time. The goal was to stream the audio AND capture the digital SAME messages to signal weather alerts.

I found several useful references online: https://github.com/tim273/weather_radio_scripts, https://github.com/cuppa-joe/dsame, https://www.dynode.nl/streaming-radio-receivers-with-the-raspberry-pi/ and https://www.wxforum.net/index.php?topic=31396.msg314826#msg314826.

I installed rtl-sdr, lame, icecast2 and ezstream.

sudo apt-get install rtl-sdr lame icecast2 ezstream

I created 20.rtlsdr.rules in /etc/udev/rules.d/

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"

I created /etc/modprobe.d/rtlsdr-blacklist.conf

blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830

After rebooting I was able to use rtl_test successfully. Using the NOAA website I was able to look up the require frequency for my location. It took a bit of fiddling to get the proper frequency setting for the dongle to actually tune the desired channel. The desired frequency for me is 162.55Mhz. I ended up using 162.298M to truly tune 162.55M.

rtl_fm -f 162298000 -s 48000 -p 14

Piping this to lame results in an MP3 stream.

rtl_fm -f 162298000 -s 48000 -p 14 | lame --bitwidth 16 --signed -s 48000 --lowpass 3500 --abr 64 --scale 8 -r -m m - - > test.mp3

The next step was to create a config XML file to ezstream and test the stream. A little touch-up is required for the sample below.

exstream.xml
<ezstream>
<url>http://your-ip:8000/weather</url>
<sourcepassword>xxxxxxxx</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>Weather test stream</svrinfoname>
<svrinfourl>your-ip</svrinfourl>
<svrinfogenre>weather</svrinfogenre>
<svrinfodescription>Weather test stream</svrinfodescription>
<svrinfobitrate>32</svrinfobitrate>
<svrinfoquality>2.0</svrinfoquality>
<svrinfochannels>1</svrinfochannels>
<svrinfosamplerate>48000</svrinfosamplerate>
<!-- Turn off YP directory advertising -->
<svrinfopublic>0</svrinfopublic>
</ezstream>
rtl_fm -f 162298000 -s 48000 -p 14 | lame --bitwidth 16 --signed -s 48000 --lowpass 3500 --abr 64 --scale 8 -r -m m - - | ezstream -c ezstream.xml

The test icecast2 stream can be found at http://your-ip:8000/weather. The icecast2 config can be edited at /etc/icecast2/icecast.xml. Documentation for the config file can be found at http://icecast.org/docs/icecast-2.4.1/config-file.html.

Next I’ll be working to integrate the python from https://github.com/cuppa-joe/dsame handle the digital side of the stream. For now we have the stream going to the icecast2 stream and also piping to the next thing.

rtl_fm -f 162298000 -s 48000 -p 14 | lame --bitwidth 16 --signed -s 48000 --lowpass 3500 --abr 64 --scale 8 -r -m m - - |tee >(ezstream -c ezstream.xml) | cat >test1.mp3

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress