A Beginner’s Guide to DIYing with the Raspberry Pi

The Raspberry Pi is a wonderful little computer that fits in the palm of your hand, yet packs enough power to run your home media center, a VPN, and a lot more. Before you can do anything awesome, however, you need to configure it and install an operating system. Here’s how.

It’s Raspberry Pi week at Lifehacker, and for the next five days we’ll be showing you some cool DIY projects you can put together with this little miracle of a device. If you haven’t bought one yet, check out the first section below to learn more about what it is, what you’ll need, and the cool stuff you can do with one.

What’s a Raspberry Pi?

A Beginner's Guide to DIYing with the Raspberry PiThe Raspberry Pi is a very capable mini computer that’s small enough to fit in your pocket (even though you’d probably never keep it there). For about $35-40, you get a caseless computer with HDMI and analog composite video output. You can add up to two USB devices (which, in most cases, will be a mouse and keyboard) and connect it to the internet via wired ethernet. The Raspberry Pi is powerful and inexpensive, allowing you to create a home media center, internet radio, or even your own VPN server on the cheap. That said, a little setup and a lot of other parts are required to get it up and running. In this post we’ll take a look at how to get a Raspberry Pi set up so you can start using it for a variety of purposes.

What You’ll Need

The Raspberry Pi may be a computer all on its own, but you’ll still need a lot of other things to make it work:

  • A Raspberry Pi: If you’re not sure where to buy one, you’ll find links below to help you out.
  • An HDMI- or composite video-capable television or monitor: In this post we’ll be working with an HDMI-capable monitor because it offers better resolution and built-in sound. You can use analog if you want, however.
  • An HDMI or composite video cable: You’ll need this cable to connect your Raspberry Pi to your television or monitor.
  • A 4GB Class 4 SD card (or better) and a card reader (if you don’t have one built into your computer): Most SD cards will work, but some aren’t compatible and will therefore cause issues. You can find out which cards are compatible, or locate a place to buy a compatible card with an operating system pre-installed, on this page.
  • A USB keyboard and mouse: Any standard USB keyboard or mouse will do. Wireless (non-Bluetooth) peripherals worked for me, but I had to unplug them and plug them back in after the Raspberry Pi booted. You’ll have fewer issues with fully wired keyboards and mice.
  • An ethernet cable: Any standard ethernet cable will do. You only need this to connect to your network and the internet, however, so you can leave this item out if desired.
  • A good quality, micro USB power supply that can provide at least
    700mA at 5V
    : Most modern smartphone chargers supply 700mA at 5V, but not all do. Check the bottom of your charger and look for a block of text. You’ll see its output values in that text which may read 0.7A instead of 700mA). If it offers at least that much power, you’re probably good to go. Just don’t use a poor quality charger or you may run into problems.
  • A 3.5mm stereo audio cable: You only need this if you’re using analog video and want to connect your Raspberry Pi to a set of external speakers or internal ones on your television or monitor.

You can find the majority of those items pretty much anywhere, but Raspberry Pi units are difficult to come by due to popular demand. Here are a few places to try that often have a few in stock:

  • Adafruit (the kit is almost always in stock if the singular unit isn’t)
  • Amazon (almost always in stock, but through third parties at a premium)
  • Allied Electronics (only available in North America)

Once you’ve got your Raspberry Pi, you can start setting it up!

How to Set Up Your Raspberry Pi with a Basic Operating System

A Beginner's Guide to DIYing with the Raspberry PiYou can use the Raspberry Pi for all sorts of different things—some of which may require their own special operating systems—but to start out, it’s a good idea to get acquainted with the Pi by installing Raspbian, a Raspberry Pi-focused version of Linux. Here’s what you need to do.

Step One: Prepare Your SD Card

First things first, we need to prepare your SD card for the Raspberry Pi. This involves formatting it properly and putting Raspbian, the standard Raspberry Pi operating system, on it. The steps vary depending on whether or not you’re on a Mac, Linux, or Windows PC, so just follow the instructions for your operating system below.

Windows
A Beginner's Guide to DIYing with the Raspberry Pi

  1. Download the lastest version of Raspbian and unzip the .img file inside. (It’s almost 500MB so it may take a little while to download.)
  2. Download Win32DiskImager and unzip the application (.exe file) inside.
  3. Insert your SD card into your Windows PC using a card reader.
  4. Open Win32DiskImager.exe, the application you just downloaded, by double-clicking on it. If you’re running Windows 7 or 8, right click on it and choose “Run as Administrator” instead.
  5. If your SD card isn’t automatically detected by the application, click on the drop-down menu at the top right (labeled “Device”) and choose it from the list.
  6. In the image file section of the application, click the little folder icon and choose the Raspbian .img file you just downloaded.
  7. Click the Write button and wait for Win32DiskImager to do its thing. When it finishes, you can safely eject your SD card and insert it into your Raspberry Pi.

OS X
A Beginner's Guide to DIYing with the Raspberry Pi

  1. Download the lastest version of Raspbian and unzip the .img file inside. (It’s almost 500MB so it may take a little while to download.)
  2. Download RPi-sd card builder (be sure to pick the appropriate version for your installed version of OS X) and unzip the application.
  3. Insert your SD card into your Mac using a card reader.
  4. Open RPi-sd card builder. You’ll immediately be asked to choose a Raspbian image. Choose the .img file you downloaded earlier.
  5. You’ll be asked if your SD card is connected. Since we inserted it earlier, it is, so go ahead and click Continue. You’ll be presented with SD card options. If you only have one inserted, you won’t see anything else in the list and it’ll be checked. If not, just check only the card you want to use and click OK.
  6. Enter your administrator password and click OK.
  7. You’ll be asked if the SD card was ejected. This is supposed to happen, as the application needs to unmount it so it can perform a direct copy. Double-check that your SD card is no longer available in the Finder. DO NOT remove it from your USB port. When you’re sure, click Continue.
  8. RPi-sd card builder finishes prepping your SD card, safely eject it and insert it into your Raspberry Pi unit.

RPi-sd card builder isn’t an app so much as it’s an Automator action that acts like one. Some people have reported issues using it, so if you run into problems just open up the Terminal app (Your Hard Drive → Applications → Utilities → Terminal) and follow the instructions for Linux.

Linux
A Beginner's Guide to DIYing with the Raspberry Pi

  1. Download the lastest version of Raspbian and unzip the .img file inside. (It’s almost 500MB so it may take a little while to download.)
  2. Open up your Linux terminal emulator of choice. If you don’t have one, try our favorite.
  3. Insert your SD card. If it mounts automatically, unmount it but make note of its location (e.g. /dev/disk2s1).Even though the card is unmounted, do not remove it from the reader
  4. In the command line, you’re going to need to type a single line to copy the contents of the Raspbian .img file to your SD card. It’ll look like this:

    sudo dd if=PATH_TO_IMG_FILE of=PATH_TO_SD_CARD_MOUNT_POINT bs=1m

    You’ll need to replace PATH_TO_IMG_FILE with the path to the .img file and PATH_TO_SD_CARD_MOUNT_POINT with the path to the SD card mount point. (The bs=1m just specifies the byte size and you don’t need to mess with it.) When you’re done, the command should look something like this:

    sudo dd if=/Users/adachis/Downloads/2012-12-16-wheezy-raspbian.img of=/dev/disk2s1 bs=1m

    It’s very important that you do not get this information wrong or you could end up writing Raspbian to the wrong disk and cause serious data loss. Be careful! When you’re sure you’ve got everything right, press enter.

  5. You will be prompted for the root password (or your administrator password for those of you on OS X who are using this method). Type it and press enter.
  6. It’ll take some time for the dd command to copy everything over to your SD card. While that happens, it’ll probably look like the Terminal froze up. Don’t worry, it’s still working and will likely take longer than an average 2GB copy to an SD card (so be patient). When it finishes, the command prompt will return and your SD card will be ready. Eject it safely and stick it in your Raspberry Pi.

Step Two: Hook Up Your Raspberry Pi

A Beginner's Guide to DIYing with the Raspberry PiConnecting everything to your Raspberry Pi is pretty easy. Start by connecting the HDMI cable from the unit to your television (or monitor). If you’re using the analog composite video connection instead, connect it to your television (or monitor) and plug in a set of speakers to the 3.5mm audio jack. If you want your Raspberry Pi to connect to your network and/or the internet, use an Ethernet cable to connect it to your router. If you’ve set up a computer before, this should all seem familiar.

Finally, you need to connect your Raspberry Pi with a micro USB power adapter. As mentioned earlier, you need an adapter that can provide at least 700mA at 5V. Fortunately, you probably already have one. Many smartphone and tablet chargers utilize micro USB and provide 700mA at 5V (or more). You can find out by reading the small text on the plug and looking for theoutput section. (Note: it may say 0.7A (or higher) instead of 700mA.) When you have a compatible power adapter on hand, connect it to a micro USB cable and then connect that cable to the micro USB port on your Raspberry Pi unit. It’ll turn on all by itself and you should see it boot for the first time.

Step Three: Configure Your Raspberry Pi

A Beginner's Guide to DIYing with the Raspberry PiOnce your Raspberry Pi boots for the first time you’ll need to configure a few things. You’ll know it’s ready for you when you see a Raspi-config window with a pretty big list of settings. You can mess with the others if you feel so inclined, but the only thing you really need to do is expand the file system so you can use up all the space on your SD card. To do so, follow these steps:

  1. Select expand_rootfs (the second option) and press enter.
  2. Confirm that you want to expand the file system and let Raspbian do its thing.
  3. When you’re returned to the configuration list, go all the way to the bottom and select the Finish option.
  4. It’ll ask you if you want to reboot. Choose yes.

Your Raspberry Pi will reboot and take a little longer this time because it needs to expand the file system. After a about a minute you’ll be asked to log in. You’ll need to use the default username and password:

Username: pi
Password: raspberry

Once you’ve logged in, you’ve got yourself a working Raspberry Pi. Congratulations!


Of course, this is far from the end. You can use your Pi as much more than just a tiny computer, so check out Lifehacker all week at 8:00 AM PT for how-tos on some of the coolest things you can do with it. Tomorrow we’ll show you how to turn that tiny little board into a killer XBMC media center.

Photos by Denise Kappa (Shutterstock), maymak (Shutterstock), Pakhnyushcha (Shutterstock), and Anan Kaewkhammul (Shutterstock), and me.