GIS • Mapping • Raspberry Pi • Photography

Raspberry Pi

I recently upgraded my Raspberry Pi 256mb from Raspbmc to the OSMC Release Candidate, there were a few hiccups along the way so thought I’d document them here incase anyone else runs into the same issues.

The OSMC RC install went fairly smoothly. I say fairly because it took a few attempts and some digging around before I found out I needed to add gpu_mem=32 to boot.config to prevent the install from hanging on my Raspberry Pi B 256mb.

Once OSMC was installed I then installed Hyperion in the usual way: install prerequisites, download installer, run installer:

As cool as a Hyperion/boblight/ambilight set up is, sometimes you want to disable the LEDs for whatever reason. You could SSH into your Pi and stop the Hyperion service or just flick the power switch on the LED power supply, but if you’re lazy like me, then you’ll probably want an even easier way to perform this task!

How about a single button press on your remote control to toggle the Hyperion service?

It’s actually pretty simple, first create a bash script which checks if the service is running. If it is, it disables it, if not it will enable it.

Hyperion is another Ambilight clone for the Raspberry Pi.
It essentially works in the same way as the boblight-dispmanx solution in that it uses dispmanx to capture the screen contents, which are then converted to colours and pushed to your LEDs.

The real advantage of Hyperion is it’s very low CPU usage, typically less than 2% for 50 LEDs.
So this really helps you to squeeze the most performance out of your Raspberry Pi. e.g playing a 1080p bluray rip with DTS audio while running LEDs is totally possible – with CPU to spare!

There are many nifty features like black border detection which works with letterbox and 4:3 videos, an Android app to set static colours and a really cool config tool, Hypercon, to help you configure your LEDs. In the above image the ‘light’ is generated dynamically depending on image you choose to display on the ‘TV’. Try it, its really cool.

It supports WS2801, LDP6803, LPD8806, Adalight, and Sedu based LEDs and can even act as a boblight server. So if you have other boblight devices on your network (e.g a cable/satellite TV box) they will still work with your Pi running Hyperion.

I’ve been running this now for a month or so and I really like it.

It’s easy to install, just download an installation script and run. Then create your config file – in much the same way you do with boblight. If you are switching from boblight, simply disable boblight from Raspbmc settings and install Hyperion – no changes to the hardware setup are required.

Many thanks to the developers poljvd and tvdzwan, they have done a really great job and continue to add new features and fixes at a very impressive rate! You can contact those guys and suggest features over at the Raspbmc forum: http://forum.stmlabs.com/showthread.php?tid=11053

The September Raspbmc update has been pushed out and unfortunately it has broken boblight support.
This release introduced a new 3.10 Linux kernel which has changed the way SPI is working.
Right now there is no fix, so I suggest if you haven’t upgraded yet, don’t!

If you’ve already upgraded then you’ll just have to sit tight until the kernel gets fixed/modified.

If you have auto updates enabled and you don’t want to update, then pull out the ethernet cable, boot into Raspbmc,, disable auto updates and then reboot with the ethernet plugged in.

* Ok, maybe not the ultimate, but you’d find it difficult to beat for the price :p

Overview

A while back a friend of mine asked how he could go about recreating my setup from scratch, i.e starting with no hardware at all. I sent him a lengthy email which I have expanded on here as I think it would be useful for others.So, in this guide I will describe what to buy and how to set up an awesome, boblight enabled, fully automated, low-cost, media centre. This particular setup is comprised of a Raspberry Pi running RaspBMC (XBMC) with a 50 WS2801 LED boblight setup, a 3TB ZyXel NSA-310 NAS drive running CouchPotato, SickBeard, Transmission, MySQL and a web server.

Part 1. Hardware

1.1 Raspberry Pi & accessories

1.1.1 Raspberry Pi
The Raspberry Pi comes in 2 flavours, raspberry and raspberry. It also comes in 2 models, A (256mb RAM and 1 USB port – US$25) and B (512mb RAM, 2 USB ports and an Ethernet port – $35). Besides those differences, the boards are pretty much the same so you could theoretically buy either, but you will get a better experience using the B model with the extra ports and RAM.

1.1.3 USB Stick
All operating systems on the Pi are usually installed on an SD card. However, to improve the performance of RaspBMC it is advised to run it from a USB stick connected to the Pi. Any decent USB stick will probably be faster than most SD cards, but to ensure the best performance, a USB 3 stick is recommended. Raspberry Pi doesn’t actually support full USB 3 speeds, but generally, USB 3 sticks will perform better than USB 2 sticks, even on USB 2 devices. Capacity of the stick is not that important as you will be storing your media on the NAS. 1GB will be plenty – if you can even buy such a thing these days. Please note, even if you install to USB, you will still need an SD card – this is where the Pi reads the firmware from during the boot process.

1.2 NAS Drives and Hard Drives

1.2.1 NAS Drives
For those wondering, NAS = Network Attached Storage, i.e an external hard drive that connects to your network, rather than to a single PC/laptop via USB. You hook this thing up to your modem/router, transfer all your media to it, hide it in a cupboard/under the stairs and forget about it. You can then access all your media from pretty much any network connected device, be it a PC, laptop, tablet, mobile phone or of course a Raspberry Pi. With some additional set up, you can also connect to the NAS via the internet from a remote connection, e.g a friends house. Where the NAS drive really shines is the fact it’s basically an always on, mini PC which you can set up to run various services and act as the central hub of your media centre; more on that later.

As with most electronics these days, there’s a wide range of NAS drives available. The first choice you’ll need to make is 1 bay or 2. If you opt for 1 bay/hard drive then you’ll have no redundancy, if the drive fails you’ll lose all your media if you don’t have a backup, but on the plus side the option is a lot cheaper, easier to set up and cheaper to run. The advantage of having a 2 bay NAS drive is that you can run a RAID configuration:

There are actually several types of RAID, but the important ones, as per the image above, are:

RAID 1 – Mirroring. i.e 2 x 3TB drives will become one 3TB drive. All data is written to both disks, meaning if one dies, you still have a copy on the other.

RAID 0 – This will merge the drives into one big drive. i.e 2 x 3TB drives will become one 6TB drive. All data will be split across both drives and only stored once.

That’s RAID in very simple terms, if you’re considering this route, it’s best to do some research and read about the differences between redundancy and backup. For example, in the situations above, running RAID 0 is essentially doubling your chance of losing 6TB of data and doesn’t provide any backup! So ideally you’d want all 6TB of that data backed up somewhere else… expensive! Running RAID 1 in the example above means you have 2 drives constantly running, using power and sat inside one device. While you have some data redundancy there, what happens if the device goes pop taking both your drives with it? Or you accidentally delete an important file on your mirrored setup? You have no true backup with this set up, you’ll still need another device to provide the backup. Ok, that’s painting RAID in a bad light, there are of course advantages to RAID, improved speeds for example (which you could argue isn’t that important in a media centre), plus the other RAID setups address the issues mentioned above.

Anyway, this led me to go the 1-bay route, which is more in line with the low-cost, low-power media centre theme. My backup comes in the form of my old unused PC with a 1.5TB of JBOD disk space. Currently I manually backup all new files from the NAS to the PC. But in time I’ll create a script to automatically wake the PC via WOL and run an incremental backup every month or so. Once I start to approach 1.5TB of data, I plan to replace the JBOD with a single 3TB drive.

The next choice is what brand/model of NAS to buy. I went with the ZyXel NSA-310ZyXel NSA-310ZyXel NSA-310ZyXel NSA-310ZyXel NSA-310ZyXel NSA-310ZyXel NSA-310 which, at the time, seemed to be the best value in terms of cost (£37) vs performance and features, by quite a margin actually.
The main draw of the ZyXel-310 and the 2-bay Zyxel NSA-320/25 models, is that it already has a pretty decent feature set. As standard it can run a webserver, a Transmission torrent client, a MySQL database (very useful for XBMC), Samba/NFS/FTP servers, WordPress, several different media servers as well as the ability to install many other packages. One such package is FFP, Fonz Fun Plug. Once installed it “unlocks” the NAS drive even further, it’s the equivalent of jailbreaking your iPhone or rooting your Android device. The FFP package sets up an SSH server which allows you to log into the underlying Linux operating system. From here you are free to install all sorts of additional packages further increasing the functionality and value of the device. The main packages you’d want to run for your media centre are CouchPotato and SickBeard. These packages take care of all your movie and TV needs. You give each bit of software a list of what you want to watch and at what quality. They will then keep track of this list, monitor release and air dates and then download your requested movies and TV series as soon as they become available. They do all the hard work and even automatically add them to your XBMC library and send you an alert. Both softwares are managed by nifty looking web interfaces. Ok, that’s beginning to sound like an advert, but these 2 bits of software are really awesome.
I should add that there are many other NAS drives around that can also do all this stuff and also run FFP. You always hear good stuff about the Synology range of NAS drives, but IMO, for the price, the ZyXel is the hands down winner.

1.2.2 Hard Drives
If you have bought an empty NAS drive, then you’ll need 1 or more hard drives. Now, I wouldn’t say any brand is better than another, at the end of the day, all brands suffer from failiures and you’ll always have the fanboys declaring their undying loyalty to their favourite brand while spreading horror stories of rival brands. You’ll then see another person reporting the exact opposite. Save yourself the hassle and just buy whatever offers the best value and performance in your price range. One other tip, make sure you buy the highest capacity drive you can afford as you’ll soon begin filling the drive and wish you had spent a little bit more and bought the next model up!

They come with a longer warranty (3 yrs) than your standard drive, which IMO is worth the additional cost.

There are also other added benefits of the WD RED, e.g when in a RAID configuration, which you can read about here.

Where to buy? Well, I tend to use Ebuyer for most of my computer parts as they’ve always been reliable and offer free shipping on a lot of products. I have bought hard drives from Scan in the past and they were good too, especially when it failed and they replaced it without fuss. Plus, their Today Only deals are worth keeping an eye on for some great deals. In the US you could try NewEgg.In the Canada you could try NewEgg.

1.2.3 A Raspberry Pi powered NAS?
It is actually completely possible to do all of the above on a Raspberry Pi, either the same one running XBMC or a second dedicated Pi. The first option would definitely not be advised. The Pi is a great device, but in terms of raw power, it’s lacking, so running an entire media centre from one Pi would be very slow! The other option is a second Pi which would act as a media server to the XBMC Pi, as well as handle all your downloads. But again, running all these services at once could be an issue for the little Pi. Then there’s network throughput. The Ethernet port on the Pi actually runs via the USB bus, so any data read from your hard drive must go through the USB bus twice which obviously quickly becomes congested which effects throughput. Then there’s the cost, the dedicated ZyXel NAS doesn’t cost much more than a second Pi so there’s probably not much point of taking this route. Unless of course you want another fun project to work on.

1.3 Boblight / LEDs

If you’ve never heard of boblight (or Ambilight) then checkout some videos and some pictures of boblight enabled media centres. Right, now you’ve seen that, you’re probably wondering how you do this and what you need to buy, well read on.

1.3.1 LEDs
There are various types of LEDs available to buy but for this guide you’ll want some WS2801 which are individually controlled RGB LEDs. They usually come in 2 types, in strings, or strips.

Strings look much like the regular Christmas lights you put on your tree. They are generally cheaper and you can position them at a variable intervals around your TV.

Strips are basically long PCBs with the LEDs fixed in position. You can cut these to length but you can’t change the distance between the LEDs. They are easier to mount on your TV but are also more expensive.

Which is the best type will depend on your TV, your budget and your willingness to do a bit of DIY. The strings will require you to build some sort of frame to mount to the back of the TV, while the strips can be stuck on fairly easily using double sided tape. However, if your TV produces a lot of heat you may find the glue in the tape will melt and the LEDs will come loose.

It’s also worth baring in mind the size of your TV. As a (very) rough guide, a string of 50 LEDs will be fine for 32″-37″ TVs, while 75 LEDs will be enough for 37″-42″ TVs. Bigger than that, you’ll probably want 100 LEDs. Since the strips have a fixed amount of LEDs per meter (usually 32 or 60) you don’t have much choice, you have to buy the right length to fit around the perimeter of your TV. I’d recommend 30 LED/m strips as when you consider a 40 inch TV would need about 2.75m / 165 LEDs at 60 LED/m, it gets pretty expensive and would probably be too bright. Actually, I’m not sure how well the Raspberry Pi would cope having to control all those LEDs whilst simultaneously running XBMC.

It seems the best place to buy WS2801 LEDs is eBay. Alibaba.com actually have a huge range of sellers with ws2801s in stock, but I think they tend to focus more on bulk orders, so I played it safe and went with eBay. Most of the eBay sellers are from China or Hong Kong and some in the US. I’m pretty certain they are all come from China anyway so I placed an order with a Chinese seller who was a bit cheaper. These are the string of LEDs I bought and I’d highly recommend this seller. Delivery took about 10 days and no customs duty to pay, the seller even let me know that my item had a failed delivery attempt as he had been checking the tracking number! (I hadn’t even checked it yet as I was expecting them to to take a lot longer to arrive!) He also followed up a few weeks later to check I had got them working as he had a few buyers complain they didn’t work when in fact they were wiring them up wrong.

1.3.2 Power Supply
Depending on where you look, each WS2801 LED draws a maximum current of between 30-60mA. Each LED will only draw this amount when it is set to white light at full brightness. So, assuming the maximum current is actually somewhere in the middle of that range, say 45mA, then 50 LEDs will draw around 2.25 Amps. In a real world scenario, my 50 LEDs are powered by a 2A 5V power supply and I’ve never noticed any problems, but then again, I never set my LEDs to full white light for long periods of time.

Number of LEDs

mA per LED

Calculate

function calculate(){document.getElementById(“result”).innerHTML = “You will require a ” + ((document.getElementById(“leds”).value * document.getElementById(“amps”).value)/1000) +”A power supply(Approx. guide only)”;}1.3.3 Mounting / Frame
The method you use to mount your LEDs will depend on the type of LEDs you have purchased and the type of TV you have. For example, the easiest method would be to tape some LED strips to a new model LED TV with a perfectly flat back. It gets a bit trickier with an older TV with curved back, or TVs with air vents and various ports to avoid. Another option is to make use of the VESA mount which most TVs have. You can build a frame using lightweight aluminium or plastic, attach your LEDs to this, and then mount to the back of your TV. This obviously involves quite a bit of effort, but the advantage of this is you can easily remove it and attach to another similar sized TV in the future.

Before going the frame route, my advice would be to get a large sheet of rigid cardboard the approximate size of your TV and then roughly mount the LEDs to this and then attach to the back of your TV. The reason for this is the positioning of the LEDs can take a while to get right. Obviously they need to be as close to the edge of the TV as possible and sit approximately behind the area of the TV which they are configured to represent. But if they are too close to the edge you can see them and if you have a clear bezel the light refracts through this and looks bad. This actually took me several attempts to get the positioning just right – each time cutting the cardboard down to size and remounting the LEDs. But now I have a template from which I can build a frame. It also has all the mounting holes marked up, plus air vents and ports which I need to avoid when I build my frame.

1.4 Other things to consider

1.4.1 TV and remotes
One of the things that makes the Raspberry Pi and RaspBMC so great is it’s ability to work out of the box with most TV remotes. If you have a newish TV (i.e anything after 2010) from one of the major brands then your TV probably supports CEC or whatever your particular manufacturer has branded it as:

Samsung – Anynet+

Sony – BRAVIA Link

LG – SimpLink

Panasonic – VIERA Link

…

Some TVs/remotes are better supported than others, for example my Samsung works pretty well, I have all the buttons you need to navigate and play/pause/FF/RW within XBMC plus a few spares which you can map to other or custom functions. If you’re about to buy a TV, it’s worth double checking the model online to see if it works well with the Pi/XBMC, although most new TVs are a safe bet and the CEC plugin for XBMC/Pi is always improving compatibility so you’ll probably be fine.
If you have a TV that doesn’t support CEC then there are various compatible remotes and receivers available. You can even build your own IR receiver connected to the Raspberry Pis GPIO pins and integrate it into your case. A good remote to use is the original XBOX DVD remote and dongle. With a simple modification, you can get this to work out the of box with RaspBMC. You can still pick these up cheaply on, you guessed it, eBay!

There are of course a plethora of iOS and Android remotes available. I’d recommend the Official XBMC for iOS and I’ve heard good things about the Yatse remote for Android devices.

1.4.2 HDMI Cable
I wouldn’t recommend buying an expensive HDMI cable, they are digital after all so they either work, or they don’t. Gone are they days when you needed a high end cable to maximise picture quality. As long as you’ve got a standard setup then your basic HDMI cable will do the job nicely. Don’t buy the really cheap HDMI cables though if you want CEC support. A lot of the cheap cables save money by only connecting the basic pins for audio/video and don’t actually wire up the CEC pins. So if you have a CEC TV but you can’t get it working, try another cable.

1.4.3 WiFi dongle
Although RaspBMC supports various WiFi dongles out of the box, I would recommend avoiding WiFi, purely for bandwidth reasons. You will get a much better experience using a wired ethernet connection than WiFi, hence the suggestion for the Raspberry Pi Model B. Plus, it’s infinitely easier to set up; plug in ethernet cable – done!

Part 2. Software

2.1 NAS Setup

2.1.1 Initial setup
Once you’ve installed the hard drive into the NAS and switched it on you’ll then need to run through the included ZyXel NAS Starter Utility. You’ll need to apply the default configuration. Once complete you should be able to find your NAS drive at http:\nsa310 and login using the default user/pass of admin/1234. I’d recommend changing this straight away via the Sharing>Users settings. You should also add a new share for downloads. Call this ‘downloads’, enable it and ‘make share public’. You can add additional shares here too if required, or just use the default music/video/photos. Next, from a PC navigate to the downloads share, e.g via Samba \nsa310downloads and create 3 folders: ‘incomplete’, ‘sickbeard’, ‘couchpotato’. Then create 2 folders in the \nsa310video share called: ‘TV Shows’ and ‘Movies’.

2.1.2 FFP Setup
Follow this guide to install the FFP package. This will give you SSH access and allow you to install various other packages and complete the rest of this tutorial. Essentially, you just download this file then place it here \nsa310adminzy-pkgs You may need to browse to the root of your NAS first, and then navigate to that path where you will be prompted for a password (use the admin account password you just changed).
Once the file is in place, open a browser and navigate to http:\nsa310 and login. Expand the ‘Applications’ tree and select packages. Find the FFP package and install it. Once complete you can now SSH into the NAS as root using your admin account/password.
Slacker is a package manager that comes with FFP, to set it up you need to run this script and then enable all repos:

/ffp/sbin/uwsiteloader.sh

You should now go ahead and install nano and zyxel_utils which lets you tweak FFP.

slacker -Ui nano zyxel_utils

You can configure zyxel_utils by un-commenting various options in the zyxel_utils.sh file:

nano /ffp/start/zyxel_utils.sh

More info about zyxel_utils can be found here, while more info about FFP can be found here (once FFP is installed).

2.1.3 Transmission
While you’re in the ZyXel packages menu, install Transmission. Once installed, but not* enabled, you’ll need to configure the settings. You can just leave them at defaults, but I would recommend changing the download paths, adding a torrent completion script and adding a password, especially if you plan to access Transmission remotely. Edit the settings file:

nano /usr/local/zy-pkgs/config/Transmission/settings.json

Modify these settings in the file above, obviously chose a proper user/pass:

The torrentdone.sh script doesn’t exist yet, but we’ll create that later.
Once you’ve changed and saved the settings, enable Transmission via the ZyXel admin page, then navigate to: http://nsa310:9091/ and hopefully you’ll be prompted to login and see the Transmission web interface. You can now test it is working by uploading a torrent file or providing a link to a torrent file or magnet link. You should find your download starts in the incomplete folder before being moved to the root of the downloads folder.

* transmission must be stopped/disabled before you can change the settings. If it is running, any changes you make won’t actually be saved.

2.1.3 Sickbeard
You basically need to follow the official SB install instructions here, but I have picked out the relevant parts, used The Pirate Bay fork by mr-orange and added NSA-310 specific instructions below:

First you need to install git, python, sqlite, wget and a few other packages so you can clone and then run Sickbeard.

If you have issues with certificates with the above command, or when updating SB in the future then try running this beforehand:

export GIT_SSL_NO_VERIFY=true

Run Sickbeard

cd my-sickbeard-install
python SickBeard.py

If it’s successful, in a browser navigate to http://nsa310:8081/ and you’ll see the Sickbeard web interface, woohoo!

Configuring sickbeard
Hover over the cog in the top right and select ‘Search settings’ and set the ‘Search frequency’. This is how often you want Sickbeard to check for episodes. Mine is set to 300 minutes (5 hours) which seems to work quite well.

Next, select the ‘torrent search’ tab where you need to:
– check ‘search torrents’
– Select Transmission as the ‘Torrent method’
– Set the host to: http://localhost:9091/
– Enter the Transmission user/pass if you have one
– Set the ‘Transmission directory’ to: /i-data/md0/downloads/sickbeard/

Run the test and ensure it’s successful. If it fails, check your password is correct, if it is, then try changing the host to http://nsa310:9091/ or http://IP_of_NAS:9091/ They all point to the same place, but for some reason SB can be picky.

Once it’s working, move onto the ‘Search Providers’ settings and enable Pirate Bay and any other torrent sites you want/have logins for. Now click the ‘Configure Built-in Providers’ and ensure Pirate Bay is configured to use a proxy if your ISP blocks it.

Set up the options ‘Episode naming’ and ‘Metadata’ tabs if you wish to do so.

Now click the ‘Notifications’ settings and set up XBMC notifications.
– Enable
– Check ‘Notify on Snatch’ , ‘Notify on Download’ and ‘Update Library’
– Set XBMC IP:Port (This is the IP of your Pi)
– Set user/pass for XBMC if you have one
– Set anything else you want and also any other notifications you fancy (there are loads)

Hit ‘Test XBMC’ and ensure it’s successful. The Pi must be on with XBMC running and the web server enabled.

Adding TV Shows
Now you need to add your TV shows, you do this by going to ‘Show List’ and then ‘Add Shows’.
Click ‘Add New Show’ and follow the steps to choose the show, the directory and quality settings etc. The directory should always be set to the root of your TV Show folder, i.e like this: ‘/i-data/md0/video/TV Shows’
No need to specify a sub-directory of the TV show name, even if it already exists, as Sickbeard will take care of that.

Now, provided the show is currently on air and torrents are found on Pirate Bay, Sickbeard will snatch a torrent and send it to Transmission. It will notify XBMC and a popup will appear on your TV. The torrent will download to the incomplete download folder and be moved to the Sickbeard download folder when complete. Once a download completes, Transmission will run the ‘torrentdone.sh’ which we configured earlier. This script will handle the manual-postprocessing and update the XBMC library (more on that later).

2.1.3 Couchpotato
Couchpotato is similar to Sickbeard and requires git and python to install and run:

With any luck, Couchpotato will be up and running and will have started a webserver here: http://nsa310:5050

Run through the wizard and set it up how you wish ensuring to:
– Set up Transmission with the same details as Sickbeard
– Ensure Transmission directory is set to: /i-data/md0/downloads/couchpotato/
In the rename downloaded movies section:
– Set ‘run every’ to 0
– Set the ‘To’ directory to /i-data/md0/video/Movies/
– Set the ‘From’ directory to /i-data/md0/downloads/couchpotato/
– Set ‘Force Every’ to 0

Once the wizard is complete, I’d suggest going to the settings and setting up ‘Notifications’ and changing ‘Quality’ settings to suit your requirements.

Now, search for a movie at the top and select a quality. With any luck, a torrent will be snatched and sent to Transmission, XBMC will be notified. The movie will finish downloading and be moved to the couchpotato download folder and the ‘torrentdone.sh’ will fire.

2.1.4 Post-Processing
Both Sickbeard and Couchpotato have automated post-processing which you may have noticed have been disabled in my setup. The reason for this is I didn’t like the way they run and how they interfere with other files you may have in your download folder (I lost a bunch of non-SB/CP downloads after either SB or CP “tidied up” after processing). So to avoid this happening again, I set up the SB and CP folders in the download share so they are separate from my other downloads. The other thing I didn’t like was how CP checks for completed downloads every x minutes. Set this option to check every 5 minutes and 99% of the time there will be nothing for it to process. Set it to every 5 hours and you could be waiting a few hours for CP to check for a complete download. It seems to make much for sense to fire up the post processing only when a download completes.
This is where the Transmission ‘torrentdone.sh’ script comes into play. My script will run whenever Transmission completes a download, be it CP, SB or a normal download I have started. The script triggers SB and CP to check their relevant download folders for any new content, it fixes some file permissions which I was having trouble with somewhere along the downloading process and also writes the details to a log file so you can check when it has run. This was mainly for debugging, but I’ve left it in as it may be useful. One other advantage of this script is it means your hard drive isn’t spinning up every x mins/hrs to check for completed downloads as it only runs when it’s actually needed. Note: the script pings your Raspberry Pi and only runs if the Pi is running. No point processing if the Pi isn’t up to scan the new media. See the ‘incremental scans’ section below to see how the script runs next time you boot the Pi.

If you use a username/password for Sickbeard, you will need to add it to the start of the URL, e.g. http://username:password@127.0.0.1:8081/…
You will find you Couchpotato API Key on the general settings page.
Make the script executable

chmod +x /ffp/home/root/torrentdone.sh

I’m sure there are better ways to handle post-processing and maybe I’ve been setting up SB/CP wrong, but this method seems to work ok for me and allows my hard drive to remain asleep the majority of the time.

2.1.5 Autostart Sickbeard and CouchPotato
Once SB and CP are installed and running without issues then you will want to start them automatically each time the NAS boots.
To do this you need to create a start up script on the NAS in /ffp/start/:

You may need to modify the paths if you installed them in a different location
Finally, make the script executable:

chmod +x /ffp/start/startSBCP.sh

2.1.6 MySQL
The final bit of set up on the NAS is to install and configure a MySQL database to store XBMCs library.
This is a lot easier and quicker than it sounds! Login to the NAS admin panel and go to the packages settings. Install and enable ‘PHP-MySQL-phpMyAdmin’. Once complete, go to http://nsa310/pkg/phpmyadmin/ and login with the user/pass of root/1234.
Click the SQL tab at the top, paste this and hit go to create a user called xbmc.

CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';

Told you it was easy!

2.1.7 Copying your existing media to the NAS
You’ll probably have some media on another PC/laptop or on external hard drives. You can copy this to the NAS and place in any of the network shares. By far the easiest way is to transfer your files from another machine via samba. i.e. navigate to \nsa310 and simply copy & paste your files over. If you have a USB device, plug it into your PC/laptop and copy & paste over to the NAS. You can plug USB devices into your NAS directly, but I found the copying process extremely slow and a pain in the ass, so I wouldn’t recommend it.

One tip though, make sure you use a wired connection from the PC/laptop to the NAS drive either directly or via a router/switch (preferably gigabit), to maximise the transfer speeds. I managed to get around 55 MB/s using this method which equates to almost 200 GB an hour.

2.2 Raspbery Pi Setup

So your NAS is now set up with media and it can download new TV and movies automatically. Now we need to set up the Raspberry Pi by installing RaspBMC, configuring XBMC to find your media on the NAS drive and creating a library of it stored in MySQL also on the NAS drive.

2.2.1 RaspBMC
Download the relevant RaspBMC installer for your OS and follow the instructions here.
If you’re opting for a USB install, you still need to install to the SD card but check the USB option. Then plug the SD and USB into the Pi and turn on. The Pi will run the RaspBMC setup, wipe the USB drive and then install the OS on it, so make sure you don’t have the wrong USB device plugged in (e.g. a hard drive with all your media!).

2.2.2 XBMC
Once RaspBMC is installed you’ll need to enable Samba (if it isn’t already) in the RaspBMC settings (below the ‘Programs’ option). Then navigate to \raspbmcpi.xbmcuserdata and create a file called advancedsettings.xml
With a text editor paste this XML, save and reboot XBMC:

You’ll need to change the IP addresses to that of your NAS drive.
Once rebooted you’ll need to start scanning your media library.

Initial scanning of your media library
From the main XBMC menu, select Videos>Files>Add Videos.
Click ‘Browse’, ‘Windows Network (SMB)’, select your workgroup, then your NAS drive, then find your Movies folder. Select the root and then press OK before OKing the next menu.
You’ll then be asked to ‘Set the content’ of this folder, in this case it’s movies and we can leave the settings as default. Press OK and XBMC should start scanning your media, you’ll see a progress window popup top right of the screen. Depending on how many movies you have, it could take anywhere from a few minutes, to several hours.

While it’s scanning, login to your phpMyAdmin/MySQL installation and check XBMC is writing to this database and not an internal one on the Pi. You should see 2 databases on the top left of the phpMyAdmin page called MyMusic32 and MyVideos75 or similar. These are the XBMC databases created by the Pi. If they are not there, stop the scan via the context menu in XBMC. If you now have a Movies option on the main XBMC menu that contains your movies but you don’t have a MySQL database then something went wrong with the advancedsettings.xml file so check that. You could also look at the XBMC log and search for “advancedsettings” or “SQL” to try and figure out what went wrong. (SSH into the Pi and ‘nano /home/pi/.xbmc/temp/xbmc.log’)

Once you’re happy that it is scanning into MySQL you can either let it run through all your media, or copy the advancedsettings.xml to an XBMC installation on a more powerful machine (pretty much any laptop/PC will do) and run the scan from there into the MySQL database. This will be a lot quicker, especially if you have a lot of media. Next time you browse your library on your Pi you’ll find all your media is there, without the Pi having to scan it itself. This is one of the benefits of MySQL, you can have multiple devices all reading from the same MySQL database

Incremental scans
Previously you will have set up a script which runs when a Transmission torrent completes. This should run the SB/CP post-processing to move the video file(s) to the correct location and also update the XBMC library…but only if the Pi is switched on. If the Pi is off, it will not run. Therefore you will want the script to run automatically next time you switch on the Pi. You could enable a full scan on boot within the XBMC settings, but this is overkill as it takes quite a while, slows down the Pi and most of the time you won’t even have new media, so there’s no point scanning.

So, the solution I have come up with is to run SB/CP post-processing on every boot of the Pi. This takes place on the NAS so doesn’t slow down the Pi at all. If SB/CP finds some new media, it will process it and then ask XBMC to scan the relevant movie or TV show folder only (This is a lot faster than running a full scan). If no media is found by SB/CP then XBMC will not scan.
I added a 45 second delay to the script which should ensure the Pi has fully booted before SP/CP attempts to invoke a library scan.

In terms of software, boblight is now really easy to set up. The only steps you need to do are:

Install RaspbmcIf you have followed this guide, you will have already done this.

Create/copy boblight.confThis needs to be placed in /etc/Make sure it is ‘Speedy’ compatible (see this blog post).

(optional) Apply your boblight optionsEdit this file:

sudo nano /etc/init/boblight-dispmanx.conf

Look for the line beginning “exec /usr/bin/boblight-dispmanx…” and change to whatever settings you want. If you use boblight clients on other machines to send colour info to the Pi, you may also want to change priority (-p) from 100 back to 129. You can also add “-b on” to enable LEDs for the XBMC GUI, or off if you only want LEDs on when video is playing.

Creating boblight.conf
boblight.conf is a config file which describes the layout of your LEDs, how many you have and where they are positioned around your TV screen.
You can find various tools/generators to create this file for you (e.g. this page, this page or this tool), but often it’s better to just cut and paste bits from other configs and fine tune the various settings.Here is a basic config file to get you started with creating your own, or you can just use this one if you have 50 LEDs (13 on the sides, 24 on the top starting clockwise from bottom left when looking at the TV).
To copy this config straight to your Pi:

Boblight Web App
Sometimes you may want to control the boblight LEDs, e.g. switch them on or off, set them a static colour etc. I created a little web app to handle this which is hosted on the Raspberry Pi and uses php and python to send commands to your LEDs. If you have an Android device then BobDroid does the same job and is worth a look.
You can see a demo of my webapp here. To run it from your Pi you need to install a webserver, in this case nginx, and php support. To do this:

Download and extract this zip to /home/pi/www/ (so you should see index.php at /home/pi/www/index.php)

Navigate to http://192.168.0.8:88 (or whatever your Raspberry IP is) and you’ll hopefully see something similar to the screenshot above.
If not, restart nginx and php to ensure they are running:

sudo service nginx restart
sudo service php5-fpm restart

Control Centre
You’ve probably noticed there are now a lot of web interfaces you need to visit to configure all of the features of your media centre. Remembering all the IPs and ports is a pain, so I decided to create a simple webpage which acts as the main hub where you can access everything you need. This can be hosted locally on the Pi/NAS or just a HTML file on your PC. My control page is actually hosted on the internet so I can access it anywhere (the webpage, as well as each individual web interface is secured by a password, so it’s fairly secure).

You can see a demo page here, it’s nothing flash, I designed it to work nicely on my iPhone. You can download the images/html code from here. You will need to add your own IPs and passwords etc.
Either place the files on your local device or store somewhere like a public Dropbox folder so you can access from multiple locations/internet.

It now uses Speedy’s boblight daemon
Speedy’s version requires some changes to boblight.conf so you may find your existing version no longer works.Basically, all ‘name’ values need to be changed to exact 3 characters long. That includes the values in the [color] and [light] sections.See this version here to get an idea of what needs to be changed: http://dl.dropboxusercontent.com/u/6885567/boblight_50xWS2801_speedy.conf
The advantage of this is, as the name suggests, better performance and less CPU intensive.

Colour info is now captured by a standalone process, boblight-dispmanx
Previously, colour information was captured by a modified OMXplayer when video was playing. Now, boblight-dispmanx is running all the time and essentially taking screenshots of whatever is on screen. e.g the XBMC interface.
While the OMXplayer version read settings from boboptions.txt, the new dispmanx version requires the settings to be passed to it when it starts.

So, to get boblight working in the July update, it’s easier than ever:

Install Raspbmc July releaseI always tend to do a complete reinstall which seems to go a lot smoother than doing an update, but an update should work too.

Create/copy boblight.confThis needs to be placed in /etc/Make sure it is ‘Speedy’ compatible (see above).

(optional) Apply your boblight optionsEdit this file:

sudo nano /etc/init/boblight-dispmanx.conf

Look for the line beginning “exec /usr/bin/boblight-dispmanx…” and change to whatever settings you had in boboptions.txt. If you use boblight clients on other machines to send colour info to the Pi, you may also want to change priority from 100 back to 129. Update: add “-b on” to enable lights for GUI

Boblight has been running quite successfully on Raspbmc for quite a while, but now with the release of boblight-dispmanx (which I previously discussed here) it’s OpenElec’s turn.

The steps to get it up and running are pretty straightforward, especially if you already have a working setup with Raspbmc.

Step 1. Install OpenElec
I won’t go into detail here as there’s already plenty of guides around on how to do this. One important note is that due to firmware requirements you must use an OpenElec build after July 19th July. This means 3.0.6 won’t work.
For this guide I installed the latest dev build at the time: devel-20130727005416-r15181.

Step 2. Set up the hardware
This is identical to any other Raspberry Pi boblight setup so I’ll direct you to my PiBob hardware guide here. If you already have boblight running on the Pi with another OS then leave the hardware as it is.
If you haven’t bought your hardware yet, have a look here for a parts list.

Step 3. Install boblightd
Within OpenElec, goto settings and Add-ons. Select OpenElec add-ons and then Services. Install boblightd.
You now need to tell boblightd about your LEDs via boblight.conf. If you have one already, place it here: \YOUR_PI_IPUserdataaddon_dataservice.multimedia.boblightd
If you don’t have one, then check out the PiBob software guide here for an example .conf and also info on how to make/customise your own.

Step 4. Install boblight-dispmanx
In the step before you installed the daemon or server which communicates with the LEDs, now you need to install the client which is responsible for capturing the colour information and sending to the daemon. SSH into the Pi and run:

You’ll then need to paste this into autostart.sh and save.
Feel free to modify or add extra settings here. e.g anything you previously had in boboptions.txt should be added here. Don’t forget the “-o” before each setting.

With any luck, XBMC will boot up and the LEDs will kick in automatically.

Troubleshooting

1. If XBMC crashes when you play a video, make sure your firmware is 19th July or newer. Check your firmware version:

vcgencmd version

If you need to update it, read below.

2. If after running boblight-dispmanx your LEDs are changing colour but it’s all a bit strange and not really matching what’s on screen you may need to update your firmware.
OpenElec doesn’t have rpi-update and I couldn’t find a way to successfully install and run it. One way I found to upgrade the firmware is to completely upgrade OpenElec. See Kirk Miller’s guide here.

3. If you experience flickering when playing back videos then you guessed it… make sure your firmware is up to date.

4.If you get this error when starting boblight-dispmanx then ensure boblightd is running first.

If it returns a pid (a number) then it’s running, if it doesn’t return anything then boblightd is not running. Double check you installed and enabled the boblightd plugin and not the boblight plugin. The ‘d’ is important!