Published: Jun 11, 2022 by Joel Vazquez, WEØDX


How did I connect NOAA Radio audio to the PBX?

This took me a weekend to figure out. Mostly for the lack of updated documentation on some of the commands. I used a USB RTL SDR device I have laying around the house and here is how I did it.

Note: This will assume you have a working Freepbx setup, and you have an IVR already in place. Also, this is just some notes on how to acomplish, not by any means a complete guide.

What will be needed?

  • A USB RTL SDR device.
  • I recomend using another computer or even a Raspberry Pi to host the feed.
  • Start installing these packages (either from source or from the distribution).

- rtl-sdr ezstream icecast2

- Look for the icecast2 configuration file, take note of the network port you will be hosting icecast2 on (default is 8000, change it as needed), also update the authentication section of it.

<authentication>
    <!-- Sources log in with username 'source' -->
    <source-password>Change_Me_123</source-password>
    <!-- Relays log in username 'relay' -->
    <relay-password>Change_Me_123</relay-password>
    <!-- Admin logs in with the username given below -->
    <admin-user>admin</admin-user>
    <admin-password>Change_Me_123</admin-password>
</authentication>

Create a file called ezstream.xml (adjust it to your needs):

<ezstream>
    <url>http://localhost:8000/KID77</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>KID77 WX Radio for Kansas City, MO</svrinfoname>
    <svrinfourl>https://www.we0dx.us</svrinfourl>
    <svrinfogenre>Public Information</svrinfogenre>
    <svrinfodescription>NOAA Weather Radio from Kansas City, MO</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>

Now adjust the following command to your situation:
rtl_fm -f 162.550m -s 24000 -p 14 | lame --bitwidth 16 --signed -s 24000 --lowpass 3500 -b 128 --cbr --scale 8 -r -m m - - | ezstream -c /etc/ezstream.xml

For example:

  • update the frequency for your nearest NOAA station. In my case it was 162.550m
  • adjust the the location of the ezstream.xml at the end, in this case it was in /etc/ezstrem.xml.

If successfull you should get something like this:

Found 1 device(s):
ezstream[1192655]: /etc/ezstream.xml: world readable
0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Detached kernel driver
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuner error set to 14 ppm.
Tuned to 162802000 Hz.
Oversampling input by: 42x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Allocating 15 zero-copy buffers
Sampling at 1008000 S/s.
Output at 24000 Hz.

Note that this has to be running for the stream to work. That means you will have to make it run either as a service, or with screen or similar solution so it stays running after you logoff.

Once that its done, make sure the network port, that you either took note of or change on the icecast2 configuration file, is opening and available from other computers in the network and is not blocked by a firewall. This bite me for a few hours...

If it is open, you should be able to open the stream from other computer with VLC or other similar. As you notice this information comes from the ezstream configuration file url field you just updated. For example my stream is:

http://192.168.1.30:8000/KID77.m3u


Now let's work on FreePBX

On this side thinks are easier. First we need to setup the "On Hold Music". This will be the connection to the icecast2 stream.

For this, in your Freepbx console go to Settings > Music On Hold.

- Click Add Category and create one with what ever name you want, and Type Custom Application

- Hit Submit

- Back on On Hold Music page, click on the pencil to update the Category you just created.

- Now on Application, copy and paste this and update it:

/usr/bin/mpg123 -q -s --mono -f 12500 -b 1024 http://192.168.1.30:8000/KID77

- Make sure you update it with your informacion. No need for the m3u at the end ;).

- Now go to Applications > Queues

- Add a Queue. Just update Queue Number and Queue Name as needed.

- Look for Music on Hold Class, and select the one you just created.

- Update other fields as needed, I left mine by default.

- To add it to your IVR, got to Applications > IVR.

- Open your IVR by cliking on the pencil. Add the queue as an IVR Entries

- And that's all, you should have your NOAA radio on your Freepbx. Hope you enjoy it!

Alternative way:

An alternative way to do this is, if you find the audio feed from the internet, you can just "pull" it from the internet directly. I could not found a feed for my NOAA radio station, so I had to use the previous process. When configuring the Music On Hold, configure the address like this:

/usr/bin/mpg123 -q -s --mono -f 12500 -b 1024 http://{host_url}/{feed}

Like: /usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 1024 http://wxradio.org/KS-Topeka-WXK91

Note that it has to be http, it would not work if it is https (encrypted).


we0dx ham radio Hamshack Hotline freepbx

Like you, I appreciate my privacy. That’s why I have setup my website eliminating as much tracking code as I can find. But I would still like to receive your comments on my page. Please send them to joelvazquez a_t we0dx.us


Last update
2022-06-12 13:43:40 -0500

Latest Posts

How to patch RX feed from a rtl sdr of NOAA Weather Radio to Freepbx.

Finally the tower is up!

A change in direction. I'm not afraid of the change!


Solar Conditions & Propagation