Our pick of the most fun and useful things you can do with your Raspberry Pi
It’s the spiritual successor to the Sinclair Spectrum. The ultra-cheap yet amazingly powerful barebones computer that’s perfect for a thousand and one different projects.
We love the Raspberry Pi, and there’s so much more to it than a just a cheap Linux PC for web browsing and email. Thanks to the Pi’s GPIO (General-Purpose Input/Output) pins and the powerful Python programming language, you can turn the unassuming circuit board into a multiroom audio controller, video intercom system, time-lapse camera… given time, ingenuity and the will to plug electronic components into a breadboard, the possibilities are endless.
In this article we’ve gathered some of our favourite Raspberry Pi projects, to help you get the most out of your £30 mini wonder. Get set to unleash the power of Pi.
Make a multiroom audio system – part 1
Save money and boost your geek credentials by putting together your own wireless audio system
Multiroom audio systems are a must for music lovers. You can listen to a song in the kitchen and you don’t need to do anything to enjoy the same track as you move into the dining room for your meal. You can control playback from your smartphone or tablet, or even set different moods for different rooms at a house party by playing a funky playlist in your living room and a calmer selection in the kitchen. The problem is, many multiroom audio systems install a secondary wireless network, and the speaker units can easily cost £300 each. By using a Raspberry Pi, your own wireless network and a NAS or PC as a server, however, you can make your own high-quality wireless speaker units for around £100 each.
As the basis for the system we’ve chosen Logitech’s Squeezebox NAS software (also known as Logitech Media Server, a common app on most NAS units) and a Raspberry Pi. We used a Raspberry Pi 2, as it has four USB ports. You’ll need these ports as for this project we’ve decided to use a USB sound card; the crackly integrated Pi audio output just isn’t good enough for music. We chose to use a simple £3 USB sound card bought from thepihut.com as it does the job and is natively supported by the Raspbian operating system. However, you could use a fancy USB sound card such as Creative’s Sound Blaster Play! See here for a full list of Pi- compatible USB sound cards and installation instructions. The other ports will be taken up with the Wi-Fi dongle (see below) and a keyboard and mouse for setup. You could, of course, use a USB hub to set up a two-port Pi.
|Raspberry Pi 2 Model B||£30||www.currys.co.uk|
|8GB microSD card||£2||www.ebuyer.com|
|USB sound card||£3||http://thepihut.com|
|Multicomp clear case||£5||http://thepihut.com|
|Creative GigaWorks T20 Series II speakers||£85||www.currys.co.uk|
We chose Edimax’s EW-7811Un Wi-Fi dongle as it’s tiny, only £6 and is natively supported by Raspbian, so we won’t have to faff around installing a driver. Other Wi-Fi dongles are also natively supported by Raspbian; any shop-branded dongles from www.modmypi.com or http://thepihut.com will be fine, and there’s a full list of compatible dongles. Although specialist Raspberry Pi resellers sell microSD cards pre-loaded with Raspbian, it’s easy enough to install it yourself on a cheap card. We chose an 8GB Class 10 microSD card and SD adaptor, which cost just £2 from Ebuyer.
We used the cheapest clear case we could find for our Pi B+, which was Multicomp’s Clear Case at £5. Clear cases let you see the Pi’s power and activity lights, but to reduce light pollution in your living room, you could use any case you like. You could even build a case from spare Lego to house the USB sound card neatly and hide the Wi-Fi dongle’s flashing activity light. As the Wi-Fi dongle is power-hungry, and the Pi is powering a USB sound card as well, opt for a 2A power supply. Modmypi.com and Thepihut.com sell such supplies for a fiver.
To round off your speaker unit, you’ll need speakers. Creative’s GigaWorks T20 Series II is a high-quality set of powered stereo speakers, but you can use any 2.0 or 2.1 speakers you like as long as they have their own power supply. Our shopping list shows the parts for a single wireless speaker unit; for a multiroom audio setup, you’ll need one set per room.
Whichever speakers you choose, the build process starts by downloading the latest version of Raspbian, as well as SD Formatter 4.0, Win32DiskImager and PuTTY. While Raspbian is downloading, you could put the Pi in its case.
Once downloaded, extract the Raspbian image from its zip file. Put the microSD card into the SD adaptor and insert this into your PC; wipe the SD card with SD Formatter and then install the extracted Raspbian.img file on to the SD card using Win32 Disk Imager. Once Raspbian is written to the SD card, take the microSD card out of the SD adaptor and insert it into the Pi. Next insert the Wi-Fi dongle and a USB keyboard, then plug in the Micro USB power adaptor.
Log into the Pi with the standard credentials (pi, raspberry) and then type ‘sudo raspi-config’. Hit Enter to select the first option, Expand the filesystem. Once the Pi tells you the file system has been expanded, change the password (option 2) by pressing down arrow, Enter and following the instructions. Exit and reboot the Pi by pressing the right arrow twice and hitting Enter.Log in again and you’re ready to set up the Wi-Fi dongle. Edit the wpa_supplicant config file by typing ‘sudo nano /etc/wpa_supplicant /wpa_supplicant.conf’ and pressing Enter. Add the following at the end of the file (using your SSID and Wi-Fi password, remembering that you’ll have to use your 2.4GHz network unless your Wi-Fi dongle is very fancy):
Save and exit by pressing Ctrl+X, Y and then Enter. Check the change works by typing ‘sudo reboot’, log back in once the Pi has rebooted and then type ‘ifconfig’ to display the Pi’s network settings. You should see a section for ‘wlan0’ and an IP address that’s in line with other IP addresses on your network, probably something like 192.168.1.xxx.
Before updating your Pi you should uninstall Wolfram Engine, as this can interfere with this project, isn’t required and massively slows down the updating process. Once Wolfram is uninstalled, you can update Raspbian and its applications as normal:
sudo apt-get remove –y wolfram-engine
sudo apt-get updatesudo apt-get –y upgrade
As the Pi updates, log into your router and give the Pi and the server you’re going to use for Squeezebox (in our case, a Synology NAS) a static IP address. Each router manufacturer has a different process for assigning static IPs, so refer to your router’s manual or the manufacturer’s website to see how to do it. Save your changes and log out of your router.
If your Squeezebox server isn’t already loaded with your music, find the server on your network and copy your music files from your PC (or PCs) to a Music folder on your Squeezebox server via your normal file browser (Explorer for Windows PC, for example). Once you’re happy that your Squeezebox server is loaded with tunes, log into the server’s web page and install Logitech’s Squeezebox app (this might be called Logitech Media Server, as on a Synology NAS). Launch the app and you’ll be asked to create a free Squeezebox account, so do so and then log into Squeezebox using those credentials.
Now run the newly installed NAS Squeezebox app. The app should be simple to set up; you just point it at the Music and Playlists folder on your Squeezebox server and click Next. On our Synology NAS the automatically created Music folder is located in ‘volume1’. We didn’t have a Playlists folder, so just pointed Squeezebox at the Music folder again.
Logitech’s Squeezebox app might be called “Logitech Media Server” on your NAS
Once Squeezebox has scanned and created your music library, you’ll see the main Squeezebox web page. If you add music to your Squeezebox server in the future, you’ll have to click on the Settings button at the bottom-right and then click the Rescan button on the settings page that appears to make sure it’s added to the library.
The easiest way to use Squeezebox is to create playlists, but this is a little clunky. You have to browse your music library in the left-hand pane of Squeezebox and add tracks to the right-hand pane via the small ‘+’ icon that appears when you hover your mouse over an item in the left-hand pane. Once the right-hand pane is populated (you can move tracks up and down the order), you need to click the small Save button at the lower right corner and then name the playlist via the input box that will appear at the top of the left-hand pane. Network lag can lead to seconds passing after each mouse click, making the process even more annoying, so be patient. Thankfully you can add groups of tracks to playlists: if you browse by genre, album or artist in the left pane you’ll see that each result has the ‘+’ icon, so you can add all Blues tracks to a playlist with a single click, for example.
Just point Squeezebox at the Music folder of your NAS (or alternative media server) and it will create your music library automatically
You may now have a Squeezebox server and music playlists, but you’ll need a Squeezebox player to actually listen to music (you can’t even listen to music via the Squeezebox web page, as it’s just a remote control). Below we show you how to make your Pi into a Squeezebox player, but for now we’ll use an iOS or Android device. Install Squeezecast (free, iOS) or SB Player (£2.35, Android) on your smartphone or tablet.
You’ll need to enter the settings for your Squeezebox server. You can find the IP address and port by looking at the address of the Squeezebox web page; ours said ‘192.168.1.145:9002’ so our server had an IP address of 192.168.1.145 and Squeezebox was using port 9002. The app should then find your Squeezebox server and load your playlists and tracks. The Squeezebox web page should also report that it’s found a Squeezebox player in the drop-down menu toward the top-right of the page; in the case of iOS’s Squeezecast, the device and app showed up as ‘Squeezeslave’.