Installing mopidy Raspberry pi 2

installing mopidy raspberry pi 2

Today i’m going installing mopidy on a raspberry pi 2.
I just installed a fresh copy of Jessie on a 16gb sd card, and expanded the filesystem.
If you haven’t expanded the filesystem yet, run this command:

sudo raspi-config

Next we’re going to add the GPG key

wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -

Add the repository

sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list

Update the repositories list, and install mopidy

sudo apt-get update
sudo apt-get install mopidy

I’m going to install spotify as well

apt-get install mopidy-spotify

I want mopidy to run as a service, since i’m going to build it in a old radio.
sudo dpkg-reconfigure mopidy

A screen will pop-up, answer “Yes”

Next install the modules you’d like. I’m installing:
–  Tunein
–  Youtube
–  Gpio extension for controlling buttons
–  Mopify webinterface

First the command below to install the requirements for Youtube,Tunein and PIP to install the modules
sudo apt-get install gstreamer1.0-plugins-bad python-pip

Next install the modules.
sudo pip install Mopidy-Mopify Mopidy-Spotmop Mopidy-TtsGpio Mopidy-YouTube Mopidy-TuneIn

Now we’re going to configure the modules in the /etc/mopidy/mopidy.conf file.
vi /etc/mopidy/mopidy.conf

My config looks like this:

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[local]
data_dir = /var/lib/mopidy/local
media_dir = /var/lib/mopidy/media

[m3u]
playlists_dir = /var/lib/mopidy/playlists

[mpd]
enabled = true
hostname = 127.0.0.1
port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist = listall,listallinfo
default_playlist_scheme = m3u

[http]
enabled = true
hostname = 0.0.0.0
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname


username: [username] 
password: *****

[mopify]
enabled = true 
debug = false

[spotmod]
enabled = true

[tunein]
timeout = 5000

[ttsgpio]
pin_button_main = 17
pin_button_next = 23
pin_button_previous = 22
pin_button_vol_up = 24
pin_button_vol_down = 25
pin_play_led = 18

Test it out

Now grab a browser and go to your raspberry’s [IP]:6680. My case: 192.168.1.239:6680

If done correct you should see a landing page:

Click on a webclient and it should load the webclient you installed.
Now it’s time to configure the speakers and all other stuff you might like to add to your raspberry E.g. buttons.

Setting your soundcard

If you’ve got a USB sound card like i have, you need to specify to Alsamixer that the USB card is the default card.
First you need to locate what soundcard is assigned:

cat /proc/asound/cards

My output:

root@raspberrypi:/home/pi# cat /proc/asound/cards
 0 [ALSA           ]: bcm2835 - bcm2835 ALSA
                      bcm2835 ALSA
 1 [Device         ]: USB-Audio - USB PnP Sound Device
                      USB PnP Sound Device at usb-3f980000.usb-1.3, full speed

As you can see, my USB sound card is device one.
Now create your asound.conf

vi /etc/asound.conf

If your soundcard is also 1, you can copy paste the following code into the file:

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}

now restart the pi.

Coming soon

Create a Nginx config that allows you to go directly to the webclient of choice instead of a port number.
E.g. 192.168.1.239 in your browser redirects you to spotmop without adding port numbers.

I’ll add another tutorial about adding speakers and buttons later on.

4 Comments

  1. DJ 2 November 2016 at 13:19

    Would be cool if you added the next part to this soon:)

    1. pjeursen 4 November 2016 at 15:14

      Will do this as soon as possible! Kinda had it busy with work lately.
      Hoping next weekend i’ll have the time to post the second part 🙂

  2. swaton 9 February 2017 at 11:58

    hey man when ever i do the command “vi /etc/mopidy/mopidy.conf” it returns a error ” access denied”. I have tried running the command with sudo but still the same error . please help

    1. pjeursen 23 February 2017 at 09:56

      Hi,

      Sorry for my late reply i kinda got caught up in work. Could you list the directory right?
      ls -al /etc/mopidy/mopidy.conf

      It’s weird that even sudo can’t access the file. This should always work!

Leave a comment

Your email address will not be published. Required fields are marked *