Raspberry Pi – Location Aware Media Server Project

Recently I purchased a Raspberry Pi and have been considering what I should do with it.

1 consideration has been to create a location aware media server.  What do I mean by location aware media server? Well most media servers will allow you to create playlists and output to whatever speakers are attached. With my project however I plan on making the system know which room you are in and to then output to speakers in that specific room, if you move room the music will follow.

Prior to jumping into such a project there are a few things that I have to work out as well as to decide the full functionality of the system.

Features And hurdles

Let’s take a look at the desired features in detail. Within each section I will be linking to a page that I will keep updated that will show my current design process. For those sections with no links, I have simply not started that process as of yet.


Pairing Design Flow

The system will consist of 1 main server. Each room will contain a further Raspberry Pi acting as a location beacon.

The location beacons need to be easily paired without the need to hook up to a PC or interfered with in any other way such as ssh.

1 possibility is to have a wifi access point using a default password however this is potentially insecure. Another possibility would be for the beacons to connect to the server using Bluetooth. The Bluetooth connection would be to carry out an initial handshake and to pass any required credentials onto the beacon. For example this would pass on the wifi details to allow the beacon to connect. During the handshake the server could register the beacon and provide API credentials that are specifically for the beacon. To help mitigate any security issues (as would still need a standard access pin) a button could be put onto both devices (using gpio?) enabling a Bluetooth connection and setting the pin to a predictable number. Provided the server is not also acting as a beacon I could then ensure that Bluetooth is disabled unless the button has been pressed in the last 2 minutes.

The beacons normal connection type after the handshake would be wifi. They would connect to an access point on the server. This would ensure that the beacons are isolated from the normal home network and only the server is visible to the network. The server would hand out IP’s on a different subnet from the main network.

I do need to double check that my understanding of Bluetooth is correct, for example is the connection secure enough to transmit the wifi details. I also need to double check that the handshake could be achieved in this manner.

Location Awareness

For the Raspberry Pi’s to have an idea of where you are you of course need to have something in your possession that the Raspberry Pi can query. Most of us carry around a device that can be used, our smartphones!

I have pretty much ruled out wifi as a method for detecting where you are as this would require each Raspberry Pi to be setup as an access point and this would saturate the wireless band.

This leaves 2 potentials that I can think of, the first is NFC and the second is Bluetooth. NFC in its normal sense would be too restrictive so I have decided to look into Bluetooth. I have already looked into the feasibility of this and have found that as long as I know the Btaddr for the phone I can ping it and ascertain the RSSI (essentially an indicator giving a distance between the devices). To make this work each beach would have to ping the identifying device (the phone) and grab the RSSI. The beacon would then transmit the RSSI to the server (using an API?). The server would check which beacon reported the lowest RSSI and feed the music to this device. Polling from beacons would happen maybe once every 10 seconds but this may need tweaking.

There are a couple of considerations that I would have to take into account, for example how much will this drain the battery of the identifying device? how would I handle times when a beacon fails to report the RSSI? How will a beacon know it is want to be scanning for devices (after all no point scanning if music isn’t playing)?

Streaming The Music

There are a couple of things I need to decide with streaming the music. For example should the speakers pair with the server or the beacons? Do I need to use a DAC? Can I use off the shelf media centre software or do I need to write this myself? Can such software stream from a NAS drive?

As you can see there are more questions than answers here but to be honest there is plenty to be getting on with prior to reaching is stage.

Control Of The System

I wish to avoid creating a mobile phone app (at least for now) therefore I need to create a method for controlling the system (registering devices, user management, creating zones, basic network set up such as IP range to use etc), dependent upon if I use an off the shelf media centre software I may also need to create a system to allow me to create playlists, start and stop music etc as well.

The bulk of this can be created as a webpage of course. I have already been playing with lighttpd with PHP and Python support. I am more adept with PHP than Python therefore the bulk of the pages would be created using this and some of the more specific tasks would use Ajax to query anything that needs to be done in Python.


As you can see there is a lot of work involved and a lot of learning on my part coming up however I am sure that this is achievable.

Any suggestions or ideas?

Be sure to let me know.

Tell us your thoughts