sam9s Raspberry Pi Project! powered by LMS and Squeezelite

sam9s

The High 5 Flyer
Hi Friends,

After a long time I have ventured in another DIY project and I am very excited to share the same with you all again. Before I go in to the details of the project. let me share the reason why I went for what I am about to share. I was out on a picnic with my family and inlaws when at the location we were all enjoying, we wanted to have some music running at the background (my car stereo in this case). I had few songs on my mobile and my Brother in law also had few punjabi songs on his mobile, but I seriously felt the need to have my entire collection. Usually I connect to my NAS Audio Station from my mobile to have the access, but this location had poor 3G signals and I was not able to connect to my NAS.

Plus every time we wanted to skip or change the song, I had to walk down to my car and access my mobile phone. That was quite irritating. (Same limitation would also have been there with an MP3 player). This made me think I should have a media player or something that can play songs from the local storage, and I should be able to control it from my mobile wirelessly. This brought me to do some googling and I came up with solution using Raspberry Pi. Converting a Rpi as a music server and a player was not something difficult, but making it accessible via mobile was.(which I will discuses later in this post) I did experiment with few solution like ...

1. Subsonic click to see excellent guide to install subsonic on rpi and access it via browser.

2. Pi MusicBox Another way is via installing Pi MusicBox based on Mopidy which is an MPD and HTTP server and again accessing the interface via webbrowser.

3. Logitech Media Server ...... Though you can install LMS and Squeezelite independently but the best approach is to find a complete image that installs and configures almost everything automatically. There are lot floating around on the net but the best one I found is called Squeezeplug, download the NOOB (SPMAX2PLAY_RPI_NOOBS_212.zip) zip file extract it on the SD card and boot your Rpi from it. Go to http://max2play and configure your server and player accordingly. (instructions are there on the webpage itself)

In all the above 3 approaches even though I was able to make my Rpi act as a server and a player and play music from it, the problem was that the Rpi had to be connected to my Home LAN network in order to work. So I could not actually take the Rpi out in open beyond my home network and use it. So I went again googling to try to find a way if I can use Rpi as a Music Server and a player even outside my home LAN

.......

Please Welcome .... RPI-Wireless-Hotspot ...... where you can make your Rpi act as a stand alone access point hotspot, that can not only act as an independent access point but also a hotspot that run its own DHCP, broadcasting its own network that any client(PC, laptop, mobile) can connect to. Now if I can run LMS and Squeezyplayer on it and also make it a standalone hotspot I can connect my mobile to it and control the music. This way I can carry Rpi any where since it would be controlled via my mobile and play my music from it.

This is what I will share in this thread of how I was able to successfully install LMS, Squeezlite and make it a hotspot that will broadcast an ad-hoc network that any mobile, pc, laptop can connect to. There were couple of guides that I followed to achieve this. Full credit goes to the developers and programmers that made this possible. All I will do in this thread is to compile all the knowledge/write ups in one thread so that any one who is interested can just read from here instead of all the multiple guides floating on Net.

So here we go ......

What hardware you will need ..........

1. Raspberry Pi B+ : Should work on B as well, and is not tested on Rapi 2.
2. 8 GB class 10 preferred Micro SDHC card
3. USB DAC or Soundcard : Most USB DACs and Soundcards are supported, as cheap as 500 bucks to the more expensive ones. I used a sound blaster sound card with a C-Media chipset.
4. A PC connected to your home LAN
5. Wifi dongle (this is important as not all wifi dongle support wifi hotspot via Rpi.) Edimax dongle though is said to support I had different problems with it. what worked for me was Comfast® CF-WU720N dongle. You can try other comfast adapers as well but this is what worked for me so I have shared the link for the same.
5. 16GB or more pendrive to store the songs.


Prepare the MicroSD Card.

Everything is installed on Rpi linux distro called Raspbian. You can download the image file from HERE. To write the image on the SD card download Win32image Disk Imager. and install it on your PC.Insert the MicroSD card and write the Raspbian image to the card. Detailed instructions
HERE

Download Putty from HERE and install in to your PC. Putty is an SSH Terminal tool that can help you to log in to Rpi running Raspbian from a remote machine, this
way you do not need to be physically connected to the Rpi via keyboarde and mouse and your device can run in complete headless mode.

We would use putty extensively to run all linux command line instructions.

Also download filezilla, this would be used to transfer the LMS dep installation file from your PC to Rpi. Install it on your PC So the journey begines ...... it would be a long post as usual with lots of linux commands, half of which I could not understand, :D, but everything worked at the end. If you are not comfortable with linux commands then probably this tutorial is not for you ....

Step 1 : Connect everything to your Rpi. Wifi dongle, pendrive with songs, lan cable connected to your home network, (which is having internet access) HDMI to your disply, USB sound card connected to your speakers, and a keyboard (you wont require a mouse). Push in the Micro SD card in your rpi and plug in the power (Any 5V, 2A USB power adapter will work)

Step 2 : The very first screen you will see is the Raspberry Pi Configuration Tool (aka Raspi-config). Refer the snap below. A detailed explanation of every entry the config tool has can be learnt
HERE

symou8.jpg


Step 3 : For this tut purpose we would only do a couple of things.

1. Expand File system
2. Go to "Advance Options"
3. Change the Hostname to your choice
4. Go to SSH and enable it (this would allow us to connect to Rpi via Putty
5. UPdate : This would update the libraries and would restart the Rpi

Step 4 : Once Rpi-config has been done the device would boot to login prompt. The default credentials are

User ID : pi
Passwpord : raspberry

Step 5 : This would bring us to the command prompt. Type ifconfig at the command prompt, which would give you the internal ip address of your pi that your router has provided. Now you can disconnect the HDMI and keyboard as we would connect and access rpi's terminal window from your PC using putty

Step 6 : Open putty on your PC (Make sure your PC and Rpi are connected to the same LAN) and put the internal ip of your Rpi and click on open. You will recieve a pop up window aout the security key just click on yes and you will be presented with the login prompt. Use the same credentials to log in to Rpi's terminal window

Step 7 : We will now start installing the applications and softwares in the below hierarchy.

1. Squeezylite player
2. Logitech Media Server
3. Create Hot spot
4. Restart

First, we will have to get rid of a default installed package “wolfram-engine” (mathkernel). This package will otherwise give problems when adding the daemon script for starting at startup. This package contains a faulty daemon script, which will prevent adding another daemon.We don’t need it for squeezelite and removing it will free aprox. 430 Mb of disk space, plus it will make the update process faster.

Step 8 : On the command line in putty execute the below command .....

sudo apt-get remove -y wolfram-engine

Step 9 : Installing Squeezelite.First set the sound level by execution the below command

sudo alsamixer

Use the F6 key to select the right soundcard (I am using an USB soundcard), and then set the volume using the up arrow keys.

Step 10: Install some libs:

sudo apt-get install -y libflac-dev libfaad2 libmad0

Step 11 : Create a squeezelite “work” directory and download squeezelite:

mkdir squeezelite
cd squeezelite
wget http://squeezelite-ownloads.googlecode.com/git/squeezelite-armv6hf


Step 12 : Move it to the usr directory, and make it executable:

sudo mv squeezelite-armv6hf /usr/bin

cd /usr/bin

sudo chmod a+x squeezelite-armv6hf


Because I use a USB soundcard, so I will have to tell squeezelite which sound device to use. First list all the devices by executing the below command:

sudo /usr/bin/squeezelite-armv6hf -l

The result:

Output devices:
null - Discard all samples (playback) or generate ze

ro samples (capture)
default:CARD=ALSA - bcm2835 ALSA, bcm2835 ALSA - Default Audio De

vice
sysdefault:CARD=ALSA - bcm2835 ALSA, bcm2835 ALSA - Default Audio De

vice
default:CARD=S2 - Sound Blaster Play! 2, USB Audio - Default Au

dio Device
sysdefault:CARD=S2 - Sound Blaster Play! 2, USB Audio - Default Au

dio Device
front:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - Front spea

kers
surround40:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - 4.0 Surrou

nd output to Front and Rear speakers
surround41:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - 4.1 Surrou

nd output to Front, Rear and Subwoofer speakers
surround50:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - 5.0 Surrou

nd output to Front, Center and Rear speakers
surround51:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - 5.1 Surrou

nd output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - 7.1 Surrou

nd output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=S2,DEV=0 - Sound Blaster Play! 2, USB Audio - IEC958 (S/

PDIF) Digital Audio Output



The second and third device both will direct the sound to the Raspberry’s default audio output. The quality of that output is not so good, so I used a USB soundcard. My USB soundcard are the rest of the sound devices, recognizable by “Sound Blaster Play!”. I wanted to use only the front speakers, so I had to tell squeezelite to use “front:CARD=S2,DEV=0".
Copy "front:CARD=S2,DEV=0" in notepad for later use

Step 13 : Starting Squeezelite on startup : To install and start squeezelite at boot up we would install a daemon start script made by "Gerrelt" called "squeezelite_settings.sh" (I will share the source link later .....

Step 14 : For this execute the below commands ..

cd /home/pi/squeezelite
sudo wget http://www.gerrelt.nl/RaspberryPi/squeezelite_settings.sh
sudo mv squeezelite_settings.sh /usr/local/bin
sudo chmod a+x /usr/local/bin/squeezelite_settings.sh

sudo wget http://www.gerrelt.nl/RaspberryPi/squeezelitehf.sh
sudo mv squeezelitehf.sh /etc/init.d/squeezelite

cd /etc/init.d
sudo chmod a+x squeezelite
sudo update-rc.d squeezelite defaults


Step 15 : You will have to set the soundcard in the settings script. Open the settings script with nano:

sudo nano /usr/local/bin/squeezelite_settings.sh

And search for this line:

SL_SOUNDCARD="sysdefault:CARD=ALSA"

Change “sysdefault:CARD=ALSA” to the one you selected earlier (in my case I changed it to “front:CARD=S2,DEV=0).

If you want to use the Raspberry’s default audio output, you don’t have to change it.

Step 16 : In the same file squeezelite_settings.sh change

#SB_SERVER_IP="192.168.0.100" to SB_SERVER_IP="127.0.0.1"

Basically remove the "#" and change the ip to 127.0.0.1

When this is done press Ctrl-O to save and Ctrl-x to exit

********** Squeezelite is installed, now we will install Logitech Media Server ***********

Step 17 : Download LMS from

HEREto your PC.

Step 18 : Now we will use filezilla (that you downloaded and installed in the earlier steps),to copy file from your PC to Rpi. Open filezilla goto File=>Site manager=>new site. Put the ip for Rpi and credentials and click on connect. Left side is your PC and right side is Rpi connected. Navigate to root=>home=>pi on the right side and navigate to the location where

you have downloaded the LMS installer on your PC. Then copy the file LogitechMediaServer_v7.8.0 or just drag and drop the file from left pannel to right where it will be copied to your Rpi root drive.

2renrte.jpg


358atxt.jpg


Step 19 : Go to terminal window (putty) and run ls -l command and you should see the LogitechMediaServer_v7.8.0 file there copied.

2h6vgxv.jpg


Step 20 : Install some more libraries by executing the below command

sudo apt-get install libjpeg8 libpng12-0 libgif4 libexif12 libswscale2 libavcodec53

Step 21 : sudo dpkg -i logitechmediaserver_7.7.2_all.deb ::: this will extract and install LMS on rpi

Step 22 : sudo service logitechmediaserver stop ::: Stop LMS service

Step 23 : wget http://allthingspi.webspace.virginmedia.com/files/lms-rpi-raspbian.tar.gz

tar -zxvf lms-rpi-raspbian.tar.gz


Step 24 : sudo patch /usr/share/perl5/Slim/bootstrap.pm lms-rpi-bootstrap.patch ::::: Patch the bootstrap perl module

Step 35 : Execute the below commands one by one ...

sudo mv arm-linux-gnueabihf-thread-multi-64int /usr/share/squeezeboxserver/CPAN/arch/5.14/
sudo mv libmediascan.so.0.0.0 libfaad.so.2.0.0 /usr/local/lib
sudo mv /usr/share/squeezeboxserver/Bin/arm-linux/faad /usr/share/squeezeboxserver/Bin/arm-linux/faad.old
sudo mv faad /usr/share/squeezeboxserver/Bin/arm-linux
sudo ln -s /usr/local/lib/libmediascan.so.0.0.0 /usr/local/lib/libmediascan.so
sudo ln -s /usr/local/lib/libmediascan.so.0.0.0 /usr/local/lib/libmediascan.so.0
sudo ln -s /usr/local/lib/libfaad.so.2.0.0 /usr/local/lib/libfaad.so
sudo ln -s /usr/local/lib/libfaad.so.2.0.0 /usr/local/lib/libfaad.so.2
sudo ldconfig


If you get some error in the above commands just ignore it.


Step 36 : sudo chown -R squeezeboxserver:nogroup /usr/share/squeezeboxserver/ :::::: Fix Permissions

Step 37 : sudo service logitechmediaserver start ::::: Start LMS by this command.

********** This completes implementation of LMS ***********

Step 38 : Now we have to mount the Pen Drive to Rpi so that LMS can see it and scan all the songs

Step 39 : First create a usb directory under /mnt:

cd /mnt
sudo mkdir usbdrive


Step 40 : execute the below command to see what all drives are connected

ls -l /dev/disk/by-uuid/

This is my output

pi@squeezybbq ~ $ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 15 Jun 28 21:58 3d81d9e2-7d1b-4015-8c2c-29ec0875f762 -> ../../mmcblk0p2
lrwxrwxrwx 1 root root 10 Jun 28 21:58 62AA-723B -> ../../sda1
lrwxrwxrwx 1 root root 15 Jun 28 21:58 787C-2FD4 -> ../../mmcblk0p1
pi@squeezybbq ~ $


Search for the line that ends with “sda1“, that’s the USB stick. Now copy the hex number thats between the time (in my

case: 21:58) and the arrow (“ -> “). In my case its 62AA-723B

Step 41 : Now edit this file:

sudo nano /etc/fstab

And add this line to the end of it

UUID=long_hex_number_from_previous_command /mnt/usbdrive vfat defaults 0 2

So in my case it would look like

UUID=62AA-723B /mnt/usbdrive vfat defaults 0 2

*********This completed USB mounting***********

Step 42 : The last part is to create Rpi as a Hotspot so that it can broadcast its own network which we can connect to via mobile.

WARNING :::: Lots n lots of Linux commands. I will just provide you the link of the tut that I followed, trust me you just need to execute each and every line just like its there in the tut and all will work just fine

the link to the tut is :::::::: RPI-Wireless-Hotspot - eLinux.org

Start from under Instructions

Once last line of code is executed which is sudo update-rc.d udhcpd enable restart Rpi

Step 43 : Final Step : type shutdown -h now and let Rpi boot and wait for couple of minutes.

If all works as it should, you shoud see Rpi broadcasting the SSID that you would have defined in the tut above.connect to it provide the password (that you again defined in the tut) and you should be connected to Rpis network.
Connect your PC as well to Rpi's network. Open the browser and go to http://<your Rpi ip>>:9000 this would open the LMS page .... just click skip where LMS page wants you to log in. Next page will show you the file manager tree of your Rpi on the left hand pannel. Just click on the + sign against /mnt and you should see your pen drive mounted there. select the songs folder and click on next.

LMS main page will load. On the top left corner click on the drop down menu and choose the player (which would be the hostname of Rpi that you defined initially. Select the player, navigate to any song from the left hand side tree and click on PLAY. you should hear the song from your speakers.(assuming you have connected the spks to the USB sound card)

vqjqq0.jpg


******** How to connect the phone ***********

Providing instruction for Android, for iOS I have no idea sorry, you have to search the compatible application of your own

Step 1 : Download 2 applications from Google Play

1. Squeezer

Start it, and go to “settings” in the settings menu. Now choose “Server Address“, and press the “Scan” button. It should now detect server “192.168.42.1“. Choose OK, and go back to squeezer.Now go to “Players” in the settings menu. It should show your player name, choose that one. Now press squeezers’s “Home” button (top left corner) and choose something under “My Music“, it should start playing.

2. ServerAssistant

Server assistance once connected will provide you two simple activities ..... Status and Shutdown thats all you need, clicking on status will provide you the same for your Rpi and shutdown will shut down your Rpi clean and nicely.

So that ends the tut, if anyone is willing to do this project as a weekend time its good. Other wise as well, it solves one purpose nicely to be able to carry your media anywhere and controll it with your phone so that you done have to manually go to the polayer to change/skip the song.

As I said full credit goes to the developers who developed the packages, all the link are provided below taht I followed to prepare this guide ....


TUTORIAL: Installing Squeezelite player on Raspbian | Squeezing a Raspberry Pi

All Things Pi

RPI-Wireless-Hotspot - eLinux.org

Any comments are welcomed .

Regards
Sammy
 

Vyom

The Power of x480
Staff member
Admin
Bumping this thread since I bought a Raspberry Pi 2, and it was delivered today at my home.
This guide you created might help me do something on it. :D
 
Top Bottom