Pages

2013/04/20

Setting up a Raspberry Pi to serve as development computer and media centre

Connection diagram: router connects by cable to main computer, network drive, and pi; pi connects to TV via HDMI; phones and laptops connect via wifi
Connection diagram
I wanted to use my Raspberry Pi for coding projects; that's what the Pi was designed for, and it allows to unload that from the main computer. A clean separation of concerns.

But then I also wanted to use it as a media centre, keeping the media on a network drive. What I don't want is to rearrange it every time I switch from one configuration to the other, but just turn it off, swap the SD card, and turn it on again.

This is what I came up with.

First things first: if I wanted to use the Pi as a media centre it should connect to the TV via HDMI. The TV is close to the router, so no need for a wifi dongle, I can wire the Pi to the router; with this I already have access to the network drive. So far so good.

Let's try it out. With this setup, I installed the latest raspbmc, XBMC built on top of raspbian, on the Pi, using a USB keyboard during the configuration. If I want, I can even divert audio output to the jack and feed it to the hi-fi set. Once everything was ready I switched to controlling it with my phone through the network with the Yatse remote app.

A few further tweaks: I enabled uPnP in both XBMC and the network drive. With this and a suitable app I can use the Pi and the network drive as servers and the Pi and the phone itself as clients, that is, I can stream from both servers to either the Pi or my phone. This can get convoluted: I once wanted to watch a video I had just added to the network drive on the phone; but the server on the network drive is relatively slow to update so I could not get it there. I ended using the Pi as the server, as it pulls media from the network drive via SMB shares, which update much faster.

At this point I considered that the media centre part of the challenge was done. Now I had to manage to switch to a raspbian SD card and, without tinkering around, use the Pi for development.

The naive approach, since the Pi was already connected to the TV was to use that as the screen, and add a wireless mouse and keyboard set to code from the couch... not a really good idea. It's fine to have the big TV screen to showcase the results, but it is hardly the best option for the development part. If only I could do that from the comfort of my computer screen and chair...

Well, that makes it easy, doesn't it? I enabled ssh and vnc on the Pi. Since the Pi is configured to output at full HD and my monitor has that as native resolution, when I vnc into it is just as having the keyboard, mouse, and screen plugged directly into the Pi.

As an additional perk, since the main computer is the only thing visible from outside the LAN (via ssh, including tunneled vnc), I can also access the Pi from anywhere. Luckily there is a whoami command to avoid getting lost.

No comments:

Post a Comment