Ham Radio Raspberry Pi streaming with scanner (Part 1)

OK, so we have been talking about getting one of these Raspberry Pi projects up. Lets do it! The end result will be a stand alone BroadCastify stream of your Ham Radio repeater needing only a single power source of 5V and 2A that can be put virtually anywhere.  This project will morph from the following parts:

  1. Raspberry Pi with scanner to local casting server.
  2. Raspberry Pi with scanner to BroadCastify Stream.
  3. Build a tool to keep the stream up in case it goes down.
  4. Raspberry Pi with rtl_sdr dongle to BroadCastify Stream.

Complete Parts list at bottom of page.

*I realize I am using sudo to run as root a lot and there are better ways. This is a tutorial for those that are not Linux savvy with a security background but those that are building a stand alone personal system.

Start with the RaspBerry Pi. The purchase price for the Pi 2 b only is around $35 USD. We will need that, an internet stream and an old scanner that receives and has squelch. The reason we want to make sure we can adjust the squelch is that when we broadcast we will be doing so 24 hours a day. We would turn folks off of our stream if we played static for the majority of time. Squelch is a way to tell the radio to be silent if the volume does not surpass a specific amount.  I think this is a good enough explanation on what squelch is for now.


All right, Now you have a Pi 2 B, a power cord, keyboard and mouse are plugged in as well as network and a monitor. we boot for the first time and run through the setup. I wont bother with that part, but here is a link if you need it. The easiest way I found to get this working was to get a USB mic.

Pi Setup <– Click Here

Turn on that scanner and make sure the external headphone jack works as expected.

For those new to Linux: If I show “$” then it means you will be a normal logged in user such as the default user “pi”. It is simply a prompt placeholder when referenced here and does not need to be copied and pasted in with the rest of the command. Only when I reference a command this symbol will be in front.

Run the following commands:

Apt-get is a package management utility that allows you to install pre-built packages and their dependencies fairly easily. The first command is to update the utility indexes.

 $ sudo apt-get update 

Then we will update the currently installed packages.

 $ sudo apt-get upgrade 

Then we need to install the packages “lame”, “ezstream” and “icecast2”.

$ sudo apt-get -y install lame ezstream icecast2

Once these install we need to configure them.

We will configure IceCast next. Configure Icecast2 <– Click here

Then we need an ezstream setup. Edit it and save as /etc/ezstream_local.xml

Here is the one for my IceCast server:


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:
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>Contact k0fey@arrl.net</svrinfoname><svrinfourl>https://k0fey.wordpress.com</svrinfourl><svrinfogenre>Ham Radio</svrinfogenre>
<svrinfodescription>146.880Mhz Repeater EPRC</svrinfodescription><svrinfobitrate>16</svrinfobitrate>
<!-- Allow the server to advertise the stream on a public YP directory: -->  <svrinfopublic>1</svrinfopublic>

ok, so we have these things configured. Now what? First lets run through Is Icecast2 already running? Lets see if it has a Process ID yet:

$ pidof icecast2

If anything shows up here then we are already running and you can move on. If not then we will start by typing:

$ sudo /etc/init.d/icecast2 start

Now we should be able to access “Icecast2″locally or from another computer:

Locally – open a browser and go to the address:

or from another computer on your network by going to:


At this point you should see something (but nothing super exciting yet, just a status page confirming it is working). If you do then we will move to getting your stream attached to it. This way the local computers on your network can listen to your ham radio broadcast.


We next plug in the USB mic. The Raspbian image already has the alsa-utils for sound already installed by default. This is the “alsamixer” setup:

alsa mixer
Run the following command:

$ sudo alsamixer

Then Press F6: Select Sound Card, and choose yours from the list, the one to pick is: USB Device 0x41e:0x30d3 (it should say “USB” in the line) and take note of the card number (This one is “1”).

Select the Mic and increase the volume to 50, you’ll likely need to change it later, but its a good place to begin. Press Esc to exit and save the settings with:

$ sudo alsactl store 1

where 1 is the USB hardware device number we saw earlier.

Now that we have that set up lets move to the app verification.

$ sudo arecord -l

and note the output. You should see something like:

**** List of CAPTURE Hardware Devices ****
card 1: Device [Generic USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Then connect the scanner to the mic jack on the USB input. A scanner tuned to NOAA weather with continuous output works good for this part.

This can be found at the following frequencies:

162.400 MHz, 162.425 MHz, 162.450 MHz, 162.475 MHz, 162.500 MHz, 162.525 MHz and 162.550 MHz

Adjust the volume to mid level on the scanner and verify this works before plugging in.

Then we run the following:

$ sudo arecord -f dat -c 1 -D hw:1,0 | /usr/bin/lame -r -s 48 --resample 44.1 -m m -b 16 -F --cbr --lowpass 2.8 --highpass .4 - - | /usr/bin/ezstream -c /etc/ezstream_local.xml &

So lets break that up into bite size chunks to see what we did:

$ sudo arecord -f dat -c 1 -D hw:1,0 

This calls the program “arecord” to run as root with the following:

-f dat (16 bit little endian, 48000, stereo) [-f S16_LE -c2 -r48000]

-c 1 (use single channel)

-D hw:1,0 (use device 1)

Then we pass this part with a “|” into to the next portion of the command:

/usr/bin/lame -r -s 48 --resample 44.1 -m m -b 16 -F --cbr --lowpass 2.8 --highpass .4 - -

This calls the program “lame” with the following:

-r -s 48 (Assume the input is raw PCM)

–resample 22.05 (Use an output sampling frequency of 22.05 kHz)

-m m (use mono mode)

-b 16 -F (Strictly enforce a bitrate of 16)

–cbr (enforce the use of constant bitrate)

–lowpass 2.8 (Set a lowpass filtering frequency of 2.8 kHz. Frequencies above the specified one will be cutoff.)

–highpass .4 (Set  a highpass filtering frequency of .4 kHz.  Frequencies below the specified one will be cutoff.)

Then we pass all that to the “ezstream” program. This outputs to the webpage/stream:

/usr/bin/ezstream -c /etc/ezstream_local.xml &

This calls ezstream with the config file ( -c ) at the location of /etc/ezstream_local.xml. The “&” at the end puts it all into the background. 

At this point you should be up an running. Now tune your scanner to your repeater frequency and refresh your browser window of: <-- for the ezstream interface <-- for the feed itself

click on the MP3 output and listen away.

Parts List:

Raspberry Pi 2 b w/ power (I like the starter kit with case)

USB keyboard and mouse

Monitor – To see what you are doing. Does not need to be permanent as the end goal is to get a standalone system that can be easily tucked away.

Edimax EW-7811Un 150Mbps 11n Wi-Fi USB Adapter – This is only if you are not plugging in directly to a router.

A scanner that can stay on a fixed channel, has squelch built in and has a headphone output.

A male-male headphone cable or this and an AV cable

We will pick this up next time with connecting this to a Broadcastify stream.

Click here for my club repeater linked to BroadCastify


Have fun and 73’s,

Let me know what questions you want me to address or if anything is unclear. My email is k0fey@arrl.net



About K0FEY

I am a member of the Eden Prairie Radio club. This is a Minnesota Ham Radio Enthusiast club and we promote experimentation and learning through the Amateur Radio hobby. Come check into a net on Sunday with us or better yet meet us in person on the 3rd Thursday of the month.
This entry was posted in Experiments, Ham Radio, Linux, Repeater, Scanner, Web. Bookmark the permalink.

One Response to Ham Radio Raspberry Pi streaming with scanner (Part 1)

  1. Steve Mason says:

    Thanks so much for this! I’m changing my personal scanner feed from a Windows box to a Pi, and this was exactly what I needed. I would have been days or weeks (or never) figuring it out.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s