Introduction: One Station Radio

So a small introduction as to why I did this.

One of my bosses is a real craftsman he can literally weld whatever he wants. And when he is working he likes to listen to his favorite radio station. To do so he uses an old stereo system with an FM receiver given to him by Moses when he updated his setup. Now this hasn't been a problem since old electronics will last a lifetime or 900 however last winter he isolated his shop and put a new outer shell on it. since the new shel is steel plates FM reception is bad. Not wanting to throw out Moses' old radio because of the great sound it produces I scoured my piles of old electronics. in order to build him a cheap one station internet radio receiver.

what I found;

Raspberry Pi 1 ( but you can use any pi you want.)
TP-LINK TL-WN725N USB wifi adapter ( because the pi doesn't have it on board)
SD card (8gb why use more :) )
audio cable
old phone charger (if you plan on using a newer radio or a set of PC speakers with a USB port you could power the Pi of of that)

What I made it do;

It plays just one radio station. Nothing more, nothing less.

this is my first ever instructeble, if there are any points of improvement please let me know. also English is not my first language so please let me know where I screwed up so I can correct it! have fun!

Supplies

Raspberry Pi 1 ( but you can use any pi you want.)
TP-LINK TL-WN725N USB wifi adapter ( because the pi doesn't have it on board)
SD card (8gb why use more :) )
audio cable
old phone charger (if you plan on using a newer radio or a set of PC speakers with a USB port you could power the Pi of of that)

only during setup:

UTP cable
HDMI cable
TV
Keyboard

Step 1: Preparing the Pi.

So, in order to get you pi to do anything we need it to have a OS. I love Raspberry Pi OS lite, because it is smal and does nothing special. so I download an image here you could also use one of the other distributions if you like a graphic interface while setting up. however I like to work headless on these things so I did not bother.

Before the image you downloaded can be burnt to the SD card you have to clean it thoroughly, so get yourself an SD card formatter and clean that little old card of any and all old mistakes you have made it carry around.

Now Burn you image to the card. I use Etcher for this. This normally works great. however, the bosses at apple ( yes I use Mac) have decided not all software can acces al part of you computer anymore. if you have the same problem ( etchers starts>you see your SDcard>you load your immage> you start..... error) start etcher using this command in terminal.;

sudo /Applications/balenaEtcher.app/Contents/MacOS/balenaEtcher

it will work just fine that way.

Once your image is burned into the SDcards never fading memory remove it safely. and place it in you PI.

Get ready to boot this puppy up.

Step 2: First Boot

So the first boot up of the pi is to make it up to date and to make our life easier for the rest of the project.
some of the steps I'm about to follow are due to the fact that my pi does not have an internal wifi antenna. if yours does you will be ready much faster.

For this part of the trip we need all the extra stuff we won't be using after the machine is ready. so plug every whole this pi has. ( for a keyboard I like to use the Logitech k400+ no I'm not payed to say that ( but I will accept that ;) ) I just love the thing.

so now we have the PI hooked up to a tv or monitor of some sort, the usb wifi thing is put in to place, the utp cable is connected to the network and the keyboard is attached. time to power the puppy.

after it boots you will need to log in.
your username is pi
and your password is raspberry

Now we want to update the pi type
sudo apt-get update
and hit enter.

The next step is to make our life easier. we are switching on SSH.

type:
sudo raspi-config
hit enter

a menu is loaded where your can configure your pi.
navigate to option 5 an hit inter
in the next menu select option P2 ( the ssh settings) en say yes to enabling.
if you have any concerns of people breaking in to your pi over ssh this is the time to also change your username and password.

so after this is done we can ssh into our pi and use one machine to read this instructable, google the shit out of things we do not know or understand and configure the rest of our pi.
As I sayed I'm on a MacBook so I use Terminal for SSH but you can use whatever client you like ( for most windows users that will be putty)
to use SSH in Terminal type;

ssh @ and hit enter

if for some reason the IP address of your pi is a mystery to you use the keyboard hooked to the pi and type

ifconfig

hit enter and in the bulk of text behind eth0 you will find you ip address.

so from now on we can chose to use ssh or work directly on the pi.

let's get that wifi working :)

Step 3: WIFI

so if u use an other usb wifi adapter than mine you could be so lucky that is is supported. let's find out.

type ;

sudo raspi-config

and hit enter.
in the menu go to option 2 and than option N2 to insert your SSID and password.
if however your wifi adapter like mine is not supported follow these steps.

first we want to know what version of the OS we are running so we type;

name -a

and hit enter. the result should be a line of text like this:
Linux yourPiName 4.19.118+ #1311 Mon Apr 27 14:16:15 BST 2020 armv6l GNU/Linux

now we want to know what chipset our Wifi adapter has so we type;

lsusb

and hit enter in the outcome of the there are several lines describing all the devices connected. one line needs our attention and it looks something like this:
Bus 001 Device 004: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter

note the two parts of the text in bold. that's the information we where after.
now go to this site it's the site of mrEngman and he hosts drivers for most wifi adapters. first browse to the folder named after your chipset, in my case 8188EU. Next search for the file with your pi OS version in it. in my case 4.19.118-1311 copy the URL to the file. and go to your ssh session and type;

sudo wget <paste here your URL>
and hit enter. there should start a download. once this is complete we need to unpack the package. type:

tar -xvzf <name of the file you just downloaded>

in my case this results in tar -xvzf 8188eu-4.19.118-v8-1311.tar.gz

after unpacking is complete there will be 3 files. now you need to install them. type:
sudo ./install.sh
and hit enter. now the drivers will be installed.
after installation of the driver is completed you should be able to inset you wifi credentials as written in the top of this step.
after that is done reboot your pi ( sudo reboot now) with you UTP disconnected and you display connected.
after rebooting you pi should now be connected via wifi and have a new IP. use this IP to ssh back in to the PI so we can make it a radio!

Step 4: Play for Me!

so to make this thing we created play music we are going to use MPD with MPC ( music player deamon)
now first we need to install these so we type:

sudo apt-get install mpc mpd

and hit enter. mpd wil be installed. now we add a station so type

mpc add <url of your favorite radio station> in my case this results in:

mpc add https://21293.live.streamtheworld.com/KINK.mp3

and hit enter. this address will now be added to the playlist.

to check if it works type:

mpc play

and hit enter. your stream should start playing. if there is a tv connected to your HDMI the TV will play the music, if speakers of any kind are connecter to the 3,5" jack output there will be sound there.
if you don't hear a thing use "mpc current" to see if anything is playing and what the output volume is.

to make sure mpc does not forget our radio station we save it to a playlist to do so type

mpc save <filename of your choice>
and hit enter your playlist is now saved.

to make sure music plays from the desired output ( in my case de 3,5" jack) we set that as the primary setting.
type:
sudo raspi-config
hit enter en navigate to 7 advanced options, go to A4 and force the audio to the output of choice.

now time to make it play on startup!

Step 5: Wake Up and Play!

to make a pi do tasks at/ after startup there is a file we need to edit this file is called rc.local. to edit this file we use nano, your pi's text editor. type:

sudo nano /etc/rc.local

and hit enter. a file will open with the following content;

==================================

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
exit 0

==================================

all the text after a # does nothing so basically this file only listens if there is an ip address and when that happens it prints it and exits. (exit 0 )

now we want to add a line of code before it exits. this way we can make it run our radio station. so before the exit command add. mpc play &

your file should look like this:

==================================

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
#play MPC
sudo mpc play &
exit 0

========================

exit the file by pressing ctrl+x and pres y for saving it.

nou if you would command you pi " sudo reboot now" your pi should reboot en start playing music when done. JAY!

Step 6: Aditional Steps

okay, you are done, you have a single station radio. But to make it easier to maintain the thing in the future you can follow these additional steps.

Set a static IP;

to do so we edit dhcpcld.conf. type:

sudo nano /etc/dhcpcd.conf

and hit enter, a file will be opend in nano wit a bunch of text that is made passif by placing # in front of it.
read trough the file and find de lines where it says;

#example static ip configuration.

In the lines that follow this line you can setup an ip-address router adres and DNS settings.
remove the # in front of the line you want to activate en fill in the information needed. If you'r not sure what addresses to use close nano ( ctrl+x) and run the ifconfig now you can see which interface u are using ( wlan0 or eth0) and what the current lan ip, router ip and DNS are. for your lan ip you have to choose an address that is outside of the scope of your routers DHCP. you can find this in your router settings. if you find this difficult you could rund the arp command to see what addresses are given out and take one that is below that. for example most of the time your arp table wil state your router at xxx.xxx.xxx.1 and other devices at xxx.xxx.xxx.50 to xxx.xxx.xxx.150 so if you would give your pi the ip address xxx.xxx.xxx.25 there most likely will never be a device given this address by your DHCP server ( aka your router) and so you will prevent an IP conflict in the future.

now whit this information completed exit and save the file ( ctrl+x ) en reboot your pi. you will now be able to ssh to it by using ssh <user>@xxx.xxx.xxx.25 of course the x's mark other numbers that will be specific to your network setup.

Use you phone;

Now you can always find your pi at the same address you can take advantage of that by using your phone to control mpd. in most Appstore's you can find a program called MPD remote or something similar. take one of your taste. install in on your phone and in server settings connect to the IP you just set for your PI. now you can add streams, start skip and pause them all from your phone as long as your phone and the pi are on the same network.

I hope you enjoy you simple radio.

Audio Challenge 2020

Participated in the
Audio Challenge 2020