Actions

Difference between revisions of "Raspberry Pi RTL-SDR Broadcastify"

From The RadioReference Wiki

(Redirected page to Broadcastify Raspberry Pi Image)
Tag: New redirect
 
Line 1: Line 1:
[[File:rtl_rsp_bcfy.jpg|200px|thumb|right|Raspberry Pi Broadcastify RTL-SDR Feed Appliance]]
+
#REDIRECT [[Broadcastify Raspberry Pi Image]]
These instructions show you how to purchase and setup a completely self contained Raspberry Pi with an RTL-SDR stick to broadcast a live audio feed to Broadcastify.com. This tutorial assumes you have a basic understanding of Linux and Raspberry Pi computers.
 
 
 
''Updated 2020-09-10''
 
 
 
== Purchase Equipment ==
 
 
 
 
 
RTL-SDR RTL2832U USB Stick
 
* Nooelec NESDR Smart v4 Bundle - Premium RTL-SDR w/Aluminum Enclosure https://amzn.to/3kaHMJL
 
 
 
 
 
Raspberry Pi
 
* CanaKit Raspberry Pi 3 B+ (B Plus) with Premium Clear Case and 2.5A Power Supply https://amzn.to/2FkC48V
 
 
 
== Install Raspbian OS ==
 
 
 
* Follow the instructions here:
 
** https://www.raspberrypi.org/documentation/installation/installing-images/README.md
 
 
 
Once you have your Raspberry Pi booted and online you may continue.
 
 
 
== Install pre-reqs and update raspberry pi to latest version ==
 
 
 
sudo apt-get update
 
sudo apt-get upgrade
 
sudo apt-get install build-essential libmp3lame-dev libshout3-dev libconfig++-dev
 
sudo apt-get install libraspberrypi-dev
 
sudo apt-get install libfftw3-dev
 
sudo apt-get install librtlsdr-dev
 
sudo apt-get install rtl-sdr
 
sudo reboot
 
 
 
== Install RTLSDR-Airband ==
 
cd ~/
 
mkdir RTLSDR-Airband
 
cd RTLSDR-Airband
 
wget -O v3.1.0.tar.gz https://github.com/szpajder/RTLSDR-Airband/archive/v3.1.0.tar.gz
 
tar xvfz v3.1.0.tar.gz
 
cd RTLSDR-Airband-3.1.0
 
make PLATFORM=armv8-generic NFM=1
 
 
 
Let it compile until it finishes then install it ...
 
 
 
sudo make install
 
 
 
The program should now be installed to /usr/local/bin/rtl_airband. The default configuration file will be installed to /usr/local/etc/rtl_airband.conf which we will edit next.
 
 
 
== RTLSDR-Airband Config ==
 
To edit the config file for RTLSDR-Airband enter this command:
 
sudo nano /usr/local/etc/rtl_airband.conf
 
and paste the following into the editor
 
 
 
# This is a minimalistic configuration file for RTLSDR-Airband.
 
# More complex configurations are possible.
 
# Refer to https://github.com/szpajder/RTLSDR-Airband/wiki
 
# for description of keywords and config syntax.
 
# Just a single RTL dongle with one FM channel
 
# sent to a single Broadcastify stream.
 
# Note that the center freq is 100 KHz offset from the receive freq
 
# Also, you must enter your server number, stream name, mountpoint and
 
# password from your Broadcastify stream "Technicals"
 
devices:
 
({
 
  type = "rtlsdr";
 
  index = 0;
 
  gain = 25;  # This may need adjustment depending on your hardware
 
  centerfreq = 153.87;
 
  correction = 0;  # this can be determined using "cumulative" output from running 'rtl_test -p' for several minutes
 
  channels:
 
  (
 
    {
 
      freq = 153.77;
 
        modulation = "nfm";
 
        highpass = 320;
 
      outputs:
 
        (
 
        {
 
          type = "icecast";
 
          server = "audio#.broadcastify.com";
 
          port = 80;
 
          mountpoint = "MOUNTPOINT";  # Note: Do not include a leading slash "/"
 
          name = "Fire Dispatch";
 
          genre = "Fire";
 
          username = "source";
 
          password = "PASSWORD";
 
        }
 
      );
 
    }
 
  );
 
});
 
 
 
== Run ==
 
It’s time to test. RTLSDR-Airband must run as root in order to have access to the GPU hardware.
 
sudo /usr/local/bin/rtl_airband -f
 
You should see a readout of numbers. The numbers should be larger when a signal is detected. Check your Broadcastify stream to see if the feed is streaming live. Once you confirmed everything is working, kill the program with CTRL+C.
 
 
 
== Create a service ==
 
Now you will want RTLSDR-Airband to run on startup of the Pi as well as restart if there are any errors or crashes over time (bound to happen eventually). Navigate to your RTLSDR-Airband folder. It should be somewhere like this:
 
cd /home/pi/RTLSDR-Airband/RTLSDR-Airband-3.1.0
 
sudo nano init.d/rtl_airband.service
 
Now in this rtl_airband.service file, change Restart=No to
 
Restart=on-failure
 
and add this line directly below it
 
RestartSec=5s
 
Save (ctrl+x and y) and then run these commands to copy the config over and create the service:
 
 
 
sudo cp init.d/rtl_airband.service /etc/systemd/system
 
sudo chown root.root /etc/systemd/system/rtl_airband.service
 
sudo systemctl daemon-reload
 
sudo systemctl enable rtl_airband
 
 
 
Now to run it, you simply need to type
 
sudo systemctl start rtl_airband
 
or just reboot the Pi!
 
 
 
== More info, expansion and troubleshooting ==
 
Much of this information I gleaned from this very helpful tutorial:
 
https://viatorci.com/posts/rtlsdr-police-scanner/#install-rtlsdr-airband
 
There are so many more possibilities with this setup and you can scan, receive multiple channels within the rtl-sdr's bandpass and a multitude of other things. This page is intended to get you streaming quickly and is not intended to address all of those scenarios.
 
 
 
If you have issues running any of the commands above using sudo try activating the su function in Raspbian. More info [https://www.raspberrypi.org/forums/viewtopic.php?t=66887 here]. Use at your own risk!
 
 
 
 
 
 
 
<big>'''INFORMATION BELOW MAY BE OUTDATED'''</big>
 
 
 
 
 
 
 
== Stream directly from a USB sound card ==
 
 
 
If you already have a scanner ready to go and just want to use the Raspberry Pi to broadcast your radio to broadcastify, simply purchase an inexpensive USB sound card dongle, plug it in to the Raspberry Pi, and follow these steps:
 
 
 
* Purchase USB Soundcard Dongle:  http://amzn.to/1hekylB  ($1.70)
 
* Install and configure ezstream with your feed's details
 
* Start alsamixer
 
 
 
pi@raspberrypi:~# alsamixer
 
 
 
* press F6, choose the "USB Headphone Set" entry
 
* press your tab key to select the "Capture" device volume control
 
* use your "up arrow" key to adjust the level to it's lowest level possible above 0 -  (6)
 
* press escape to exist alsamixer
 
* run the following command to save the volume settings
 
 
sudo alsactl store
 
 
 
* Run this command to start the sound card broadcast
 
 
 
arecord -f dat -c 1 -D hw:1,0 | \
 
/usr/bin/lame -r -s 48 --resample 22.05 -m m -b 16 --cbr --lowpass 4 - - | \
 
/usr/bin/ezstream -c /etc/ezstream_bcfy1.xml > /var/log/bcfy1.log 2>&1 &
 
 
 
Note: very little volume will be needed from your scanner - adjust the levels as appropriate for a good sounding feed.
 
 
 
== Start stream on boot ==
 
 
 
Easiest way is to add your full command(s) to /etc/rc.local just before the exit 0 entry
 
 
 
TODO: formal startup scripts.
 
 
 
== Verify System is running and connected ==
 
 
 
I've found that occasionally lame will crash/stop and take the feed offline (at least with my setup).
 
 
 
I've made a script to reboot the Pi if it happens.  The script will check if the user pi is logged in - if so it won't reboot because maybe you are working on it.
 
 
 
Copy the script below, and create a file in /etc called checkstuff.sh
 
 
 
sudo nano /etc/checkstuff.sh
 
 
 
#!/bin/sh
 
 
PROCESS="$1"
 
PROCANDARGS=$*
 
 
RESULT=`who | grep pi`
 
 
if [ "${RESULT:-null}" = null ]; then
 
echo "Nobody logged in.  We'll check for  other stuff"
 
logger "checkstuff: Nobody logged in.  Continueing checks."
 
else
 
logger "checkstuff: Pi is logged in.  Bypass all other checks."
 
exit 0
 
fi
 
 
RESULT=`netstat -an | grep :80`
 
 
if [ "${RESULT:-null}" = null ]; then
 
logger "checkstuff: No connection to RadioReference.  Rebooting."
 
sudo reboot
 
else
 
logger "checkstuff: Connection established to RadioReference."
 
fi
 
 
RESULT=`pgrep rtl_fm`
 
 
if [ "${RESULT:-null}" = null ]; then
 
logger "checkstuff: rtl_fm not running.  Rebooting."
 
sudo reboot
 
else
 
logger "checkstuff: rtl_fm running."
 
fi
 
 
RESULT=`pgrep lame`
 
 
if [ "${RESULT:-null}" = null ]; then
 
logger "checkstuff: Lame not running.  Rebooting."
 
sudo reboot
 
else
 
echo "lame running"
 
logger "checkstuff: Lame running."
 
fi
 
 
RESULT=`pgrep ezstream`
 
 
if [ "${RESULT:-null}" = null ]; then
 
logger "checkstuff: EZStream not running.  Rebooting."
 
sudo reboot
 
else
 
logger "checkstuff: EZStream running."
 
fi
 
 
logger "checkstuff: Feed should be online."
 
 
 
Save the file and exit nano. 
 
 
 
Now the file needs to be made executable:
 
 
 
sudo chmod 755 /etc/checkstuff.sh
 
 
 
You now need to set up a schedule to run the script.  I've set mine to run automatically every 10 minutes.  This can be done by updating the cron jobs:
 
 
 
sudo crontab -e
 
 
 
Paste the following lines at the bottom.
 
 
 
*/10 * * * * /etc/checkstuff.sh
 
 
 
Save & exit the file.  The script will now run every 10 minutes (at x:00, x:10, x:20, x:30, x:40 and x:50).  It will log to the /var/log/messages logfile every time it runs.
 
 
 
 
 
 
 
[[Category:Software for Live Audio Broadcasting]]
 
 
 
 
 
Also refer to another thread postings ... https://wiki.radioreference.com/index.php/Broadcastify/RTLSDR-Airband
 

Latest revision as of 09:44, 18 April 2021