Internet of things is about connecting connecting th things around you in a meaningful way. Last few posts, I showed how to connect and monitor a few sensors inside the home using raspberry pi. Now it's time for a little entertainment. After the basics in home, I believe it's going to be our entertainment systems coming to online. In this post, I'll explore the idea of an internet connected music player with raspberry pi.


Enter Mopidy

Mopidy is much more than a normal music player. I makes your music device accessible from web and also enables it to stream content from web like spotify, Google Play Music etc., The best part - you can access your music player from your smartphone or tab or from PC. This is how it's going to work - Mopidy is going to run on your raspberry pi (I'm using Pi3). It will be working as a daemon(background process) in your pi. And your Pi must be connected to a network. Noe you can access the Mopidy UI using any of you devices - either phone, tab or another PC. It's basically like bluetooth streaming experience except that it won't drain you battery But the catch is your music files should be either available in your rPi or should be played from cloud.


Hardware Setup

The hardware setup is really simply. You have to connect a speaker to your 3.5mm jack. I'm using an USB powered speaker, which I power from the Pi.



Software Installation

Although there is an official apt repository method for installing Mopidy on Pi, I will be following the pip method. The version in apt repo is seems to be old - 0.19, while the one using pip is new - 2.x

First thing to do is to install all the gstreamer dependencies in Pi. Use the following command to install the dependencies:

sudo apt-get install python-gst-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-tools gir1.2-gstreamer-1.0 gir1.2-gst-plugins-base-1.0

Now we can go on to install Modpiy using pip. Use the following command to install:

sudo pip install Mopidy

This will install Mopidy music server in your Pi. Before using it, we have to configure Mopidy to be able to access from other devices. This will be particularly helpful if you are running Pi headless. Other thing is, once you configure these access you will be able to control music player from your mobile phone or other PC also. To edit the configuration:

nano ~/.config/mopidy/mopidy.conf

Basic structure of the file is going to be section in square braces ( eg [core] ) and options under it.

First to be able to access mopidy from outside, you need to enable MPD and HTTP section. Navigate to the sections and modify them as given below:

enabled = true 
hostname =
port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist =
default_playlist_scheme = m3u

enabled = true 
hostname =
port = 6680
static_dir =   
zeroconf = Mopidy HTTP server on $hostname

Now you will be able to access your Mopidy from any devices. Next you have to install clients to be able to access them. First we'll configure a webclient so that we can access Mopidy from PC/tablet/phone. You can get a non-exhaustive list of webclients for mopidy from . For this project, I chose to use 'Musicbox_webclient'. To install it, just enter:

sudo pip install Mopidy-MusicBox-Webclient

Now you will be able to access your Mopidy from any of the web clients from any devices.

Now you can go to http://<Pi's IP>:6680 and you will see a page like this:

Screen Shot 2016-08-24 at 10.39.35 pm.png

This page should show all the available webclients for Mopidy. Here I have only one. You can click on it and will be taken to a page like this:

Screen Shot 2016-08-24 at 10.45.24 pm.png

From this point, it will behave as a normal music player. You will be able to browse you local music files and play them using this UI.


Let's Party

Here is a small demo of how I'm using Mopidy using MusicBox client from my android mobile. It is the webclient itself, but I created a shortcut to my home screen so that I can open it easily.


Happy Hacking,



<< Prev | Index | Next >>