<p>In this episode I talk about how I used a Raspberry Pi to create a streaming radio device to feed my pillow speaker. This is something I used to do with clock radios and later a satellite radio, but in an effort to decrease monthly subscription costs for services I did not use optimally, I discontinued my satellite radio subscription about a year ago. This new free solution is an excellent substitute for Satellite Radio so far, since I was mostly listening to this same channel on the Sat Radio but paying about $12 a month for the privilege. The device I’m using is a <a href="https://www.raspberrypi.org/products/raspberry-pi-2-model-b/">Raspberry Pi 2 Model B</a> with <a href="https://ubuntu.com/download/raspberry-pi">Ubuntu Server</a>. My barrier to this project in the past was not being able to find the URL for the stream I wanted but I discovered you can find it easily if you use Firefox with <a href="https://www.downloadhelper.net/">Video Download Helper</a> to reveal the URL on a page with media playing (in this case it’s from TuneIn):</p>

<pre><code>https://XX.XXX.XXX.XXX/radio-stationmp3-48?session-id=af1b271fefba04b650f8e253c6b253bd&source=TuneIn
</code></pre>

<p>Strip off everything after the <code>48</code> to get raw URL:</p>

<pre><code>https://XX.XXX.XXX.XXX/radio-stationmp3-48
</code></pre>

<p>Command to play stream with <a href="https://www.mpg123.de/">mpg123</a> on the Pi. Using the <code>-q</code> option to suppress output:</p>

<pre><code>mpg123-pulse -q https://XX.XXX.XXX.XXX/radio-stationmp3-48 &
</code></pre>

<p>Once I figure out the command that plays the stream I want, I save the command as an executable script in <code>/home/$user/bin</code>.</p>

<h3 id="usingtheradio">Using the “Radio”</h3>

<p>To start playing a stream you first have to SSH into the RasPi. This is easy from a laptop using any terminal emulator. I use pubkey auth so I don’t have to type a password every time. On my phone I use <a href="https://play.google.com/store/apps/details?id=org.connectbot&hl=en_US">ConnectBot</a>. Once I’m into the Pi I run the radio commands from CLI like <code>espn</code> or <code>kmfa</code> or <code>krvs</code>. To stop playback I kill the process with <code>pkill mpg</code>. I have a 3.5mm audio splitter Plugged into the headphone jack of the USB audio interface. In one side of the splitter I’ve got an old pair of earbuds where one side didn’t work, with the working earbud under my pillow. That’s my pillow speaker. On the other side of the splitter I put the audio cable for an <a href="https://smile.amazon.com/gp/product/B005GUQ0FI/">FM transmitter</a>, so that I can use an FM radio to listen to the stream while I’m walking around the house.</p>

<p>Click the image below to see pictures of the setup.</p>

<p><a data-flickr-embed="true" href="https://www.flickr.com/photos/137675441@N05/albums/72157712927722077" title="Raspberry Pi Radio"><img src="https://live.staticflickr.com/65535/49473218252_39195601ed.jpg" width="500" height="281" alt="Raspberry Pi Radio"></a></p>

<h3 id="links">Links</h3>

<ul>
<li><a href="https://www.raspberrypi.org/products/raspberry-pi-2-model-b/">Raspberry Pi 2 Model B</a></li>
<li><a href="https://ubuntu.com/download/raspberry-pi">Ubuntu Server</a></li>
<li><a href="https://www.downloadhelper.net/">Video Download Helper</a> (Firefox extension)</li>
<li>The <a href="https://smile.amazon.com/gp/product/B001MSS6CS/">USB Audio interface</a> I use</li>
<li>Panda Wireless <a href="https://smile.amazon.com/gp/product/B00762YNMG">USB WiFi adapter</a></li>
<li><a href="https://www.mpg123.de/">mpg123</a> command-line audio player</li>
<li><a href="https://play.google.com/store/apps/details?id=org.connectbot&hl=en_US">ConnectBot</a></li>
<li><a href="https://smile.amazon.com/gp/product/B005GUQ0FI/">C. Crane FM Transmitter</a></li>
</ul>
