Raspberry Pi with rtl_sdr dongle to BroadCastify Stream (Part 4)

This is a 4 part series. The parts are as follows:

  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.

Even if you keep the squelch wide open the feed terminates and you have to restart it manually.

What is happening is that the stream is stopping because there is no data keeping it alive. We will need to pad the dead space. Broadcastify has a good solution for this with the Raspberry Pi. Here is the copy/paste directly from their site:

Install pre-reqs and update raspberry pi to latest version

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git cmake libusb-1.0-0.dev build-essential
sudo apt-get install libmp3lame-dev libvorbis-dev libshout-dev
sudo rpi-update && sudo reboot

Install the latest rtl-sdr code

This latest git release is needed for padding zeros when squelch is enabled (-E pad option)

git clone https://github.com/keenerd/rtl-sdr/
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
sudo mv $HOME/rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/rtl-sdr.rules

Blacklist the kernel’s bundled RTL drivers

We do this so we don’t conflict with the RTL drivers we’re about to install

sudo su -
echo "blacklist r820t" >> /etc/modprobe.d/dvb-blacklist.conf
echo "blacklist rtl2832" >> /etc/modprobe.d/dvb-blacklist.conf
echo "blacklist rtl2830" >> /etc/modprobe.d/dvb-blacklist.conf
echo "blacklist dvb_usb_rtl28xxu" >> /etc/modprobe.d/dvb-blacklist.conf
exit

Install and configure ezstream

sudo apt-get install ezstream

Create this configuration file at /etc/ezstream_bcfy.xml and replace with your mount, password, and stream name

<ezstream>
    <url>http://audio#.broadcastify.com:80/your_mount</url>
    <sourcepassword>your_source_password</sourcepassword>
    <format>MP3</format>
    <filename>stdin</filename>
    <svrinfoname>Stream Name</svrinfoname>
    <svrinfourl>http://www.broadcastify.com</svrinfourl>
    <svrinfogenre>Scanner</svrinfogenre>
    <svrinfodescription></svrinfodescription>
    <svrinfobitrate>16</svrinfobitrate>
    <svrinfochannels>1</svrinfochannels>
    <svrinfosamplerate>22050</svrinfosamplerate>
    <svrinfopublic>0</svrinfopublic>
</ezstream>

rtl_fm – command line tuner for rt stick

rtl_fm
-d 0           	device 0 (first rtl stick, second rtl stick would be -d 1)
-M am           tune to AM Mode
-f 124.55M      tune to 124.55 MHz (use multiple -f entries to scan through frequencies)
-l 65           set scanning squelch to 65 (adjust as needed)
-p 69           ppm offset
-g 40.2         gain (0-49.6) - adjust as needed
-t 0            scanning delay (I set to 0, default is 10)
-E pad          when squelch is enabled pad output with zeros (required when broadcasting)
-s 8k           sample at 8k

which is then piped to the mp3 lame encoder…

lame - MP3 encoder
-r           accept raw data input
-s 8          sample in at 8k
-m m          encode mono
-b 16          encode at 16kbs bitrate
--cbr         use Broadcastify’s mp3 cbr standard
--lowpass 4  use a low pass filter of 4
--scale 16   turn up the volume for AM Mode

which is then piped to ezstream

ezstream -c /etc/ezstream_bcfy.xml

Command for FM Scanning and Streaming

/usr/local/bin/rtl_fm -d 0 -M fm -f 461.4M -p 69 -l 65 -g 50 -t 2 -E pad -s 12k |
/usr/bin/lame -r -s 12 --resample 22.05 -m m -b 16 --cbr --lowpass 4 - - |
/usr/bin/ezstream -c /etc/ezstream_bcfy.xml > /var/log/bcfy2.log 2>&1 &

rtl_fm – command line tuner for rt stick

rtl_fm
-d 0           	device 0 (first rtl stick, second rtl stick would be -d 1)
-M fm           tune to FM Mode
-f 461.4M      tune to 461.4 MHz (use multiple -f entries to scan through frequencies)
-l 65           set scanning squelch to 65 (adjust as needed)
-p 69           ppm offset
-g 40.2         gain (0-49.6) - adjust as needed
-t 2            scanning delay (I set to 2, default is 10)
-E pad          when squelch is enabled pad output with zeros (required when broadcasting)
-s 12k           sample NFM at 12k

which is then piped to the mp3 lame encoder…

lame - MP3 encoder
-r           accept raw data input
-s 12          input at 12k
--resample 22.05   resample at 22.05Khz
-m m          encode mono
-b           encode at 16kbs bitrate
--cbr         use Broadcastify’s mp3 cbr standard
--lowpass 4  use a low pass filter of 4

which is then piped to ezstream

ezstream -c /etc/ezstream_bcfy.xml

S

Command for AM Aviation Scanning and Streaming

/usr/local/bin/rtl_fm -M am -f 124.55M -f 133.4M -f 121.6M -l 65 -p 69 -g 40 -t 0 -E pad -s 8k |
lame -r -s 8 -m m -b 16 --cbr --lowpass 4 --scale 16 - - |
ezstream -c /etc/ezstream_bcfy.xml

That is a great tutorial from their site. It worked for me and because of that I did not want to lose it to modifications down the line. Hence why I copied it here. Now I had played around quite a bit with this to get it to sound good and go into the background. Here is the final version of the actual command I ran:

/usr/local/bin/rtl_fm -d 0 -M fm -f 146.88M -p 44 -l 19 -g 20.7 -t 5 -s 28k -E pad | /usr/bin/lame -r -s 28 --resample 44.1 -m m -b 16 -F --cbr --lowpass 2.8 --highpass .4 - - | /usr/bin/ezstream -c /etc/ezstream_bcfy.xml &

IT works well for me with the script in play (from Part 3 that fixes the stopped stream as well as checks for running processes and stops the console output from logging or filling up) as well but the usb sdr’s do tend to very easily get overloaded. I cannot put this close to my transmitter when I am running a net or I will wipe out my signal completely.

We are finally at the end of this project. Let me know how yours turned out and what we should look at next.

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

radioactive

Advertisements

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, SDR (Software Defined Radio). Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s